ColdBox Platform Version 2.6.3

coldbox.system.plugins
Class feedReader

WEB-INF.cftags.component
        extended by coldbox.system.frameworkSupertype
            extended by coldbox.system.plugin
                extended by coldbox.system.plugins.feedReader

public class feedReader
extends plugin

A rss reader plugin. We recommend that when you call the readFeed method, that you use url's as settings. ex: readFeed(getSetting('myFeedURL')). The settings this plugin uses are the following: feedReader_useCache:boolean [default=true], feedReader_cacheLocation:string, feedReader_cacheTimeout:numeric [default=30 min], feedReader_httpTimeout:numeric [default=30 sec]. If the cacheLocation directory does not exits, the plugin will throw an error. So please remember to create the directory.


Constructor Summary
init(any controller)
          Plugin Constructor.
 
Method Summary
private string URLToCacheKey(string feedURL)
          Convert a url to a cache key representation
 void expireCachedFeed(string feedURL)
          If the feed exists and it has expired, it removes it, else nothing.
private string findCreatedDate(xml xmlRoot)
          Parse the doc and find a created date
private string findUpdatedDate(xml xmlRoot)
          Parse the doc and find a updated date
 void flushCache()
          Flushes the entire file cache. Removes all entries
 numeric getCacheSize()
          Returns the number of elements in the cache directory. Only used for file caching.
 any getCachedFeed(string feedURL)
          Get the contents of a feed from the cache, if not found, it returns a blank structure. (This method does NOT timeout or expire the feeds, that is done by the readFeed method ONLY)
 string getcacheLocation()
          The cache location (absolute path)
 string getcachePrefix()
 numeric getcacheTimeout()
          The cache timeout in minutes
 string getcacheType()
 numeric gethttpTimeout()
          The http timeout in seconds
private string getlockName()
 boolean getuseCache()
          Whether using file cache or not.
 boolean isDateISO8601(string datetime)
          Checks if a date is in ISO8601 Format
 boolean isFeedCached(string feedURL)
          Checks if a feed is cached or not
 boolean isFeedExpired(string feedURL)
          Checks if a feed has expired or not. If the feed does not exist, it will throw an error.
private string normalizeAtomTextConstruct(any entity)
          Send an element and it will return the appropriate text construct.
private any parseAtomItems(any items, [string itemsType='query'], [numeric maxItems='0'])
          Parse the items an return an array of structures
 struct parseFeed(xml xmlDoc, [string itemsType='query'], [numeric maxItems='0'])
          This parses a feed as an xml doc and returns it as a structure of elements.
private any parseRSSItems(any items, [string itemsType='query'], [numeric maxItems='0'])
          Parse the items an return an array of structures
private query readCacheDir([string filter='*'])
          Read the cahe directory using a filter.
 struct readFeed(string feedURL, [string itemsType='query'], [numeric maxItems='0'])
          Read a feed from http if new or from local cache. Return a universal structure representation of the feed.
 boolean removeCachedFeed(string feedURL)
          Purges/removes a feed from the cache, returns false if not in the cache.
 struct retrieveFeed(string feedURL, [string itemsType='query'], [numeric maxItems='0'])
          This method does a cfhttp call on the feed url and returns a universal parsed feed structure. You can use this if you don't even want to use the caching facilities.
 void setCachedFeed(string feedURL, any feedStruct)
          Set a new feed contents into the feed cache.
 void setcacheLocation(string cacheLocation)
          The cache location (absolute path)
 void setcachePrefix(string cachePrefix)
 void setcacheTimeout(numeric cacheTimeout)
          Set the cache timeout in minutes
 void setcacheType(string cacheType)
 void sethttpTimeout(numeric httpTimeout)
          Set the http timeout in seconds
private void setlockName(string lockName)
 void setuseCache(boolean useCache)
          Set whether to use file caching or not
 
Methods inherited from class coldbox.system.plugin
getPluginDescription, getPluginName, getPluginVersion, getpluginPath, setPluginDescription, setPluginName, setPluginVersion
 
Methods inherited from class coldbox.system.frameworkSupertype
abort, announceInterception, dump, getColdboxOCM, getDatasource, getDebugMode, getHash, getInstance, getInterceptor, getMailSettings, getModel, getMyPlugin, getPlugin, getResource, getSetting, getSettingStructure, getSettingsBean, getcontroller, getfwLocale, htmlhead, include, includeUDF, locateDirectoryPath, locateFilePath, persistVariables, populateModel, relocate, renderExternalView, renderView, rethrowit, runEvent, setDebugMode, setNextEvent, setNextRoute, setSetting, setcontroller, settingExists, throw
 
Methods inherited from class WEB-INF.cftags.component
 

Constructor Detail

init

public init(any controller)

Method Detail

URLToCacheKey

private string URLToCacheKey(string feedURL)
Convert a url to a cache key representation

Parameters:
feedURL - The feed url to parse or retrieve from cache.

expireCachedFeed

public void expireCachedFeed(string feedURL)
If the feed exists and it has expired, it removes it, else nothing.

Parameters:
feedURL - The url to check if its in the cache.

findCreatedDate

private string findCreatedDate(xml xmlRoot)
Parse the doc and find a created date

Parameters:
xmlRoot - The xml root to look in

findUpdatedDate

private string findUpdatedDate(xml xmlRoot)
Parse the doc and find a updated date

Parameters:
xmlRoot - The xml root to look in

flushCache

public void flushCache()
Flushes the entire file cache. Removes all entries


getCacheSize

public numeric getCacheSize()
Returns the number of elements in the cache directory. Only used for file caching.


getCachedFeed

public any getCachedFeed(string feedURL)
Get the contents of a feed from the cache, if not found, it returns a blank structure. (This method does NOT timeout or expire the feeds, that is done by the readFeed method ONLY)

Parameters:
feedURL - The url to check if its in the cache.

getcacheLocation

public string getcacheLocation()
The cache location (absolute path)


getcachePrefix

public string getcachePrefix()


getcacheTimeout

public numeric getcacheTimeout()
The cache timeout in minutes


getcacheType

public string getcacheType()


gethttpTimeout

public numeric gethttpTimeout()
The http timeout in seconds


getlockName

private string getlockName()


getuseCache

public boolean getuseCache()
Whether using file cache or not.


isDateISO8601

public boolean isDateISO8601(string datetime)
Checks if a date is in ISO8601 Format

Parameters:
datetime - The datetime string to check

isFeedCached

public boolean isFeedCached(string feedURL)
Checks if a feed is cached or not

Parameters:
feedURL - The url to check if its in the cache.

isFeedExpired

public boolean isFeedExpired(string feedURL)
Checks if a feed has expired or not. If the feed does not exist, it will throw an error.

Parameters:
feedURL - The url to check if its in the cache.

normalizeAtomTextConstruct

private string normalizeAtomTextConstruct(any entity)
Send an element and it will return the appropriate text construct.

Parameters:
entity - The xml construct

parseAtomItems

private any parseAtomItems(any items, [string itemsType='query'], [numeric maxItems='0'])
Parse the items an return an array of structures

Parameters:
items - The xml of items
itemsType - The type of the items either query or Array. Query is by default.
maxItems - The max number of entries to retrieve, default is all

parseFeed

public struct parseFeed(xml xmlDoc, [string itemsType='query'], [numeric maxItems='0'])
This parses a feed as an xml doc and returns it as a structure of elements.

Parameters:
xmlDoc - The xmldoc to parse and normalize. Must be a coldfusion xml doc object not a string.
itemsType - The type of the items either query or Array. Query is by default.
maxItems - The max number of entries to retrieve, default is all

parseRSSItems

private any parseRSSItems(any items, [string itemsType='query'], [numeric maxItems='0'])
Parse the items an return an array of structures

Parameters:
items - The xml of items
itemsType - The type of the items either query or Array. Query is by default.
maxItems - The max number of entries to retrieve, default is all

readCacheDir

private query readCacheDir([string filter='*'])
Read the cahe directory using a filter.

Parameters:
filter - The file filter to use if sent, else * is default

readFeed

public struct readFeed(string feedURL, [string itemsType='query'], [numeric maxItems='0'])
Read a feed from http if new or from local cache. Return a universal structure representation of the feed.

Parameters:
feedURL - The feed url to parse or retrieve from cache.
itemsType - The type of the items either query or Array. Query is by default.
maxItems - The max number of entries to retrieve, default is all

removeCachedFeed

public boolean removeCachedFeed(string feedURL)
Purges/removes a feed from the cache, returns false if not in the cache.

Parameters:
feedURL - The url to purge from the cache.

retrieveFeed

public struct retrieveFeed(string feedURL, [string itemsType='query'], [numeric maxItems='0'])
This method does a cfhttp call on the feed url and returns a universal parsed feed structure. You can use this if you don't even want to use the caching facilities.

Parameters:
feedURL - The url to retrieve the feed from.
itemsType - The type of the items either query or Array. Query is by default.
maxItems - The max number of entries to retrieve, default is all

setCachedFeed

public void setCachedFeed(string feedURL, any feedStruct)
Set a new feed contents into the feed cache.

Parameters:
feedURL - The feed url to store in the cache.
feedStruct - The contents of the feed to cache

setcacheLocation

public void setcacheLocation(string cacheLocation)
The cache location (absolute path)

Parameters:
cacheLocation

setcachePrefix

public void setcachePrefix(string cachePrefix)

Parameters:
cachePrefix

setcacheTimeout

public void setcacheTimeout(numeric cacheTimeout)
Set the cache timeout in minutes

Parameters:
cacheTimeout

setcacheType

public void setcacheType(string cacheType)

Parameters:
cacheType

sethttpTimeout

public void sethttpTimeout(numeric httpTimeout)
Set the http timeout in seconds

Parameters:
httpTimeout

setlockName

private void setlockName(string lockName)

Parameters:
lockName

setuseCache

public void setuseCache(boolean useCache)
Set whether to use file caching or not

Parameters:
useCache

ColdBox Platform Version 2.6.3