# HG changeset patch # User stechong # Date 1239910791 18000 # Node ID 3604ec4c983e6b2ae7a2cfc9400f28e75fdf637d # Parent 4f14af134d0e1568ee5492cfe1ea5c907f7ce9d1 Fix for Bug 8890. diff -r 4f14af134d0e -r 3604ec4c983e core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/editor/NewsPage.java --- 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(); diff -r 4f14af134d0e -r 3604ec4c983e core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/feed/FeedManager.java --- 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 entries, String entryTitle) { + public void markEntryAsRead(List 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; } diff -r 4f14af134d0e -r 3604ec4c983e core/com.nokia.carbide.cpp.news.reader/src/com/nokia/carbide/cpp/internal/news/reader/gen/FeedInfo/FeedInfoManager.java --- 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"); + } + }