org.eclipse.mylyn.trac.core_3.7.1.v20120425-0100

16:46:59.744 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.trac.core_3.7.1.v20120425-0100.jar
package org.eclipse.mylyn.internal.trac.core.util;

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.AuthScheme;
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;

public class TracHttpClientTransportFactory
  implements XmlRpcTransportFactory
{
  private final XmlRpcClient xmlRpcClient;
  private AbstractWebLocation location;
  private final HttpClient httpClient;
  private HttpMethodInterceptor interceptor;
  
  public static class TracHttpClientTransport
    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 TracHttpClientTransport(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)
      {
        TracHttpClientTransportFactory.TracHttpException e = new TracHttpClientTransportFactory.TracHttpException(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 TracXmlRpcClientRequest))
      {
        TracXmlRpcClientRequest tracRequest = (TracXmlRpcClientRequest)request;
        monitor = tracRequest.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 localSslCertificateException)
      {
        throw new TracHttpClientTransportFactory.TracHttpException(499);
      }
      catch (IOException e)
      {
        throw new XmlRpcException("I/O error while communicating with HTTP server: " + e.getMessage(), e);
      }
    }
  }
  
  public static class TracHttpException
    extends XmlRpcException
  {
    private static final long serialVersionUID = 9032521978140685830L;
    private AuthScheme authScheme;
    
    public TracHttpException(int responseCode)
    {
      super("HTTP Error " + responseCode);
    }
    
    public AuthScheme getAuthScheme()
    {
      return authScheme;
    }
    
    public void setAuthScheme(AuthScheme authScheme)
    {
      this.authScheme = authScheme;
    }
  }
  
  public TracHttpClientTransportFactory(XmlRpcClient xmlRpcClient, HttpClient httpClient)
  {
    this.xmlRpcClient = xmlRpcClient;
    this.httpClient = httpClient;
  }
  
  public AbstractWebLocation getLocation()
  {
    return location;
  }
  
  public XmlRpcTransport getTransport()
  {
    return new TracHttpClientTransport(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.trac.core.util.TracHttpClientTransportFactory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.trac.core.util;

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

public class TracHttpClientTransportFactory$TracHttpException
  extends XmlRpcException
{
  private static final long serialVersionUID = 9032521978140685830L;
  private AuthScheme authScheme;
  
  public TracHttpClientTransportFactory$TracHttpException(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.trac.core.util.TracHttpClientTransportFactory.TracHttpException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.trac.core.util;

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

public class TracXmlRpcClientRequest
  extends XmlRpcClientRequestImpl
{
  private final IProgressMonitor progressMonitor;
  
  public TracXmlRpcClientRequest(XmlRpcRequestConfig config, String methodName, Object[] params, IProgressMonitor monitor)
  {
    super(config, methodName, params);
    progressMonitor = monitor;
  }
  
  public IProgressMonitor getProgressMonitor()
  {
    return progressMonitor;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.trac.core.util.TracXmlRpcClientRequest
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.trac.core.util;

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;

public class TracHttpClientTransportFactory$TracHttpClientTransport
  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 TracHttpClientTransportFactory$TracHttpClientTransport(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)
    {
      TracHttpClientTransportFactory.TracHttpException e = new TracHttpClientTransportFactory.TracHttpException(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 TracXmlRpcClientRequest))
    {
      TracXmlRpcClientRequest tracRequest = (TracXmlRpcClientRequest)request;
      monitor = tracRequest.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 localSslCertificateException)
    {
      throw new TracHttpClientTransportFactory.TracHttpException(499);
    }
    catch (IOException e)
    {
      throw new XmlRpcException("I/O error while communicating with HTTP server: " + e.getMessage(), e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.trac.core.util.TracHttpClientTransportFactory.TracHttpClientTransport
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.trac.core.util;

import java.io.BufferedOutputStream;
import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcStreamTransport.ReqWriter;
import org.apache.xmlrpc.util.XmlRpcIOException;
import org.xml.sax.SAXException;

class TracHttpClientTransportFactory$TracHttpClientTransport$1
  implements RequestEntity
{
  TracHttpClientTransportFactory$TracHttpClientTransport$1(TracHttpClientTransportFactory.TracHttpClientTransport paramTracHttpClientTransport, XmlRpcStreamTransport.ReqWriter paramReqWriter) {}
  
  public long getContentLength()
  {
    return this$1.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 (TracHttpClientTransportFactory.TracHttpClientTransport.access$1(this$1, TracHttpClientTransportFactory.TracHttpClientTransport.access$0(this$1))) {
        ostream = new FilterOutputStream(pOut)
        {
          public void close()
            throws IOException
          {
            flush();
          }
        };
      } else {
        ostream = new BufferedOutputStream(pOut)
        {
          public void close()
            throws IOException
          {
            flush();
          }
        };
      }
      val$writer.write(ostream);
    }
    catch (XmlRpcException e)
    {
      throw new XmlRpcIOException(e);
    }
    catch (SAXException e)
    {
      throw new XmlRpcIOException(e);
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.trac.core.util.TracHttpClientTransportFactory.TracHttpClientTransport.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.trac.core.util;

import org.apache.commons.httpclient.HttpMethod;

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

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

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Date;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.mylyn.internal.trac.core.model.TracSearch;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.RepositoryStatus;

public class TracUtil
{
  public static Date parseDate(String time)
  {
    if (time != null) {
      try
      {
        return parseDate(Long.valueOf(time).longValue());
      }
      catch (NumberFormatException localNumberFormatException) {}
    }
    return null;
  }
  
  public static Date parseDate(long seconds)
  {
    return new Date(seconds * 1000L);
  }
  
  public static long toTracTime(Date date)
  {
    return date.getTime() / 1000L;
  }
  
  private static String getQueryParameter(IRepositoryQuery query)
  {
    String url = query.getUrl();
    int i = url.indexOf("/query?format=tab");
    if (i == -1) {
      return null;
    }
    return url.substring(i + "/query?format=tab".length());
  }
  
  public static TracSearch toTracSearch(IRepositoryQuery query)
  {
    String url = getQueryParameter(query);
    if (url != null)
    {
      TracSearch search = new TracSearch();
      search.fromUrl(url);
      return search;
    }
    return null;
  }
  
  public static IStatus createPermissionDeniedError(String repositoryUrl, String pluginId)
  {
    return new RepositoryStatus(repositoryUrl, 4, "org.eclipse.mylyn.trac.core", 
      12, Messages.TracUtil_Permission_denied);
  }
  
  public static String encodeUrl(String string)
  {
    try
    {
      return URLEncoder.encode(string, "UTF-8").replaceAll("\\+", "%20");
    }
    catch (UnsupportedEncodingException localUnsupportedEncodingException) {}
    return string;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.trac.core.util.TracUtil
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.trac.core.util;

import java.io.FilterOutputStream;
import java.io.IOException;
import java.io.OutputStream;

class TracHttpClientTransportFactory$TracHttpClientTransport$1$1
  extends FilterOutputStream
{
  TracHttpClientTransportFactory$TracHttpClientTransport$1$1(TracHttpClientTransportFactory.TracHttpClientTransport.1 param1, OutputStream $anonymous0)
  {
    super($anonymous0);
  }
  
  public void close()
    throws IOException
  {
    flush();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.trac.core.util.TracHttpClientTransportFactory.TracHttpClientTransport.1.1
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.trac.core.util;

import org.eclipse.osgi.util.NLS;

public class Messages
{
  private static final String BUNDLE_NAME = "org.eclipse.mylyn.internal.trac.core.util.messages";
  public static String TracUtil_Permission_denied;
  
  static {}
  
  public static void reloadMessages()
  {
    NLS.initializeMessages("org.eclipse.mylyn.internal.trac.core.util.messages", Messages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.trac.core.util.Messages
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.trac.core.util;

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

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

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.trac.core.util.TracHttpClientTransportFactory.TracHttpClientTransport.1.2
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.trac.core;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.mylyn.internal.trac.core.model.TracTicket.Key;

public enum TracAttribute
{
  CC(TracTicket.Key.CC, Messages.TracAttribute_CC, "task.common.user.cc", "shortText", TracAttributeMapper.Flag.PEOPLE, new TracAttributeMapper.Flag[0]),  CHANGE_TIME(TracTicket.Key.CHANGE_TIME, Messages.TracAttribute_Last_Modification, "task.common.date.modified", 
    "date", TracAttributeMapper.Flag.READ_ONLY, new TracAttributeMapper.Flag[0]),  COMPONENT(TracTicket.Key.COMPONENT, Messages.TracAttribute_Component, "task.common.product", "singleSelect", 
    TracAttributeMapper.Flag.ATTRIBUTE, new TracAttributeMapper.Flag[0]),  DESCRIPTION(TracTicket.Key.DESCRIPTION, Messages.TracAttribute_Description, "task.common.description", 
    "longRichText"),  ID(TracTicket.Key.ID, Messages.TracAttribute_ID, "task.common.key", "shortText", TracAttributeMapper.Flag.PEOPLE, new TracAttributeMapper.Flag[0]),  KEYWORDS(TracTicket.Key.KEYWORDS, Messages.TracAttribute_Keywords, "task.common.keywords", "shortText", 
    TracAttributeMapper.Flag.ATTRIBUTE, new TracAttributeMapper.Flag[0]),  MILESTONE(TracTicket.Key.MILESTONE, Messages.TracAttribute_Milestone, null, "singleSelect", TracAttributeMapper.Flag.ATTRIBUTE, new TracAttributeMapper.Flag[0]),  OWNER(TracTicket.Key.OWNER, Messages.TracAttribute_Assigned_to, "task.common.user.assigned", "person", 
    TracAttributeMapper.Flag.PEOPLE, new TracAttributeMapper.Flag[0]),  PRIORITY(TracTicket.Key.PRIORITY, Messages.TracAttribute_Priority, "task.common.priority", "singleSelect", 
    TracAttributeMapper.Flag.ATTRIBUTE, new TracAttributeMapper.Flag[0]),  REPORTER(TracTicket.Key.REPORTER, Messages.TracAttribute_Reporter, "task.common.user.reporter", "person", 
    TracAttributeMapper.Flag.READ_ONLY, new TracAttributeMapper.Flag[0]),  RESOLUTION(TracTicket.Key.RESOLUTION, Messages.TracAttribute_Resolution, "task.common.resolution", 
    "singleSelect"),  SEVERITY(TracTicket.Key.SEVERITY, Messages.TracAttribute_Severity, null, "singleSelect", TracAttributeMapper.Flag.ATTRIBUTE, new TracAttributeMapper.Flag[0]),  STATUS(TracTicket.Key.STATUS, Messages.TracAttribute_Status, "task.common.status", "shortText"),  SUMMARY(TracTicket.Key.SUMMARY, Messages.TracAttribute_Summary, "task.common.summary", "shortRichText"),  TIME(TracTicket.Key.TIME, Messages.TracAttribute_Created, "task.common.date.created", "date", TracAttributeMapper.Flag.READ_ONLY, new TracAttributeMapper.Flag[0]),  TYPE(TracTicket.Key.TYPE, Messages.TracAttribute_Type, "task.common.kind", "singleSelect", 
    TracAttributeMapper.Flag.ATTRIBUTE, new TracAttributeMapper.Flag[0]),  VERSION(TracTicket.Key.VERSION, Messages.TracAttribute_Version, null, "singleSelect", TracAttributeMapper.Flag.ATTRIBUTE, new TracAttributeMapper.Flag[0]),  TOKEN(TracTicket.Key.TOKEN, "Update Token", null, "shortText", TracAttributeMapper.Flag.READ_ONLY, new TracAttributeMapper.Flag[0]);
  
  static Map<String, TracAttribute> attributeByTracKey = new HashMap();
  static Map<String, String> tracKeyByTaskKey = new HashMap();
  private final String tracKey;
  private final String prettyName;
  private final String taskKey;
  private final String type;
  private EnumSet<TracAttributeMapper.Flag> flags;
  
  public static TracAttribute getByTaskKey(String taskKey)
  {
    TracAttribute[] arrayOfTracAttribute;
    int j = (arrayOfTracAttribute = values()).length;
    for (int i = 0; i < j; i++)
    {
      TracAttribute attribute = arrayOfTracAttribute[i];
      if (taskKey.equals(attribute.getTaskKey())) {
        return attribute;
      }
    }
    return null;
  }
  
  public static TracAttribute getByTracKey(String tracKey)
  {
    TracAttribute[] arrayOfTracAttribute;
    int j = (arrayOfTracAttribute = values()).length;
    for (int i = 0; i < j; i++)
    {
      TracAttribute attribute = arrayOfTracAttribute[i];
      if (tracKey.equals(attribute.getTracKey())) {
        return attribute;
      }
    }
    return null;
  }
  
  private TracAttribute(TracTicket.Key tracKey, String prettyName, String taskKey, String type, TracAttributeMapper.Flag firstFlag, TracAttributeMapper.Flag... moreFlags)
  {
    this.tracKey = tracKey.getKey();
    this.taskKey = taskKey;
    this.prettyName = prettyName;
    this.type = type;
    if (firstFlag == null) {
      flags = TracAttributeMapper.NO_FLAGS;
    } else {
      flags = EnumSet.of(firstFlag, moreFlags);
    }
  }
  
  private TracAttribute(TracTicket.Key tracKey, String prettyName, String taskKey, String type)
  {
    this(tracKey, prettyName, taskKey, type, null, new TracAttributeMapper.Flag[0]);
  }
  
  public String getTaskKey()
  {
    return taskKey;
  }
  
  public String getTracKey()
  {
    return tracKey;
  }
  
  public String getKind()
  {
    if (flags.contains(TracAttributeMapper.Flag.ATTRIBUTE)) {
      return "task.common.kind.default";
    }
    if (flags.contains(TracAttributeMapper.Flag.PEOPLE)) {
      return "task.common.kind.people";
    }
    return null;
  }
  
  public String getType()
  {
    return type;
  }
  
  public boolean isReadOnly()
  {
    return flags.contains(TracAttributeMapper.Flag.READ_ONLY);
  }
  
  public String toString()
  {
    return prettyName;
  }
}

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

import java.io.File;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.mylyn.commons.net.AbstractWebLocation;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient;
import org.eclipse.mylyn.internal.trac.core.client.ITracClient.Version;
import org.eclipse.mylyn.internal.trac.core.client.TracClientData;
import org.eclipse.mylyn.tasks.core.IRepositoryListener;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.TaskRepositoryLocationFactory;

public class TracClientManager
  implements IRepositoryListener
{
  private final Map<String, ITracClient> clientByUrl = new HashMap();
  private final Map<String, TracClientData> clientDataByUrl = new HashMap();
  private final File cacheFile;
  private volatile TaskRepositoryLocationFactory taskRepositoryLocationFactory;
  
  public TracClientManager(File cacheFile, TaskRepositoryLocationFactory taskRepositoryLocationFactory)
  {
    this.cacheFile = cacheFile;
    this.taskRepositoryLocationFactory = taskRepositoryLocationFactory;
    
    readCache();
  }
  
  public synchronized ITracClient getTracClient(TaskRepository taskRepository)
  {
    ITracClient repository = (ITracClient)clientByUrl.get(taskRepository.getRepositoryUrl());
    if (repository == null)
    {
      AbstractWebLocation location = taskRepositoryLocationFactory.createWebLocation(taskRepository);
      repository = TracClientFactory.createClient(location, ITracClient.Version.fromVersion(taskRepository.getVersion()));
      clientByUrl.put(taskRepository.getRepositoryUrl(), repository);
      
      TracClientData data = (TracClientData)clientDataByUrl.get(taskRepository.getRepositoryUrl());
      if (data == null)
      {
        data = new TracClientData();
        clientDataByUrl.put(taskRepository.getRepositoryUrl(), data);
      }
      repository.setData(data);
    }
    return repository;
  }
  
  public void repositoriesRead() {}
  
  public synchronized void repositoryAdded(TaskRepository repository)
  {
    removeClient(repository);
    clientDataByUrl.remove(repository.getRepositoryUrl());
  }
  
  public synchronized void clearClients()
  {
    clientByUrl.clear();
  }
  
  private synchronized void removeClient(TaskRepository repository)
  {
    clientByUrl.remove(repository.getRepositoryUrl());
  }
  
  public synchronized void repositoryRemoved(TaskRepository repository)
  {
    removeClient(repository);
    clientDataByUrl.remove(repository.getRepositoryUrl());
  }
  
  public synchronized void repositorySettingsChanged(TaskRepository repository)
  {
    removeClient(repository);
  }
  
  /* Error */
  public synchronized void readCache()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 178	org/eclipse/mylyn/internal/trac/core/TracClientManager:cacheFile	Ljava/io/File;
    //   4: ifnull +13 -> 17
    //   7: aload_0
    //   8: getfield 178	org/eclipse/mylyn/internal/trac/core/TracClientManager:cacheFile	Ljava/io/File;
    //   11: invokevirtual 182	java/io/File:exists	()Z
    //   14: ifne +4 -> 18
    //   17: return
    //   18: aconst_null
    //   19: astore_1
    //   20: new 89	java/io/ObjectInputStream
    //   23: dup
    //   24: new 86	java/io/FileInputStream
    //   27: dup
    //   28: aload_0
    //   29: getfield 178	org/eclipse/mylyn/internal/trac/core/TracClientManager:cacheFile	Ljava/io/File;
    //   32: invokespecial 183	java/io/FileInputStream:<init>	(Ljava/io/File;)V
    //   35: invokespecial 187	java/io/ObjectInputStream:<init>	(Ljava/io/InputStream;)V
    //   38: astore_1
    //   39: aload_1
    //   40: invokevirtual 185	java/io/ObjectInputStream:readInt	()I
    //   43: istore_2
    //   44: iconst_0
    //   45: istore_3
    //   46: goto +48 -> 94
    //   49: aload_1
    //   50: invokevirtual 188	java/io/ObjectInputStream:readObject	()Ljava/lang/Object;
    //   53: checkcast 92	java/lang/String
    //   56: astore 4
    //   58: aload_1
    //   59: invokevirtual 188	java/io/ObjectInputStream:readObject	()Ljava/lang/Object;
    //   62: checkcast 104	org/eclipse/mylyn/internal/trac/core/client/TracClientData
    //   65: astore 5
    //   67: aload 4
    //   69: ifnull +22 -> 91
    //   72: aload 5
    //   74: ifnull +17 -> 91
    //   77: aload_0
    //   78: getfield 180	org/eclipse/mylyn/internal/trac/core/TracClientManager:clientDataByUrl	Ljava/util/Map;
    //   81: aload 4
    //   83: aload 5
    //   85: invokeinterface 212 3 0
    //   90: pop
    //   91: iinc 3 1
    //   94: iload_3
    //   95: iload_2
    //   96: if_icmplt -47 -> 49
    //   99: goto +52 -> 151
    //   102: astore_2
    //   103: new 98	org/eclipse/core/runtime/Status
    //   106: dup
    //   107: iconst_2
    //   108: ldc 3
    //   110: ldc 1
    //   112: aload_2
    //   113: invokespecial 195	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   116: invokestatic 196	org/eclipse/mylyn/commons/core/StatusHandler:log	(Lorg/eclipse/core/runtime/IStatus;)V
    //   119: aload_1
    //   120: ifnull +43 -> 163
    //   123: aload_1
    //   124: invokevirtual 186	java/io/ObjectInputStream:close	()V
    //   127: goto +36 -> 163
    //   130: pop
    //   131: goto +32 -> 163
    //   134: astore 6
    //   136: aload_1
    //   137: ifnull +11 -> 148
    //   140: aload_1
    //   141: invokevirtual 186	java/io/ObjectInputStream:close	()V
    //   144: goto +4 -> 148
    //   147: pop
    //   148: aload 6
    //   150: athrow
    //   151: aload_1
    //   152: ifnull +11 -> 163
    //   155: aload_1
    //   156: invokevirtual 186	java/io/ObjectInputStream:close	()V
    //   159: goto +4 -> 163
    //   162: pop
    //   163: return
    // Line number table:
    //   Java source line #103	-> byte code offset #0
    //   Java source line #104	-> byte code offset #17
    //   Java source line #107	-> byte code offset #18
    //   Java source line #109	-> byte code offset #20
    //   Java source line #110	-> byte code offset #39
    //   Java source line #111	-> byte code offset #44
    //   Java source line #112	-> byte code offset #49
    //   Java source line #113	-> byte code offset #58
    //   Java source line #114	-> byte code offset #67
    //   Java source line #115	-> byte code offset #77
    //   Java source line #111	-> byte code offset #91
    //   Java source line #118	-> byte code offset #102
    //   Java source line #119	-> byte code offset #103
    //   Java source line #120	-> byte code offset #110
    //   Java source line #119	-> byte code offset #113
    //   Java source line #122	-> byte code offset #119
    //   Java source line #124	-> byte code offset #123
    //   Java source line #125	-> byte code offset #130
    //   Java source line #121	-> byte code offset #134
    //   Java source line #122	-> byte code offset #136
    //   Java source line #124	-> byte code offset #140
    //   Java source line #125	-> byte code offset #147
    //   Java source line #129	-> byte code offset #148
    //   Java source line #122	-> byte code offset #151
    //   Java source line #124	-> byte code offset #155
    //   Java source line #125	-> byte code offset #162
    //   Java source line #131	-> byte code offset #163
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	164	0	this	TracClientManager
    //   19	137	1	in	java.io.ObjectInputStream
    //   43	53	2	size	int
    //   102	11	2	e	Throwable
    //   45	50	3	i	int
    //   56	26	4	url	String
    //   65	19	5	data	TracClientData
    //   134	15	6	localObject	Object
    //   130	1	8	localIOException1	java.io.IOException
    //   147	1	9	localIOException2	java.io.IOException
    //   162	1	10	localIOException3	java.io.IOException
    // Exception table:
    //   from	to	target	type
    //   20	99	102	java/lang/Throwable
    //   123	127	130	java/io/IOException
    //   20	119	134	finally
    //   140	144	147	java/io/IOException
    //   155	159	162	java/io/IOException
  }
  
  /* Error */
  public synchronized void writeCache()
  {
    // Byte code:
    //   0: aload_0
    //   1: getfield 178	org/eclipse/mylyn/internal/trac/core/TracClientManager:cacheFile	Ljava/io/File;
    //   4: ifnonnull +4 -> 8
    //   7: return
    //   8: aconst_null
    //   9: astore_1
    //   10: new 90	java/io/ObjectOutputStream
    //   13: dup
    //   14: new 87	java/io/FileOutputStream
    //   17: dup
    //   18: aload_0
    //   19: getfield 178	org/eclipse/mylyn/internal/trac/core/TracClientManager:cacheFile	Ljava/io/File;
    //   22: invokespecial 184	java/io/FileOutputStream:<init>	(Ljava/io/File;)V
    //   25: invokespecial 191	java/io/ObjectOutputStream:<init>	(Ljava/io/OutputStream;)V
    //   28: astore_1
    //   29: aload_1
    //   30: aload_0
    //   31: getfield 180	org/eclipse/mylyn/internal/trac/core/TracClientManager:clientDataByUrl	Ljava/util/Map;
    //   34: invokeinterface 207 1 0
    //   39: invokevirtual 190	java/io/ObjectOutputStream:writeInt	(I)V
    //   42: aload_0
    //   43: getfield 180	org/eclipse/mylyn/internal/trac/core/TracClientManager:clientDataByUrl	Ljava/util/Map;
    //   46: invokeinterface 209 1 0
    //   51: invokeinterface 213 1 0
    //   56: astore_3
    //   57: goto +32 -> 89
    //   60: aload_3
    //   61: invokeinterface 206 1 0
    //   66: checkcast 92	java/lang/String
    //   69: astore_2
    //   70: aload_1
    //   71: aload_2
    //   72: invokevirtual 192	java/io/ObjectOutputStream:writeObject	(Ljava/lang/Object;)V
    //   75: aload_1
    //   76: aload_0
    //   77: getfield 180	org/eclipse/mylyn/internal/trac/core/TracClientManager:clientDataByUrl	Ljava/util/Map;
    //   80: aload_2
    //   81: invokeinterface 210 2 0
    //   86: invokevirtual 192	java/io/ObjectOutputStream:writeObject	(Ljava/lang/Object;)V
    //   89: aload_3
    //   90: invokeinterface
1 2 3 4 5 6 7 8 9 10

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