[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[mylyn-dev] web connector
|
- From: Krzysztof Daniel <kdaniel@xxxxxxxxxx>
- Date: Wed, 06 Nov 2013 13:49:34 +0100
- Delivered-to: mylyn-dev@xxxxxxxxxxx
- Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAIAAADYYG7QAAAAA3NCSVQICAjb4U/gAAAHIklEQVRYw61YTWwbxxX+SC5FmVr9mCuzNF1KlFFT5GphG1VaJYHSGE4QA+LNhwrJQb32XLg5BT4YaBAkhdGjz0JTQD4YuYiHIjHk2khqIKnlYLUUKcCmvYFD0FqHspcEKS61PbzlcMU/kyIHxGJ3uDvzzffe+96bcVRKBnppVaPq4lx07eadhit7p93nzl7RNA9XNapGSTNKWsO/9nfsPR1WAoDrBgEbwj6WUdIeZ4prqze21ldZ51x8ZXnlz6d/E2z5STfN0cFk7RiuGtWHX9784vrHHcb9618+P7v8ATcstBytA9C2gJiXNLjLzrbawEq7RmydiYbsTDdQ3htDzW1nW726/HZPJri29u2ZaKjd8vpyaqOkra3eQI/t6vLbO9sqcUP0sJu+AFWN6mfXrnew1McfLdmNxa4A1lZvGCWty4m410oO3T/88mZLNHPxlfj4LsO0vjdJrzE0ALbWV3+clX77pw87ENMVIIamalQTKdkOYmt9tQZld31vkmGKj+/GP1oCrEfEVwhfIiWfa9LGozu13ZftlHTTGGf//Oo/rpmZltLasw+9un/P7hzre5PdA2LoH5W5fn2og7sAiIUiSTXd/FosFGnyd3z+r8Sr+/cQ/XAwgBIpeS6+ckXyQfgDAGgyAMyLsXkRPygAkmo6dv4ywgetv1fTRG2/Tm2X/Pj4roUGwLzIewPW/TsBAL/DxeYP9WLWxll6PSWfwx9fO11v2R7hg7Y0NLU66MPO1C+gQ+GQceIITZAAmIELA3Pq+uJs9JgeoVFCyhp1Osqa3WTQ5FgoolQwGIaaF9dgi3YQ2702UB/qpsIqay1NBgDq08EAEgO+7kGYHoF+dZLCBwAc2Y3Kd7dMI9+XD1WNauXmP5RKUAxFaNyWhrAbqzw2Qjeel4eAkmB6XhbKY3Bw! E0cEZBp5C JKoyUolKNbUhWGiuT0vC/Z7eiw8SBo1/QSgVILimxMsSE0jD044CiBaCv/ORdzeRsapZF84shvWis9f5kU/cUNohp8/1YtZ5b/5REqOj+9aOeQHhTCRpu8XIhjrw2QuzlUBdCVXyxjB2PnLSvYFgOTmLWxasIafawB0JZfc/MoBLM1eiAV8CB/w3gBBFAM+aM+SavrsW30XaLzo1+/eFgPS3+/IVyQAPkd2Y31vEpiMj+9Ck/ViPZPEQhGlEkyk5EQK8c0aSQgifICwGBtI2JeNCYqU+PhuUk0nN2+ZgQtLs5b4JtU02YIopPwfH9+9Ivko6UKQRhcWLZUXpKERV78Fmiv3tPAgCUDJvhADPmiypSuanFTTRInVz9q8yHsDZGjys8IvW4SJe/cNyzTDwhFTx77vFMJbAET4eNGvF0Xe6wegKxIzAS/6gYv63dsMjekReLFRpXjRXxpIcuW9Ad4baKFDggRAdD9r4IaBYApJAd+c/o6o1KUTU3b5OZQ47ZlhXmzQayaSFHH1xyNEmX3Pyw0LnuNz+i9bhMn0CDwAkWBJDQmVKROJpKOs0WJKJ6YGkFxpl1k1qvu+U+6haIsSzO7LGaeu5FokVxaqVkqx1HwQBVq7fM6qJU0mTC2n7IDjKOVHs4ToSg6CxIv+0okp0yOQIPGiv9235EPlsZEOzvR6QORMppHfL7TaM2iyruSGnz+1lKbm18Qi43K/UGX0dDZZp/MhwvE4Uww9USh//f5i9FCU2Uvs9sWJruTUafG0x6jsb7uHosRW1T/VW5QRFNqzKgDJf9kwPFy+RcFfq7UPyUENX3Lzlpl98Whh8bQnWkmnK4A7EnH1GvY/rv2bakV1uq4uj8pcjDtkLxIhmlgvZpFxWp3hA9ZJFf5M2GsCbkQAVNJp18xMz6ljdGFRtW3vayRNeLg87w3oyNHqY6GIfvdQBc2LfqLKIkyQxFp1ZZ4EarB6AzS6sMjOGET3s2Q2D! SzS4ipkoD DqFYUgNTsToeG9AT2cdQ9FTcA08sad793vvY/QRM9RFvrfTUd2w5HdoFTFdkJ1C2acVFFYtiOFrBVlDE1tuCkHN+H4+SWAyjdfdyj12zKkVIIIBAFA8KnT4igwE/Y+zhSZt5LJqPKqdfrr/9pyH0m8i3OV0tZpiXHne+7Spd4YIo8ZXVhklBCambDXVnJY0zdEO6Fhud08OUY6wr37hvu99weg1K/u33t1/x4dwT7OFFVTslKs6EfGaQ91ZixCQznfwU1Q/qGb4UuX3JHenZpOx+1nl4Ts7PIHAPQn2RGqdcJUwzsBp44c4ET4YOT4HNsV7ftOscN/ovxMNNQu5gG4rn5ytfVhyk+5Pd/JxsNGLXdq+tzxCfeT/PFjpa2hY/6hY/5fT43sPy9AkyFO8sFfufnpBjR0iJtIyTtabrpU+vmhfCIadHLennVoaVYaXVicCXvZRpPkG5aDS6EHCnkSlbD2mpDQkKV2tlU2YCIlL81Kn127/smnf2s56f8BT1i2ky/8xFYAAAAASUVORK5CYII=
- List-archive: <https://dev.eclipse.org/mailman/private/mylyn-dev>
- List-help: <mailto:mylyn-dev-request@eclipse.org?subject=help>
- List-subscribe: <https://dev.eclipse.org/mailman/listinfo/mylyn-dev>, <mailto:mylyn-dev-request@eclipse.org?subject=subscribe>
- List-unsubscribe: <https://dev.eclipse.org/mailman/options/mylyn-dev>, <mailto:mylyn-dev-request@eclipse.org?subject=unsubscribe>
- Organization: Red Hat
Hey Mylyn masters,
I wrote two more patches (attached, mostly for myself) to remove jdom
and rome from mylyn dependency tree. However, the problem appeared when
I tried to test mylyn web tasks as described in
http://alblue.bandlem.com/2009/04/google-code-and-mylyn-redux.html. The
point is that it looks like the webtasks connector doesn't work for
google code, even without my patches. It looks like a regular text
content is passed to the WebRepositoryConnector.performRssQuery(String,
IProgressMonitor, TaskDataCollector, TaskRepository), causing
!MESSAGE Failed to parse RSS feed: "Invalid XML: Error on line 1:
Content is not allowed in prolog." (despite showing proper preview).
That makes me wonder - is this web connector still working :> ? Are
there any users? Maybe it would be good to archive it?
--
Krzysztof Daniel <kdaniel@xxxxxxxxxx>
Red Hat
>From eda8bf9c0f993cb5a69461d75ef21e31f5906d92 Mon Sep 17 00:00:00 2001
From: Krzysztof Daniel <kdaniel@xxxxxxxxxx>
Date: Wed, 6 Nov 2013 10:51:12 +0100
Subject: [PATCH] remove jdom & rome
---
org.eclipse.mylyn.web.tasks/META-INF/MANIFEST.MF | 3 +-
.../internal/web/tasks/WebRepositoryConnector.java | 114 +++++++++++++--------
2 files changed, 70 insertions(+), 47 deletions(-)
diff --git a/org.eclipse.mylyn.web.tasks/META-INF/MANIFEST.MF b/org.eclipse.mylyn.web.tasks/META-INF/MANIFEST.MF
index 57642a3..dcf99a7 100644
--- a/org.eclipse.mylyn.web.tasks/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.web.tasks/META-INF/MANIFEST.MF
@@ -5,8 +5,7 @@ Bundle-SymbolicName: org.eclipse.mylyn.web.tasks;singleton:=true
Bundle-Version: 3.11.0.qualifier
Bundle-Activator: org.eclipse.mylyn.internal.web.tasks.TasksWebPlugin
Bundle-Vendor: %Bundle-Vendor
-Require-Bundle: com.sun.syndication;bundle-version="0.9.0",
- org.jdom;bundle-version="1.0.0",
+Require-Bundle:
org.eclipse.core.runtime,
org.eclipse.ui,
org.eclipse.ui.forms,
diff --git a/org.eclipse.mylyn.web.tasks/src/org/eclipse/mylyn/internal/web/tasks/WebRepositoryConnector.java b/org.eclipse.mylyn.web.tasks/src/org/eclipse/mylyn/internal/web/tasks/WebRepositoryConnector.java
index 16f0b49..6493637 100644
--- a/org.eclipse.mylyn.web.tasks/src/org/eclipse/mylyn/internal/web/tasks/WebRepositoryConnector.java
+++ b/org.eclipse.mylyn.web.tasks/src/org/eclipse/mylyn/internal/web/tasks/WebRepositoryConnector.java
@@ -19,13 +19,19 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
+import javax.xml.bind.Unmarshaller;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.stream.StreamSource;
+
import org.apache.commons.codec.EncoderException;
import org.apache.commons.codec.net.URLCodec;
import org.apache.commons.httpclient.Header;
@@ -45,6 +51,10 @@ import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.commons.net.WebLocation;
import org.eclipse.mylyn.commons.net.WebUtil;
+import org.eclipse.mylyn.internal.commons.core.rss.Atom;
+import org.eclipse.mylyn.internal.commons.core.rss.AtomItem;
+import org.eclipse.mylyn.internal.commons.core.rss.RSS;
+import org.eclipse.mylyn.internal.commons.core.rss.RSSItem;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryManager;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
@@ -58,12 +68,9 @@ import org.eclipse.mylyn.tasks.core.data.TaskMapper;
import org.eclipse.mylyn.tasks.core.sync.ISynchronizationSession;
import org.eclipse.mylyn.tasks.ui.TaskRepositoryLocationUiFactory;
import org.eclipse.mylyn.tasks.ui.TasksUi;
-
-import com.sun.syndication.feed.module.DCModule;
-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 org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.SAXParseException;
/**
* Generic connector for web based issue tracking systems
@@ -436,51 +443,68 @@ public class WebRepositoryConnector extends AbstractRepositoryConnector {
public static IStatus performRssQuery(String content, IProgressMonitor monitor, TaskDataCollector resultCollector,
TaskRepository repository) {
- SyndFeedInput input = new SyndFeedInput();
- try {
- SyndFeed feed = input.build(new XmlReader(new ByteArrayInputStream(content.getBytes())));
-
- SimpleDateFormat df = new SimpleDateFormat("yy-MM-dd HH:mm"); //$NON-NLS-1$
+ SimpleDateFormat df = new SimpleDateFormat("yy-MM-dd HH:mm"); //$NON-NLS-1$
- Iterator<?> it;
- for (it = feed.getEntries().iterator(); it.hasNext();) {
- SyndEntry entry = (SyndEntry) it.next();
-
- String author = entry.getAuthor();
- if (author == null) {
- DCModule module = (DCModule) entry.getModule("http://purl.org/dc/elements/1.1/"); //$NON-NLS-1$
- author = module.getCreator();
- }
+ try {
- Date date = entry.getUpdatedDate();
- if (date == null) {
- date = entry.getPublishedDate();
- }
- if (date == null) {
- DCModule module = (DCModule) entry.getModule("http://purl.org/dc/elements/1.1/"); //$NON-NLS-1$
- date = module.getDate();
+ DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ Document doc = builder.parse(new ByteArrayInputStream(content.getBytes("UTF-8")));
+ Element e = doc.getDocumentElement();
+ String localName = e.getLocalName();
+ if (localName == null) {
+ //probably not received xml
+ return Status.OK_STATUS;
+ }
+ boolean isAtom = localName.equals("feed") && e.getNamespaceURI().equals("http://www.w3.org/2005/Atom");
+ if (isAtom) {
+ JAXBContext jc = JAXBContext.newInstance(Atom.class);
+ Unmarshaller unmarshaller = jc.createUnmarshaller();
+ JAXBElement<Atom> atom = unmarshaller.unmarshal(
+ new StreamSource(new ByteArrayInputStream(content.getBytes())), Atom.class);
+
+ for (AtomItem atomItem : atom.getValue().getItems()) {
+ String author = atomItem.getAuthor();
+ Date date = AtomItem.getDate(atomItem.getUpdated());
+ String entryUri = atomItem.getLink();
+ String entrTitle = atomItem.getTitle();
+
+ TaskData data = createTaskData(repository, entryUri.replaceAll("-", "%2D")); //$NON-NLS-1$ //$NON-NLS-2$
+ TaskMapper schema = new TaskMapper(data, true);
+ schema.setSummary(((date == null ? "" : df.format(date) + " - ") + entrTitle)); //$NON-NLS-1$ //$NON-NLS-2$
+ schema.setCreationDate(date);
+ schema.setOwner(author);
+ schema.setTaskUrl(entryUri);
+ resultCollector.accept(data);
}
-
- String entryUri = entry.getLink();
- if (entryUri == null) {
- entryUri = entry.getUri();
+ } else {
+ JAXBContext jc = JAXBContext.newInstance(RSS.class);
+ Unmarshaller unmarshaller = jc.createUnmarshaller();
+ JAXBElement<RSS> rss = unmarshaller.unmarshal(
+ new StreamSource(new ByteArrayInputStream(content.getBytes())), RSS.class);
+
+ for (RSSItem rssItem : rss.getValue().getItems()) {
+
+ String author = rssItem.getAuthor();
+ Date date = RSSItem.getDate(rssItem.getPubDate());
+ String entryUri = rssItem.getLink();
+ String entrTitle = rssItem.getTitle();
+
+ TaskData data = createTaskData(repository, entryUri.replaceAll("-", "%2D")); //$NON-NLS-1$ //$NON-NLS-2$
+ TaskMapper schema = new TaskMapper(data, true);
+ schema.setSummary(((date == null ? "" : df.format(date) + " - ") + entrTitle)); //$NON-NLS-1$ //$NON-NLS-2$
+ schema.setCreationDate(date);
+ schema.setOwner(author);
+ schema.setTaskUrl(entryUri);
+ resultCollector.accept(data);
}
-
- String entrTitle = entry.getTitle();
-
- TaskData data = createTaskData(repository, entryUri.replaceAll("-", "%2D")); //$NON-NLS-1$ //$NON-NLS-2$
- TaskMapper schema = new TaskMapper(data, true);
- schema.setSummary(((date == null ? "" : df.format(date) + " - ") + entrTitle)); //$NON-NLS-1$ //$NON-NLS-2$
- schema.setCreationDate(date);
- schema.setOwner(author);
- schema.setTaskUrl(entryUri);
- resultCollector.accept(data);
}
return Status.OK_STATUS;
- } catch (Exception e) {
- String msg = e.getMessage() == null ? e.toString() : e.getMessage();
+ } catch (SAXParseException e) {
+ return Status.OK_STATUS;
+ } catch (Exception e1) {
+ String msg = e1.getMessage() == null ? e1.toString() : e1.getMessage();
return new Status(IStatus.ERROR, TasksWebPlugin.ID_PLUGIN, IStatus.ERROR, //
- Messages.WebRepositoryConnector_Failed_to_parse_RSS_feed + "\"" + msg + "\"", e); //$NON-NLS-1$ //$NON-NLS-2$
+ Messages.WebRepositoryConnector_Failed_to_parse_RSS_feed + "\"" + msg + "\"", e1); //$NON-NLS-1$ //$NON-NLS-2$
}
}
--
1.8.4.2
>From 3045658f2094f93a6c306d945a92d97d430d6b98 Mon Sep 17 00:00:00 2001
From: Krzysztof Daniel <kdaniel@xxxxxxxxxx>
Date: Wed, 6 Nov 2013 10:50:53 +0100
Subject: [PATCH] Refactor RSS handling.
---
.../META-INF/MANIFEST.MF | 3 +-
.../mylyn/internal/commons/core/rss/Atom.java | 40 ++++
.../mylyn/internal/commons/core/rss/AtomItem.java | 116 ++++++++++++
.../mylyn/internal/commons/core/rss/RSS.java | 42 +++++
.../mylyn/internal/commons/core/rss/RSSItem.java | 206 +++++++++++++++++++++
.../commons/notifications/feed/FeedEntry.java | 20 +-
.../commons/notifications/feed/FeedReader.java | 2 +
.../internal/commons/notifications/feed/RSS.java | 42 -----
.../commons/notifications/feed/RSSItem.java | 184 ------------------
9 files changed, 410 insertions(+), 245 deletions(-)
create mode 100644 org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/Atom.java
create mode 100644 org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/AtomItem.java
create mode 100644 org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/RSS.java
create mode 100644 org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/RSSItem.java
delete mode 100644 org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/RSS.java
delete mode 100644 org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/RSSItem.java
diff --git a/org.eclipse.mylyn.commons.core/META-INF/MANIFEST.MF b/org.eclipse.mylyn.commons.core/META-INF/MANIFEST.MF
index 4eae8eb..75c7ca8 100644
--- a/org.eclipse.mylyn.commons.core/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.commons.core/META-INF/MANIFEST.MF
@@ -11,7 +11,8 @@ Export-Package: org.eclipse.mylyn.commons.core,
org.eclipse.mylyn.commons.core.operations,
org.eclipse.mylyn.commons.core.storage;x-internal:=true,
org.eclipse.mylyn.internal.commons.core;x-internal:=true,
- org.eclipse.mylyn.internal.commons.core.operations;x-internal:=true
+ org.eclipse.mylyn.internal.commons.core.operations;x-internal:=true,
+ org.eclipse.mylyn.internal.commons.core.rss
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.net
Bundle-ClassPath: .
diff --git a/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/Atom.java b/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/Atom.java
new file mode 100644
index 0000000..e0348b5
--- /dev/null
+++ b/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/Atom.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.commons.core.rss;
+
+import java.util.ArrayList;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "feed")
+public class Atom {
+
+ private ArrayList<AtomItem> items;
+
+ /**
+ * @return the items
+ */
+ @XmlElement(name = "item")
+ public ArrayList<AtomItem> getItems() {
+ return items;
+ }
+
+ /**
+ * @param items
+ * the items to set
+ */
+ public void setItems(ArrayList<AtomItem> items) {
+ this.items = items;
+ }
+
+}
diff --git a/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/AtomItem.java b/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/AtomItem.java
new file mode 100644
index 0000000..9519d09
--- /dev/null
+++ b/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/AtomItem.java
@@ -0,0 +1,116 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.commons.core.rss;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.internal.commons.core.CommonsCorePlugin;
+
+public class AtomItem {
+
+ private String title;
+
+ private String updated;
+
+ private String author;
+
+ private String link;
+
+ /**
+ * @return the title
+ */
+ @XmlElement(name = "title")
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * @param title
+ * the title to set
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * @return the updated
+ */
+ @XmlElement(name = "updated")
+ public String getUpdated() {
+ return updated;
+ }
+
+ /**
+ * @param updated
+ * the updated to set
+ */
+ public void setUpdated(String updated) {
+ this.updated = updated;
+ }
+
+ /**
+ * @return the author
+ */
+ @XmlElementWrapper(name = "author")
+ @XmlElement(name = "name")
+ public String getAuthor() {
+ return author;
+ }
+
+ /**
+ * @param author
+ * the author to set
+ */
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ /**
+ * @return the link
+ */
+ public String getLink() {
+ return link;
+ }
+
+ /**
+ * @param link
+ * the link to set
+ */
+ @XmlElementWrapper(name = "link")
+ @XmlAttribute(name = "href")
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ public static final Date getDate(String date) {
+ if (date == null) {
+ return null;
+ }
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssz"); //$NON-NLS-1$
+ try {
+ return sdf.parse(date);
+ } catch (ParseException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, CommonsCorePlugin.ID_PLUGIN, "Processing a date \"" //$NON-NLS-1$
+ + date + "\" failed", e)); //$NON-NLS-1$
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/RSS.java b/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/RSS.java
new file mode 100644
index 0000000..7f17ab9
--- /dev/null
+++ b/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/RSS.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.commons.core.rss;
+
+import java.util.ArrayList;
+
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementWrapper;
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement(name = "rss")
+public class RSS {
+
+ private ArrayList<RSSItem> items;
+
+ /**
+ * @return the items
+ */
+ @XmlElementWrapper(name = "channel")
+ @XmlElement(name = "item")
+ public ArrayList<RSSItem> getItems() {
+ return items;
+ }
+
+ /**
+ * @param items
+ * the items to set
+ */
+ public void setItems(ArrayList<RSSItem> items) {
+ this.items = items;
+ }
+
+}
\ No newline at end of file
diff --git a/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/RSSItem.java b/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/RSSItem.java
new file mode 100644
index 0000000..d7bba42
--- /dev/null
+++ b/org.eclipse.mylyn.commons.core/src/org/eclipse/mylyn/internal/commons/core/rss/RSSItem.java
@@ -0,0 +1,206 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Red Hat, Inc and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.commons.core.rss;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlElement;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.internal.commons.core.CommonsCorePlugin;
+
+public class RSSItem {
+
+ private String title;
+
+ private String link;
+
+ private String pubDate;
+
+ private String author;
+
+ /**
+ * @return the author
+ */
+ @XmlElement(name = "author", namespace = "http://purl.org/dc/elements/1.1/")
+ public String getAuthor() {
+ return author;
+ }
+
+ /**
+ * @param author
+ * the author to set
+ */
+ public void setAuthor(String author) {
+ this.author = author;
+ }
+
+ private ArrayList<String> subjects;
+
+ private String description;
+
+ private ArrayList<String> categories;
+
+ private String guid;
+
+ /**
+ * @return the guid
+ */
+ @XmlElement(name = "guid")
+ public String getGuid() {
+ return guid;
+ }
+
+ /**
+ * @param guid
+ * the guid to set
+ */
+ public void setGuid(String guid) {
+ this.guid = guid;
+ }
+
+ /**
+ * @return the categories
+ */
+ @XmlElement(name = "category", nillable = true)
+ public List<String> getCategories() {
+ if (categories == null) {
+ synchronized (this) {
+ if (categories == null) {
+ categories = new ArrayList<String>(0);
+ }
+ }
+ }
+ return categories;
+ }
+
+ /**
+ * @param categories
+ * the categories to set
+ */
+ public void setCategories(ArrayList<String> categories) {
+ this.categories = categories;
+ }
+
+ /**
+ * @return the link
+ */
+ @XmlElement(name = "link")
+ public String getLink() {
+ return link;
+ }
+
+ /**
+ * @param link
+ * the link to set
+ */
+ public void setLink(String link) {
+ this.link = link;
+ }
+
+ /**
+ * @return the description
+ */
+ @XmlElement(name = "description")
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * @param description
+ * the description to set
+ */
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ /**
+ * @return the title
+ */
+ @XmlElement(name = "title")
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * @param title
+ * the title to set
+ */
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ /**
+ * @return the pubDate
+ */
+ @XmlElement(name = "pubDate")
+ public String getPubDate() {
+ return pubDate;
+ }
+
+ /**
+ * @param pubDate
+ * the pubDate to set
+ */
+ public void setPubDate(String pubDate) {
+ this.pubDate = pubDate;
+ }
+
+ /**
+ * @return the subject
+ */
+ @XmlElement(name = "subject", namespace = "http://purl.org/dc/elements/1.1/")
+ public List<String> getSubjects() {
+ if (subjects == null) {
+ synchronized (this) {
+ if (subjects == null) {
+ subjects = new ArrayList<String>(0);
+ }
+ }
+ }
+ return subjects;
+ }
+
+ /**
+ * @param subject
+ * the subject to set
+ */
+ public void setSubjects(ArrayList<String> subjects) {
+ this.subjects = subjects;
+ }
+
+ @Override
+ public String toString() {
+ return "RSSItem [title=" + title + ", link=" + link + ", pubDate=" + pubDate + ", guid=" + guid + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+
+ public static final Date getDate(String date) {
+ if (date == null) {
+ return null;
+ }
+ SimpleDateFormat sdf = new SimpleDateFormat("E, dd MMM yyyy hh:mm:ss ZZZZ"); //$NON-NLS-1$
+ try {
+ return sdf.parse(date);
+ } catch (ParseException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, CommonsCorePlugin.ID_PLUGIN, "Processing a date \"" //$NON-NLS-1$
+ + date + "\" failed", e)); //$NON-NLS-1$
+ }
+ return null;
+ }
+
+}
diff --git a/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/FeedEntry.java b/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/FeedEntry.java
index a902356..2b10809 100644
--- a/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/FeedEntry.java
+++ b/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/FeedEntry.java
@@ -12,16 +12,11 @@
package org.eclipse.mylyn.internal.commons.notifications.feed;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Date;
import java.util.List;
import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.internal.commons.core.rss.RSSItem;
/**
* @author Steffen Pingel
@@ -40,18 +35,7 @@ public class FeedEntry extends ServiceMessage {
}
setUrl(source.getLink());
setImage("dialog_messasge_info_image"); //$NON-NLS-1$
- setDate(getDate(source));
- }
-
- private Date getDate(RSSItem source) {
- SimpleDateFormat sdf = new SimpleDateFormat("E, dd MMM yyyy hh:mm:ss ZZZZ"); //$NON-NLS-1$
- try {
- return sdf.parse(source.getPubDate());
- } catch (ParseException e) {
- StatusHandler.log(new Status(IStatus.ERROR, INotificationsFeed.ID_PLUGIN, "Processing pub date of \"" //$NON-NLS-1$
- + source + "\" failed", e)); //$NON-NLS-1$
- }
- return null;
+ setDate(RSSItem.getDate(source.getPubDate()));
}
public FeedEntry(String eventId) {
diff --git a/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/FeedReader.java b/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/FeedReader.java
index 469677e..3dc4655 100644
--- a/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/FeedReader.java
+++ b/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/FeedReader.java
@@ -28,6 +28,8 @@ 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;
+import org.eclipse.mylyn.internal.commons.core.rss.RSS;
+import org.eclipse.mylyn.internal.commons.core.rss.RSSItem;
/**
* @author Steffen Pingel
diff --git a/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/RSS.java b/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/RSS.java
deleted file mode 100644
index 0be36d1..0000000
--- a/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/RSS.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 Red Hat, Inc and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.commons.notifications.feed;
-
-import java.util.ArrayList;
-
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.bind.annotation.XmlElementWrapper;
-import javax.xml.bind.annotation.XmlRootElement;
-
-@XmlRootElement(name = "rss")
-public class RSS {
-
- private ArrayList<RSSItem> items;
-
- /**
- * @return the items
- */
- @XmlElementWrapper(name = "channel")
- @XmlElement(name = "item")
- public ArrayList<RSSItem> getItems() {
- return items;
- }
-
- /**
- * @param items
- * the items to set
- */
- public void setItems(ArrayList<RSSItem> items) {
- this.items = items;
- }
-
-}
\ No newline at end of file
diff --git a/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/RSSItem.java b/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/RSSItem.java
deleted file mode 100644
index 6b5737e..0000000
--- a/org.eclipse.mylyn.commons.notifications.feed/src/org/eclipse/mylyn/internal/commons/notifications/feed/RSSItem.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 Red Hat, Inc and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.internal.commons.notifications.feed;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.xml.bind.annotation.XmlElement;
-
-public class RSSItem {
-
- private String title;
-
- private String link;
-
- private String pubDate;
-
- private String creator;
-
- private ArrayList<String> subjects;
-
- private String description;
-
- private ArrayList<String> categories;
-
- private String guid;
-
- /**
- * @return the guid
- */
- @XmlElement(name = "guid")
- public String getGuid() {
- return guid;
- }
-
- /**
- * @param guid
- * the guid to set
- */
- public void setGuid(String guid) {
- this.guid = guid;
- }
-
- /**
- * @return the categories
- */
- @XmlElement(name = "category", nillable = true)
- public List<String> getCategories() {
- if (categories == null) {
- synchronized (this) {
- if (categories == null) {
- categories = new ArrayList<String>(0);
- }
- }
- }
- return categories;
- }
-
- /**
- * @param categories
- * the categories to set
- */
- public void setCategories(ArrayList<String> categories) {
- this.categories = categories;
- }
-
- /**
- * @return the link
- */
- @XmlElement(name = "link")
- public String getLink() {
- return link;
- }
-
- /**
- * @param link
- * the link to set
- */
- public void setLink(String link) {
- this.link = link;
- }
-
- /**
- * @return the description
- */
- @XmlElement(name = "description")
- public String getDescription() {
- return description;
- }
-
- /**
- * @param description
- * the description to set
- */
- public void setDescription(String description) {
- this.description = description;
- }
-
- /**
- * @return the title
- */
- @XmlElement(name = "title")
- public String getTitle() {
- return title;
- }
-
- /**
- * @param title
- * the title to set
- */
- public void setTitle(String title) {
- this.title = title;
- }
-
- /**
- * @return the pubDate
- */
- @XmlElement(name = "pubDate")
- public String getPubDate() {
- return pubDate;
- }
-
- /**
- * @param pubDate
- * the pubDate to set
- */
- public void setPubDate(String pubDate) {
- this.pubDate = pubDate;
- }
-
- /**
- * @return the creator
- */
- @XmlElement(name = "creator", namespace = "http://purl.org/dc/elements/1.1/")
- public String getCreator() {
- return creator;
- }
-
- /**
- * @param creator
- * the creator to set
- */
- public void setCreator(String creator) {
- this.creator = creator;
- }
-
- /**
- * @return the subject
- */
- @XmlElement(name = "subject", namespace = "http://purl.org/dc/elements/1.1/")
- public List<String> getSubjects() {
- if (subjects == null) {
- synchronized (this) {
- if (subjects == null) {
- subjects = new ArrayList<String>(0);
- }
- }
- }
- return subjects;
- }
-
- /**
- * @param subject
- * the subject to set
- */
- public void setSubjects(ArrayList<String> subjects) {
- this.subjects = subjects;
- }
-
- @Override
- public String toString() {
- return "RSSItem [title=" + title + ", link=" + link + ", pubDate=" + pubDate + ", guid=" + guid + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
-
-}
--
1.8.4.2