Fix for Bug 8890.
--- a/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/editor/NewsPage.java Tue Apr 14 13:14:38 2009 -0500
+++ b/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/editor/NewsPage.java Thu Apr 16 14:39:51 2009 -0500
@@ -557,7 +557,7 @@
private void handleMarkEntryRead(String feedTitle, String entryTitle) {
CarbideSyndFeed feed = newsFeeds.get(currentFeed);
if (feed != null) {
- CarbideNewsReaderPlugin.getFeedManager().removeNewsFeedEntry(feed.getEntries(), entryTitle);
+ CarbideNewsReaderPlugin.getFeedManager().markEntryAsRead(feed.getEntries(), entryTitle);
}
newsBrowser.setText(createNewsContents());
newsFeedsTableViewer.refresh();
--- a/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/FeedManager.java Tue Apr 14 13:14:38 2009 -0500
+++ b/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/FeedManager.java Thu Apr 16 14:39:51 2009 -0500
@@ -44,7 +44,6 @@
import com.sun.syndication.fetcher.FeedFetcher;
import com.sun.syndication.fetcher.impl.FeedFetcherCache;
import com.sun.syndication.fetcher.impl.HashMapFeedInfoCache;
-import com.sun.syndication.fetcher.impl.HttpURLFeedFetcher;
/**
* A class to manage feeds for the Carbide.c++ news reader.
@@ -191,11 +190,11 @@
}
/**
- * Remove an entry from a feed.
- * @param feed - feed object in question
- * @param entryTitle - title of the entry to be removed
+ * Search for a feed entry by name and then mark it as read.
+ * @param entries - feed entries to be checked
+ * @param entryTitle - title of the entry to be marked as read
*/
- public void removeNewsFeedEntry(List<CarbideSyndEntry> entries, String entryTitle) {
+ public void markEntryAsRead(List<CarbideSyndEntry> entries, String entryTitle) {
if (entries == null || entryTitle == null) {
return;
}
@@ -204,7 +203,7 @@
CarbideSyndEntry entry = iterator.next();
String title = entry.getTitle();
title = title.replaceAll("\n", "");
- if (title.equals(entryTitle)) {
+ if (title.equals(entryTitle) && !entry.isRead()) {
entry.setRead(true);
break;
}
--- a/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/gen/FeedInfo/FeedInfoManager.java Tue Apr 14 13:14:38 2009 -0500
+++ b/core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/gen/FeedInfo/FeedInfoManager.java Thu Apr 16 14:39:51 2009 -0500
@@ -114,13 +114,13 @@
if (pathStr != null) {
URL fileUrl = new URL(pathStr);
if (fileUrl != null) {
- HttpURLConnection httpConnection = null;
+ HttpURLConnection connection = null;
InputStream inputStream = null;
try {
- URLConnection connection = fileUrl.openConnection();
- httpConnection = (HttpURLConnection)connection;
- httpConnection.connect();
- int responseCode = httpConnection.getResponseCode();
+ connection = (HttpURLConnection) fileUrl.openConnection();
+ setRequestHeaders(connection);
+ connection.connect();
+ int responseCode = connection.getResponseCode();
handlesHttpErrorCode(responseCode);
inputStream = connection.getInputStream();
if (inputStream != null) {
@@ -138,8 +138,8 @@
} catch (Exception e) {
CarbideNewsReaderPlugin.log(e);
} finally {
- if (httpConnection != null) {
- httpConnection.disconnect();
+ if (connection != null) {
+ connection.disconnect();
}
if (inputStream != null) {
inputStream.close();
@@ -205,8 +205,17 @@
} else if (responseCode >= 400 && responseCode < 500) {
throw new Exception("The requested resource could not be found. HTTP Response code was:" + responseCode);
} else if (responseCode >= 500 && responseCode < 600) {
- throw new Exception("The server encounted an error. HTTP Response code was:" + responseCode);
+ throw new Exception("The server encountered an error. HTTP Response code was:" + responseCode);
}
}
+ /**
+ * Sets appropriate HTTP headers.
+ * @param connection - URL connection
+ */
+ private void setRequestHeaders(URLConnection connection) {
+ // specify acceptable content types
+ connection.setRequestProperty("Accept", "*/xml");
+ }
+
}