org.sakaiproject.component.legacy.news
Class BasicNewsService

java.lang.Object
  extended byorg.sakaiproject.component.legacy.news.BasicNewsService
All Implemented Interfaces:
NewsService

public class BasicNewsService
extends Object
implements NewsService

BasicNewsService ...

Version:
$Revision: 5825 $
Author:
University of Michigan, Sakai Software Development Team

Nested Class Summary
 class BasicNewsService.BasicNewsChannel
          NewsChannel implementation
 class BasicNewsService.BasicNewsItem
          NewsItem implementation
 
Field Summary
protected static int DEFAULT_EXPIRATION
           
protected  Logger m_logger
          Dependency: logging service
protected  MemoryService m_memoryService
          Dependency: MemoryService.
protected  Cache m_storage
           
 
Fields inherited from interface org.sakaiproject.service.legacy.news.NewsService
REFERENCE_ROOT, SERVICE_NAME
 
Constructor Summary
BasicNewsService()
           
 
Method Summary
 void destroy()
          Returns to uninitialized state.
 NewsChannel getChannel(String source)
          Retrieves a NewsChannel object indexed by a URL.
 List getChannels()
          Retrieves a list of URLs for NewsChannel objects currently indexed by the service.
 List getNewsitems(String source)
          Retrieves a list of items from an rss feed.
 List getNewsitems(String source, Filter filter)
          Retrieves a list of items from an rss feed.
protected  String getSafeHtml(String in)
           Permits safe tags but escapes other tags.
 void init()
          Final initialization, once all dependencies are set.
 boolean isUpdateAvailable(String source)
          Checks whether an update is available for the rss news feed.
 void removeChannel(String source)
          Removes a NewsChannel object from the service.
 void setLogger(Logger service)
          Dependency: logging service.
 void setMemoryService(MemoryService service)
          Dependency: MemoryService.
protected  void updateChannel(String source)
           Checks whether channel is cached.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EXPIRATION

protected static int DEFAULT_EXPIRATION

m_storage

protected Cache m_storage

m_logger

protected Logger m_logger
Dependency: logging service


m_memoryService

protected MemoryService m_memoryService
Dependency: MemoryService.

Constructor Detail

BasicNewsService

public BasicNewsService()
Method Detail

setLogger

public void setLogger(Logger service)
Dependency: logging service.

Parameters:
service - The logging service.

setMemoryService

public void setMemoryService(MemoryService service)
Dependency: MemoryService.

Parameters:
service - The MemoryService.

init

public void init()
Final initialization, once all dependencies are set.


destroy

public void destroy()
Returns to uninitialized state.


getSafeHtml

protected String getSafeHtml(String in)

Permits safe tags but escapes other tags.

Parameters:
in - The String to process.
Returns:
text that is safe to display in a browser window.

updateChannel

protected void updateChannel(String source)
                      throws NewsConnectionException,
                             NewsFormatException

Checks whether channel is cached. If not or if it's expired, retrieve the feed and update the cache

Parameters:
source - The url for the news feed
Throws:
NewsConnectionException, - for errors making the connection.
NewsFormatException, - for errors in the URL or errors parsing the feed.
NewsConnectionException
NewsFormatException

getNewsitems

public List getNewsitems(String source)
                  throws NewsConnectionException,
                         NewsFormatException
Retrieves a list of items from an rss feed.

Specified by:
getNewsitems in interface NewsService
Parameters:
source - The url for the feed.
Returns:
A list of NewsItem objects retrieved from the feed.
Throws:
NewsConnectionException, - for errors making the connection.
NewsFormatException, - for errors in the URL or errors parsing the feed.
NewsConnectionException
NewsFormatException

getNewsitems

public List getNewsitems(String source,
                         Filter filter)
                  throws NewsConnectionException,
                         NewsFormatException
Retrieves a list of items from an rss feed.

Specified by:
getNewsitems in interface NewsService
Parameters:
source - The url for the feed.
filter - A filtering object to accept NewsItems, or null if no filtering is desired.
Returns:
A list of NewsItem objects retrieved from the feed.
Throws:
NewsConnectionException, - for errors making the connection.
NewsFormatException, - for errors in the URL or errors parsing the feed.
NewsConnectionException
NewsFormatException

isUpdateAvailable

public boolean isUpdateAvailable(String source)
Checks whether an update is available for the rss news feed.

Specified by:
isUpdateAvailable in interface NewsService
Parameters:
source - The url for the feed.
Returns:
true if update is available, false otherwise
Throws:
NewsConnectionException, - for errors making the connection.
NewsFormatException, - for errors in the URL or errors parsing the feed.

getChannels

public List getChannels()
Retrieves a list of URLs for NewsChannel objects currently indexed by the service.

Specified by:
getChannels in interface NewsService
Returns:
A list of NewsChannel objects (possibly empty).

getChannel

public NewsChannel getChannel(String source)
                       throws NewsConnectionException,
                              NewsFormatException
Retrieves a NewsChannel object indexed by a URL.

Specified by:
getChannel in interface NewsService
Parameters:
source - The url for the channel.
Returns:
A NewsChannel object (possibly null).
Throws:
NewsConnectionException, - for errors making the connection.
NewsFormatException, - for errors in the URL or errors parsing the feed.
NewsConnectionException
NewsFormatException

removeChannel

public void removeChannel(String source)
Removes a NewsChannel object from the service.

Specified by:
removeChannel in interface NewsService
Parameters:
source - The url for the channel.
Returns:
A list of NewsChannel objects (possibly empty).