org.jasig.portlet.dining.dao
Class ScreenScrapingDiningMenuDaoImpl

java.lang.Object
  extended by org.jasig.portlet.dining.dao.ScreenScrapingDiningMenuDaoImpl
All Implemented Interfaces:
IDiningMenuDao

public class ScreenScrapingDiningMenuDaoImpl
extends Object
implements IDiningMenuDao

Dining menu DAO capable of collecting menu information vi screen scraping HTML content. This implementation should only be used if no more structured content can be made available.

Version:
$Revision: 25324 $
Author:
Jen Bourey, jennifer.bourey@gmail.com

Field Summary
protected  org.apache.commons.logging.Log log
           
 
Constructor Summary
ScreenScrapingDiningMenuDaoImpl()
           
 
Method Summary
protected  String getCleanedHtmlContent(String html)
          Get clean, valid HTML for the supplied HTML markup.
 List<String> getDiningHalls(javax.portlet.PortletRequest request)
          Get the list of dining halls for a given portlet request.
protected  String getHtmlContent(String diningHall)
          Get HTML content for the specified dining hall.
 DiningHall getMenu(javax.portlet.PortletRequest request, String diningHall)
          Get the menu for the specified dining hall.
protected  Menu getMenu(String xml)
          Deserialize a menu from the provided XML.
protected  String getXml(String cleanHtml)
          Get portlet-specific XML for clean, valid HTML.
 void setCache(net.sf.ehcache.Cache cache)
           
 void setDiningHalls(List<String> diningHalls)
          Set the list of dining hall names.
 void setPolicy(org.springframework.core.io.Resource config)
          Set the AntiSamy policy to be used to clean and validate HTML content.
 void setXslt(org.springframework.core.io.Resource xslt)
          Set the XSLT to use when transforming clean, valid HTML to portlet-specific XML.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected final org.apache.commons.logging.Log log
Constructor Detail

ScreenScrapingDiningMenuDaoImpl

public ScreenScrapingDiningMenuDaoImpl()
Method Detail

setCache

public void setCache(net.sf.ehcache.Cache cache)

setXslt

public void setXslt(org.springframework.core.io.Resource xslt)
Set the XSLT to use when transforming clean, valid HTML to portlet-specific XML.

Parameters:
xslt -

setPolicy

public void setPolicy(org.springframework.core.io.Resource config)
               throws org.owasp.validator.html.PolicyException,
                      IOException
Set the AntiSamy policy to be used to clean and validate HTML content.

Parameters:
config -
Throws:
org.owasp.validator.html.PolicyException
IOException

setDiningHalls

public void setDiningHalls(List<String> diningHalls)
Set the list of dining hall names.

Parameters:
diningHalls -

getDiningHalls

public List<String> getDiningHalls(javax.portlet.PortletRequest request)
Description copied from interface: IDiningMenuDao
Get the list of dining halls for a given portlet request.

Specified by:
getDiningHalls in interface IDiningMenuDao
Returns:

getMenu

public DiningHall getMenu(javax.portlet.PortletRequest request,
                          String diningHall)
Description copied from interface: IDiningMenuDao
Get the menu for the specified dining hall.

Specified by:
getMenu in interface IDiningMenuDao
Returns:

getHtmlContent

protected String getHtmlContent(String diningHall)
                         throws org.apache.http.client.ClientProtocolException,
                                IOException
Get HTML content for the specified dining hall.

Parameters:
diningHall -
Returns:
Throws:
org.apache.http.client.ClientProtocolException
IOException

getCleanedHtmlContent

protected String getCleanedHtmlContent(String html)
                                throws org.owasp.validator.html.ScanException,
                                       org.owasp.validator.html.PolicyException
Get clean, valid HTML for the supplied HTML markup.

Parameters:
html -
Returns:
Throws:
org.owasp.validator.html.ScanException
org.owasp.validator.html.PolicyException

getXml

protected String getXml(String cleanHtml)
                 throws TransformerException,
                        IOException
Get portlet-specific XML for clean, valid HTML.

Parameters:
cleanHtml -
Returns:
Throws:
TransformerException
IOException

getMenu

protected Menu getMenu(String xml)
                throws JAXBException
Deserialize a menu from the provided XML.

Parameters:
xml -
Returns:
Throws:
JAXBException


Copyright © 2011 Jasig. All Rights Reserved.