org.eclipse.mylyn.commons.notifications.feed_0.9.1.v20120425-0100

16:46:25.965 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.commons.notifications.feed_0.9.1.v20120425-0100.jar
package org.eclipse.mylyn.commons.notifications.feed;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;

class ServiceMessageManager$1
  extends Job
{
  ServiceMessageManager$1(ServiceMessageManager paramServiceMessageManager, String $anonymous0)
  {
    super($anonymous0);
  }
  
  protected IStatus run(IProgressMonitor monitor)
  {
    try
    {
      this$0.refresh(monitor);
      return Status.OK_STATUS;
    }
    catch (Throwable localThrowable) {}
    return Status.CANCEL_STATUS;
  }
}

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

import java.util.ArrayList;
import java.util.Collections;
import java.util.EventObject;
import java.util.List;
import org.eclipse.mylyn.internal.commons.notifications.feed.ServiceMessage;

public class ServiceMessageEvent
  extends EventObject
{
  private static final long serialVersionUID = 1L;
  private final List<ServiceMessage> messages;
  private final Kind eventKind;
  
  public static enum Kind
  {
    MESSAGE_UPDATE,  STOP;
  }
  
  public ServiceMessageEvent(ServiceMessageManager manager, Kind kind)
  {
    this(manager, kind, new ArrayList());
  }
  
  public ServiceMessageEvent(ServiceMessageManager manager, Kind eventKind, List<ServiceMessage> messages)
  {
    super(manager);
    this.eventKind = eventKind;
    this.messages = Collections.unmodifiableList(new ArrayList(messages));
  }
  
  public List<ServiceMessage> getMessages()
  {
    return messages;
  }
  
  public Kind getEventKind()
  {
    return eventKind;
  }
}

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

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.notifications.core.NotificationEnvironment;
import org.eclipse.mylyn.internal.commons.notifications.feed.FeedReader;
import org.eclipse.mylyn.internal.commons.notifications.feed.ServiceMessage;

public class ServiceMessageManager
{
  private static final String ID_EVENT_SERVICE_MESSAGE = "org.eclipse.mylyn.notifications.feed.events.ServiceMessage";
  private static final long RECHECK_DELAY = 1209600000L;
  private static final long START_DELAY = 30000L;
  private final long checktime;
  private final NotificationEnvironment environment;
  private String eTag;
  private String eventId;
  private String lastModified;
  private final List<IServiceMessageListener> listeners = new CopyOnWriteArrayList();
  private Job messageCheckJob;
  private volatile List<? extends ServiceMessage> messages = Collections.emptyList();
  private boolean statusLogged;
  private String url;
  
  public ServiceMessageManager(String serviceMessageUrl, String lastModified, String eTag, long checktime)
  {
    this(serviceMessageUrl, lastModified, eTag, checktime, new NotificationEnvironment());
  }
  
  public ServiceMessageManager(String serviceMessageUrl, String lastModified, String eTag, long checktime, NotificationEnvironment environment)
  {
    url = serviceMessageUrl;
    this.lastModified = lastModified;
    this.checktime = checktime;
    this.eTag = eTag;
    this.environment = environment;
    eventId = "org.eclipse.mylyn.notifications.feed.events.ServiceMessage";
  }
  
  public void addServiceMessageListener(IServiceMessageListener listener)
  {
    listeners.add(listener);
  }
  
  public final String getEventId()
  {
    return eventId;
  }
  
  public List<ServiceMessage> getServiceMessages()
  {
    return new ArrayList(messages);
  }
  
  public String getUrl()
  {
    return url;
  }
  
  public void removeServiceMessageListener(IServiceMessageListener listener)
  {
    listeners.remove(listener);
  }
  
  public final void setEventId(String eventId)
  {
    Assert.isNotNull(eventId);
    this.eventId = eventId;
  }
  
  public void setUrl(String url)
  {
    this.url = url;
  }
  
  public void start()
  {
    if (messageCheckJob == null)
    {
      messageCheckJob = new Job("Checking for new service message")
      {
        protected IStatus run(IProgressMonitor monitor)
        {
          try
          {
            refresh(monitor);
            return Status.OK_STATUS;
          }
          catch (Throwable localThrowable) {}
          return Status.CANCEL_STATUS;
        }
      };
      messageCheckJob.setSystem(true);
      messageCheckJob.setPriority(50);
      messageCheckJob.addJobChangeListener(new JobChangeAdapter()
      {
        public void done(IJobChangeEvent event)
        {
          if (messageCheckJob != null) {
            messageCheckJob.schedule(1209600000L);
          }
        }
      });
    }
    if (checktime == 0L)
    {
      messageCheckJob.schedule(30000L);
    }
    else
    {
      long nextCheckTime = checktime + 1209600000L;
      long now = System.currentTimeMillis();
      if (nextCheckTime < now) {
        messageCheckJob.schedule(30000L);
      } else if (nextCheckTime > now) {
        if (nextCheckTime - now < 30000L) {
          messageCheckJob.schedule(30000L);
        } else {
          messageCheckJob.schedule(nextCheckTime - now);
        }
      }
    }
  }
  
  public void stop()
  {
    if (messageCheckJob != null)
    {
      messageCheckJob.cancel();
      messageCheckJob = null;
    }
    final ServiceMessageEvent event = new ServiceMessageEvent(this, ServiceMessageEvent.Kind.STOP);
    for (final IServiceMessageListener listener : listeners) {
      SafeRunner.run(new ISafeRunnable()
      {
        public void handleException(Throwable e)
        {
          StatusHandler.log(new Status(2, "org.eclipse.mylyn.commons.notifications.feed", "Listener failed: " + 
            listener.getClass(), e));
        }
        
        public void run()
          throws Exception
        {
          listener.handleEvent(event);
        }
      });
    }
  }
  
  /* Error */
  public int refresh(IProgressMonitor monitor)
  {
    // Byte code:
    //   0: iconst_m1
    //   1: istore_2
    //   2: aconst_null
    //   3: astore_3
    //   4: new 162	org/apache/commons/httpclient/HttpClient
    //   7: dup
    //   8: invokestatic 351	org/eclipse/mylyn/commons/net/WebUtil:getConnectionManager	()Lorg/apache/commons/httpclient/HttpConnectionManager;
    //   11: invokespecial 335	org/apache/commons/httpclient/HttpClient:<init>	(Lorg/apache/commons/httpclient/HttpConnectionManager;)V
    //   14: astore 4
    //   16: aload 4
    //   18: aconst_null
    //   19: invokestatic 352	org/eclipse/mylyn/commons/net/WebUtil:configureHttpClient	(Lorg/apache/commons/httpclient/HttpClient;Ljava/lang/String;)V
    //   22: new 171	org/eclipse/mylyn/commons/net/WebLocation
    //   25: dup
    //   26: aload_0
    //   27: getfield 319	org/eclipse/mylyn/commons/notifications/feed/ServiceMessageManager:url	Ljava/lang/String;
    //   30: invokespecial 350	org/eclipse/mylyn/commons/net/WebLocation:<init>	(Ljava/lang/String;)V
    //   33: astore 5
    //   35: aload 4
    //   37: aload 5
    //   39: new 169	org/eclipse/core/runtime/SubProgressMonitor
    //   42: dup
    //   43: aload_1
    //   44: iconst_1
    //   45: invokespecial 344	org/eclipse/core/runtime/SubProgressMonitor:<init>	(Lorg/eclipse/core/runtime/IProgressMonitor;I)V
    //   48: invokestatic 355	org/eclipse/mylyn/commons/net/WebUtil:createHostConfiguration	(Lorg/apache/commons/httpclient/HttpClient;Lorg/eclipse/mylyn/commons/net/AbstractWebLocation;Lorg/eclipse/core/runtime/IProgressMonitor;)Lorg/apache/commons/httpclient/HostConfiguration;
    //   51: astore 6
    //   53: new 164	org/apache/commons/httpclient/methods/GetMethod
    //   56: dup
    //   57: aload_0
    //   58: getfield 319	org/eclipse/mylyn/commons/notifications/feed/ServiceMessageManager:url	Ljava/lang/String;
    //   61: invokespecial 337	org/apache/commons/httpclient/methods/GetMethod:<init>	(Ljava/lang/String;)V
    //   64: astore 7
    //   66: aload 7
    //   68: ldc 3
    //   70: aload_0
    //   71: getfield 318	org/eclipse/mylyn/commons/notifications/feed/ServiceMessageManager:lastModified	Ljava/lang/String;
    //   74: invokevirtual 338	org/apache/commons/httpclient/methods/GetMethod:setRequestHeader	(Ljava/lang/String;Ljava/lang/String;)V
    //   77: aload 7
    //   79: ldc 4
    //   81: aload_0
    //   82: getfield 316	org/eclipse/mylyn/commons/notifications/feed/ServiceMessageManager:eTag	Ljava/lang/String;
    //   85: invokevirtual 338	org/apache/commons/httpclient/methods/GetMethod:setRequestHeader	(Ljava/lang/String;Ljava/lang/String;)V
    //   88: aload 4
    //   90: aload 6
    //   92: aload 7
    //   94: aload_1
    //   95: invokestatic 356	org/eclipse/mylyn/commons/net/WebUtil:execute	(Lorg/apache/commons/httpclient/HttpClient;Lorg/apache/commons/httpclient/HostConfiguration;Lorg/apache/commons/httpclient/HttpMethod;Lorg/eclipse/core/runtime/IProgressMonitor;)I
    //   98: istore_2
    //   99: iload_2
    //   100: sipush 200
    //   103: if_icmpne +95 -> 198
    //   106: aload_1
    //   107: invokeinterface 379 1 0
    //   112: ifne +86 -> 198
    //   115: aload 7
    //   117: ldc 5
    //   119: invokevirtual 339	org/apache/commons/httpclient/methods/GetMethod:getResponseHeader	(Ljava/lang/String;)Lorg/apache/commons/httpclient/Header;
    //   122: astore 8
    //   124: aload 8
    //   126: ifnull +12 -> 138
    //   129: aload_0
    //   130: aload 8
    //   132: invokevirtual 334	org/apache/commons/httpclient/Header:getValue	()Ljava/lang/String;
    //   135: putfield 318	org/eclipse/mylyn/commons/notifications/feed/ServiceMessageManager:lastModified	Ljava/lang/String;
    //   138: aload 7
    //   140: ldc 2
    //   142: invokevirtual 339	org/apache/commons/httpclient/methods/GetMethod:getResponseHeader	(Ljava/lang/String;)Lorg/apache/commons/httpclient/Header;
    //   145: astore 9
    //   147: aload 9
    //   149: ifnull +12 -> 161
    //   152: aload_0
    //   153: aload 9
    //   155: invokevirtual 334	org/apache/commons/httpclient/Header:getValue	()Ljava/lang/String;
    //   158: putfield 316	org/eclipse/mylyn/commons/notifications/feed/ServiceMessageManager:eTag	Ljava/lang/String;
    //   161: aload 7
    //   163: aload_1
    //   164: invokestatic 354	org/eclipse/mylyn/commons/net/WebUtil:getResponseBodyAsStream	(Lorg/apache/commons/httpclient/HttpMethodBase;Lorg/eclipse/core/runtime/IProgressMonitor;)Ljava/io/InputStream;
    //   167: astore 10
    //   169: aload_0
    //   170: aload 10
    //   172: aload_1
    //   173: invokespecial 362	org/eclipse/mylyn/commons/notifications/feed/ServiceMessageManager:readMessages	(Ljava/io/InputStream;Lorg/eclipse/core/runtime/IProgressMonitor;)Ljava/util/List;
    //   176: astore_3
    //   177: goto +13 -> 190
    //   180: astore 11
    //   182: aload 10
    //   184: invokevirtual 324	java/io/InputStream:close	()V
    //   187: aload 11
    //   189: athrow
    //   190: aload 10
    //   192: invokevirtual 324	java/io/InputStream:close	()V
    //   195: goto +66 -> 261
    //   198: iload_2
    //   199: sipush 404
    //   202: if_icmpeq +59 -> 261
    //   205: iload_2
    //   206: sipush 304
    //   209: if_icmpeq +52 -> 261
    //   212: aload_0
    //   213: new 168	org/eclipse/core/runtime/Status
    //   216: dup
    //   217: iconst_2
    //   218: ldc_w 149
    //   221: new 154	java/lang/StringBuilder
    //   224: dup
    //   225: ldc_w 148
    //   228: invokespecial 327	java/lang/StringBuilder:<init>	(Ljava/lang/String;)V
    //   231: iload_2
    //   232: invokestatic 336	org/apache/commons/httpclient/HttpStatus:getStatusText	(I)Ljava/lang/String;
    //   235: invokevirtual 328	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   238: invokevirtual 326	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   241: invokespecial 342	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;)V
    //   244: invokespecial 361	org/eclipse/mylyn/commons/notifications/feed/ServiceMessageManager:logStatus	(Lorg/eclipse/core/runtime/IStatus;)V
    //   247: goto +14 -> 261
    //   250: astore 12
    //   252: aload 7
    //   254: aload_1
    //   255: invokestatic 353	org/eclipse/mylyn/commons/net/WebUtil:releaseConnection	(Lorg/apache/commons/httpclient/HttpMethodBase;Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   258: aload 12
    //   260: athrow
    //   261: aload 7
    //   263: aload_1
    //   264: invokestatic 353	org/eclipse/mylyn/commons/net/WebUtil:releaseConnection	(Lorg/apache/commons/httpclient/HttpMethodBase;Lorg/eclipse/core/runtime/IProgressMonitor;)V
    //   267: goto +25 -> 292
    //   270: astore 4
    //   272: aload_0
    //   273: new 168	org/eclipse/core/runtime/Status
    //   276: dup
    //   277: iconst_2
    //   278: ldc_w 149
    //   281: ldc_w 147
    //   284: aload 4
    //   286: invokespecial 343	org/eclipse/core/runtime/Status:<init>	(ILjava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)V
    //   289: invokespecial 361	org/eclipse/mylyn/commons/notifications/feed/ServiceMessageManager:logStatus	(Lorg/eclipse/core/runtime/IStatus;)V
    //   292: aload_3
    //   293: ifnull +17 -> 310
    //   296: aload_3
    //   297: invokeinterface 375 1 0
    //   302: ifle +8 -> 310
    //   305: aload_0
    //   306: aload_3
    //   307: invokespecial 360	org/eclipse/mylyn/commons/notifications/feed/ServiceMessageManager:notifyListeners	(Ljava/util/List;)V
    //   310: iload_2
    //   311: ireturn
    // Line number table:
    //   Java source line #182	-> byte code offset #0
    //   Java source line #183	-> byte code offset #2
    //   Java source line #185	-> byte code offset #4
    //   Java source line #186	-> byte code offset #16
    //   Java source line #188	-> byte code offset #22
    //   Java source line #189	-> byte code offset #35
    //   Java source line #190	-> byte code offset #39
    //   Java source line #189	-> byte code offset #48
    //   Java source line #192	-> byte code offset #53
    //   Java source line #193	-> byte code offset #66
    //   Java source line #194	-> byte code offset #77
    //   Java source line #197	-> byte code offset #88
    //   Java source line #198	-> byte code offset #99
    //   Java source line #199	-> byte code offset #115
    //   Java source line #200	-> byte code offset #124
    //   Java source line #201	-> byte code offset #129
    //   Java source line #203	-> byte code offset #138
    //   Java source line #204	-> byte code offset #147
    //   Java source line #205	-> byte code offset #152
    //   Java source line #208	-> byte code offset #161
    //   Java source line #210	-> byte code offset #169
    //   Java source line #211	-> byte code offset #180
    //   Java source line #212	-> byte code offset #182
    //   Java source line #213	-> byte code offset #187
    //   Java source line #212	-> byte code offset #190
    //   Java source line #214	-> byte code offset #198
    //   Java source line #216	-> byte code offset #205
    //   Java source line #219	-> byte code offset #212
    //   Java source line #220	-> byte code offset #221
    //   Java source line #219	-> byte code offset #244
    //   Java source line #222	-> byte code offset #250
    //   Java source line #223	-> byte code offset #252
    //   Java source line #224	-> byte code offset #258
    //   Java source line #223	-> byte code offset #261
    //   Java source line #225	-> byte code offset #270
    //   Java source line #226	-> byte code offset #272
    //   Java source line #227	-> byte code offset #281
    //   Java source line #226	-> byte code offset #289
    //   Java source line #230	-> byte code offset #292
    //   Java source line #231	-> byte code offset #305
    //   Java source line #233	-> byte code offset #310
    // Local variable table:
    //   start	length	slot	name	signature
    //   0	312	0	this	ServiceMessageManager
    //   0	312	1	monitor	IProgressMonitor
    //   1	310	2	status	int
    //   3	304	3	messages	List<? extends ServiceMessage>
    //   14	75	4	httpClient	org.apache.commons.httpclient.HttpClient
    //   270	15	4	e	Exception
    //   33	5	5	location	org.eclipse.mylyn.commons.net.WebLocation
    //   51	40	6	hostConfiguration	org.apache.commons.httpclient.HostConfiguration
    //   64	198	7	method	org.apache.commons.httpclient.methods.GetMethod
    //   122	9	8	lastModifiedHeader	org.apache.commons.httpclient.Header
    //   145	9	9	eTagHeader	org.apache.commons.httpclient.Header
    //   167	24	10	in	InputStream
    //   180	8	11	localObject1	Object
    //   250	9	12	localObject2	Object
    // Exception table:
    //   from	to	target	type
    //   169	180	180	finally
    //   88	250	250	finally
    //   4	267	270	java/lang/Exception
  }
  
  private void logStatus(IStatus status)
  {
    if (!statusLogged) {
      statusLogged = true;
    }
  }
  
  private void notifyListeners(List<? extends ServiceMessage> messages)
  {
    this.messages = messages;
    for (ServiceMessage message : messages)
    {
      message.setETag(eTag);
      message.setLastModified(lastModified);
    }
    ArrayList<ServiceMessage> sortedMessages = new ArrayList(messages);
    Collections.sort(messages);
    final ServiceMessageEvent event = new ServiceMessageEvent(this, ServiceMessageEvent.Kind.MESSAGE_UPDATE, 
      sortedMessages);
    for (final IServiceMessageListener listener : listeners) {
      SafeRunner.run(new ISafeRunnable()
      {
        public void handleException(Throwable e)
        {
          StatusHandler.log(new Status(2, "org.eclipse.mylyn.commons.notifications.feed", "Listener failed: " + 
            listener.getClass(), e));
        }
        
        public void run()
          throws Exception
        {
          listener.handleEvent(event);
        }
      });
    }
  }
  
  private List<? extends ServiceMessage> readMessages(InputStream in, IProgressMonitor monitor)
    throws IOException
  {
    FeedReader reader = new FeedReader(eventId, environment);
    reader.parse(in, monitor);
    return reader.getEntries();
  }
}

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

import org.eclipse.core.runtime.jobs.IJobChangeEvent;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.jobs.JobChangeAdapter;

class ServiceMessageManager$2
  extends JobChangeAdapter
{
  ServiceMessageManager$2(ServiceMessageManager paramServiceMessageManager) {}
  
  public void done(IJobChangeEvent event)
  {
    if (ServiceMessageManager.access$0(this$0) != null) {
      ServiceMessageManager.access$0(this$0).schedule(1209600000L);
    }
  }
}

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

import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;

class ServiceMessageManager$3
  implements ISafeRunnable
{
  ServiceMessageManager$3(ServiceMessageManager paramServiceMessageManager, IServiceMessageListener paramIServiceMessageListener, ServiceMessageEvent paramServiceMessageEvent) {}
  
  public void handleException(Throwable e)
  {
    StatusHandler.log(new Status(2, "org.eclipse.mylyn.commons.notifications.feed", "Listener failed: " + 
      val$listener.getClass(), e));
  }
  
  public void run()
    throws Exception
  {
    val$listener.handleEvent(val$event);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.notifications.feed.ServiceMessageManager.3
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.notifications.feed;

public abstract interface IServiceMessageListener
{
  public abstract void handleEvent(ServiceMessageEvent paramServiceMessageEvent);
}

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

import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;

class ServiceMessageManager$4
  implements ISafeRunnable
{
  ServiceMessageManager$4(ServiceMessageManager paramServiceMessageManager, IServiceMessageListener paramIServiceMessageListener, ServiceMessageEvent paramServiceMessageEvent) {}
  
  public void handleException(Throwable e)
  {
    StatusHandler.log(new Status(2, "org.eclipse.mylyn.commons.notifications.feed", "Listener failed: " + 
      val$listener.getClass(), e));
  }
  
  public void run()
    throws Exception
  {
    val$listener.handleEvent(val$event);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.notifications.feed.ServiceMessageManager.4
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.notifications.feed;

public enum ServiceMessageEvent$Kind
{
  MESSAGE_UPDATE,  STOP;
}

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

import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.mylyn.commons.notifications.core.IFilterable;

class FeedReader$1
  implements IAdaptable
{
  FeedReader$1(FeedReader paramFeedReader, FeedEntry paramFeedEntry) {}
  
  public Object getAdapter(Class adapter)
  {
    if (adapter == IFilterable.class) {
      new IFilterable()
      {
        public List<String> getFilters(String key)
        {
          return val$entry.getFilters(key);
        }
        
        public String getFilter(String key)
        {
          return val$entry.getFilter(key);
        }
      };
    }
    if (adapter == FeedEntry.class) {
      return val$entry;
    }
    return null;
  }
}

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

public abstract interface INotificationsFeed
{
  public static final String ID_PLUGIN = "org.eclipse.mylyn.commons.notifications.feed";
}

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

import com.sun.syndication.feed.module.DCModule;
import com.sun.syndication.feed.module.DCSubject;
import com.sun.syndication.feed.synd.SyndContent;
import com.sun.syndication.feed.synd.SyndEntry;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.Assert;

public class FeedEntry
  extends ServiceMessage
{
  private final SyndEntry source;
  
  public FeedEntry(String eventId, SyndEntry source)
  {
    super(eventId);
    this.source = source;
    setId(source.getUri());
    setTitle(source.getTitle());
    if (source.getDescription() != null) {
      setDescription(source.getDescription().getValue());
    }
    setUrl(source.getLink());
    setImage("dialog_messasge_info_image");
    setDate(source.getPublishedDate());
  }
  
  public FeedEntry(String eventId)
  {
    super(eventId);
    source = null;
  }
  
  public SyndEntry getSource()
  {
    return source;
  }
  
  public List<String> getFilters(String key)
  {
    Assert.isNotNull(key);
    List<String> result = new ArrayList();
    DCModule module = (DCModule)source.getModule("http://purl.org/dc/elements/1.1/");
    if ((module != null) && (module.getSubjects() != null)) {
      for (Iterator<?> it = module.getSubjects().iterator(); it.hasNext();)
      {
        DCSubject category = (DCSubject)it.next();
        String value = parseFilter(key, category.getValue());
        if (value != null) {
          result.add(value);
        }
      }
    }
    return result;
  }
  
  public String getFilter(String key)
  {
    Assert.isNotNull(key);
    DCModule module = (DCModule)source.getModule("http://purl.org/dc/elements/1.1/");
    if ((module != null) && (module.getSubjects() != null)) {
      for (Iterator<?> it = module.getSubjects().iterator(); it.hasNext();)
      {
        DCSubject category = (DCSubject)it.next();
        String value = parseFilter(key, category.getValue());
        if (value != null) {
          return value;
        }
      }
    }
    return null;
  }
  
  private String parseFilter(String key, String category)
  {
    if (category != null)
    {
      int i = category.indexOf("=");
      if ((i != -1) && 
        (category.substring(0, i).trim().equals(key))) {
        return category.substring(i + 1).trim();
      }
    }
    return null;
  }
}

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

import com.sun.syndication.feed.synd.SyndEntry;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.notifications.core.IFilterable;
import org.eclipse.mylyn.commons.notifications.core.NotificationEnvironment;

public class FeedReader
{
  private final NotificationEnvironment environment;
  private final List<FeedEntry> entries;
  private final String eventId;
  
  public FeedReader(String eventId, NotificationEnvironment environment)
  {
    this.eventId = eventId;
    this.environment = environment;
    entries = new ArrayList();
  }
  
  public IStatus parse(InputStream in, IProgressMonitor monitor)
  {
    SyndFeedInput input = new SyndFeedInput();
    try
    {
      SyndFeed feed = input.build(new XmlReader(in));
      for (Iterator<?> it = feed.getEntries().iterator(); it.hasNext();)
      {
        SyndEntry syndEntry = (SyndEntry)it.next();
        final FeedEntry entry = createEntry(syndEntry);
        if (environment.matches(new IAdaptable()
        {
          public Object getAdapter(Class adapter)
          {
            if (adapter == IFilterable.class) {
              new IFilterable()
              {
                public List<String> getFilters(String key)
                {
                  return val$entry.getFilters(key);
                }
                
                public String getFilter(String key)
                {
                  return val$entry.getFilter(key);
                }
              };
            }
            if (adapter == FeedEntry.class) {
              return entry;
            }
            return null;
          }
        }, 
        
          monitor)) {
          entries.add(entry);
        }
      }
      return Status.OK_STATUS;
    }
    catch (Exception e)
    {
      return new Status(4, "org.eclipse.mylyn.commons.notifications.feed", 4, "Failed to parse RSS feed", e);
    }
  }
  
  protected FeedEntry createEntry(SyndEntry syndEntry)
  {
    return new FeedEntry(eventId, syndEntry);
  }
  
  public List<FeedEntry> getEntries()
  {
    return entries;
  }
}

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

import java.util.Date;
import org.eclipse.core.runtime.IAdapterManager;
import org.eclipse.core.runtime.Platform;
import org.eclipse.mylyn.commons.notifications.core.AbstractNotification;

public class ServiceMessage
  extends AbstractNotification
{
  private Date date;
  private String description;
  private String eTag;
  private String id;
  private String image;
  private String lastModified;
  private String title;
  private String url;
  
  public ServiceMessage(String eventId)
  {
    super(eventId);
  }
  
  public int compareTo(ServiceMessage o)
  {
    return -getId().compareTo(o.getId());
  }
  
  public Object getAdapter(Class adapter)
  {
    return Platform.getAdapterManager().getAdapter(this, adapter);
  }
  
  public Date getDate()
  {
    return date;
  }
  
  public String getDescription()
  {
    return description;
  }
  
  public String getETag()
  {
    return eTag;
  }
  
  public String getId()
  {
    return id;
  }
  
  public String getImage()
  {
    return image;
  }
  
  public String getLabel()
  {
    return getTitle();
  }
  
  public String getLastModified()
  {
    return lastModified;
  }
  
  public String getTitle()
  {
    return title;
  }
  
  public String getUrl()
  {
    return url;
  }
  
  public boolean isValid()
  {
    return (id != null) && (title != null) && (description != null) && (image != null);
  }
  
  public void setDate(Date date)
  {
    this.date = date;
  }
  
  public void setDescription(String description)
  {
    this.description = description;
  }
  
  public void setETag(String eTag)
  {
    this.eTag = eTag;
  }
  
  public void setId(String id)
  {
    this.id = id;
  }
  
  public void setImage(String image)
  {
    this.image = image;
  }
  
  public void setLastModified(String lastModified)
  {
    this.lastModified = lastModified;
  }
  
  public void setTitle(String title)
  {
    this.title = title;
  }
  
  public void setUrl(String url)
  {
    this.url = url;
  }
  
  public String toString()
  {
    StringBuilder builder = new StringBuilder();
    builder.append("ServiceMessage [id=");
    builder.append(id);
    builder.append(", title=");
    builder.append(title);
    builder.append(", description=");
    builder.append(description);
    builder.append(", url=");
    builder.append(url);
    builder.append(", image=");
    builder.append(image);
    builder.append(", eTag=");
    builder.append(eTag);
    builder.append(", lastModified=");
    builder.append(lastModified);
    builder.append(", date=");
    builder.append(date);
    builder.append("]");
    return builder.toString();
  }
}

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

import java.util.List;
import org.eclipse.mylyn.commons.notifications.core.IFilterable;

class FeedReader$1$1
  implements IFilterable
{
  FeedReader$1$1(FeedReader.1 param1, FeedEntry paramFeedEntry) {}
  
  public List<String> getFilters(String key)
  {
    return val$entry.getFilters(key);
  }
  
  public String getFilter(String key)
  {
    return val$entry.getFilter(key);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.notifications.feed.FeedReader.1.1
 * 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