ColdBox Platform v3.8.0

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 feed reader plug-in that processes Atom, RDF and RSS formats. The recommended method for general usage is readFeed().

Constructor Summary
init(any controller)
          Plug-in constructor
 
Method Summary
private string URLToCacheKey(string feedURL)
          Convert a url to a cache key representation
package string createUserAgent()
          Creates a ColdBox user agent used in HTTP requests
package string downloadFeed(string feedURL)
 void expireCachedFeed(string feedURL)
          If the feed exists and it has expired, it removes it other it does nothing
 void flushCache()
          Flushes the entire file cache by removing all the entries
 numeric getCacheSize()
          Returns the number of elements in the cache directory (only used for file caching)
 any getCachedFeed(string feedURL)
          Get the feed content from the cache, if missing a blank structure is returned
 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 isFeedCached(string feedURL)
          Checks if a feed is cached or not
 boolean isFeedExpired(string feedURL)
          Checks if a feed has expired or not
 struct parseFeed(xml xmlDoc, [string itemsType='array'], [numeric maxItems='0'])
          This parses a feed as a XML document and returns the results as a structure of elements
private query readCacheDir([string filter='*'])
          Read the cache directory using a filter
 struct readFeed(string feedURL, [string itemsType='array'], [numeric maxItems='0'])
          Read a feed sourced from HTTP or from cache
 boolean removeCachedFeed(string feedURL)
          Purges a feed from the cache, returns false if feed is not found
 struct retrieveFeed(string feedURL, [string itemsType='array'], [numeric maxItems='0'])
          This method does a cfhttp call on the feed url and returns a universal parsed feed structure
 void setCachedFeed(string feedURL, any feedStruct)
          Copy feed content into the 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, getRequestCollection, getRequestContext, getpluginAuthor, getpluginAuthorURL, getpluginPath, setPluginDescription, setPluginName, setPluginVersion, setpluginAuthor, setpluginAuthorURL
 
Methods inherited from class coldbox.system.FrameworkSupertype
$abort, $dump, $htmlhead, $include, $rethrow, $throw, addAsset, announceInterception, getColdboxOCM, getController, getDatasource, getDebugMode, getInterceptor, getMailService, getMailSettings, getMemento, getModel, getModuleSettings, getMyPlugin, getNewMail, getPlugin, getResource, getSetting, getSettingStructure, getSettingsBean, getValidationManager, getfwLocale, includeUDF, loadGlobalUDFLibraries, locateDirectoryPath, locateFilePath, persistVariables, populateModel, relocate, renderExternalView, renderLayout, renderView, runEvent, setDebugMode, setNextEvent, setNextRoute, setSetting, setfwLocale, settingExists, validateModel
 
Methods inherited from class WEB-INF.cftags.component
None
 

Constructor Detail

init

public init(any controller)
Plug-in constructor

Parameters:
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

createUserAgent

package string createUserAgent()
Creates a ColdBox user agent used in HTTP requests


downloadFeed

package string downloadFeed(string feedURL)

Parameters:
feedURL - The url to retrieve the feed from.

expireCachedFeed

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

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

flushCache

public void flushCache()
Flushes the entire file cache by removing all the 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 feed content from the cache, if missing a blank structure is returned. This method does NOT timeout or expire the feeds that is only done by the readFeed method.

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


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 an error will be thrown.

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

parseFeed

public struct parseFeed(xml xmlDoc, [string itemsType='array'], [numeric maxItems='0'])
This parses a feed as a XML document and returns the results as a structure of elements

Parameters:
xmlDoc - The XML document (saved as a ColdFusion object) to parse and normalize
itemsType - The type of the items either query or array, array is used by default
maxItems - The maximum number of entries to retrieve, default is display all

readCacheDir

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

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

readFeed

public struct readFeed(string feedURL, [string itemsType='array'], [numeric maxItems='0'])
Read a feed sourced from HTTP or from 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, array is used by default
maxItems - The maximum number of entries to retrieve, default is display all

removeCachedFeed

public boolean removeCachedFeed(string feedURL)
Purges a feed from the cache, returns false if feed is not found

Parameters:
feedURL - The url to purge from the cache

retrieveFeed

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

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

setCachedFeed

public void setCachedFeed(string feedURL, any feedStruct)
Copy feed content into the cache

Parameters:
feedURL - The feed url to store in the cache
feedStruct - The content 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 v3.8.0