org.jasig.portlet.calendar.adapter
Class ConfigurableHttpCalendarAdapter
java.lang.Object
org.jasig.portlet.calendar.adapter.ConfigurableHttpCalendarAdapter
- All Implemented Interfaces:
- ICalendarAdapter, ISingleEventSupport
public final class ConfigurableHttpCalendarAdapter
- extends Object
- implements ICalendarAdapter, ISingleEventSupport
Implementation of ICalendarAdapter that uses Commons HttpClient
for retrieving CalendarEvents.
This bean requires an EhCache Cache be provided.
This bean also depends on instances of 3 different interfaces
(default implementation listed in parenthesis):
By specifying alternate implementations for these interfaces, multiple instances of
this class can be configured to consume CalendarEvents from a variety of different
end points, for example an RSS feed behind basic auth, a CalendarKey implementation behind
a shared secret, or behind CAS.
- Version:
- $Header: RefactoredHttpICalendarAdapter.java Exp $
- Author:
- Nicholas Blair, nblair@doit.wisc.edu
|
Field Summary |
protected org.apache.commons.logging.Log |
log
|
|
Method Summary |
CalendarEvent |
getEvent(CalendarConfiguration calendar,
net.fortuna.ical4j.model.Period period,
String uid,
String recurrenceId,
javax.portlet.PortletRequest request)
|
Set<CalendarEvent> |
getEvents(CalendarConfiguration calendarConfiguration,
net.fortuna.ical4j.model.Period period,
javax.portlet.PortletRequest request)
Workflow for this implementation:
consult the configured IUrlCreator for the url to request
consult the cache to see if the fetch via HTTP is necessary (if not return the cached events)
if the fetch is necessary, consult the ICredentialsExtractor for necessary Credentials
Invoke retrieveCalendarHttp
Pass the returned InputStream into the configured IContentProcessor
Return the CalendarEvents
(non-Javadoc) |
String |
getLink(CalendarConfiguration calendar,
net.fortuna.ical4j.model.Period period,
javax.portlet.PortletRequest request)
Get hyper link for the defined calendar. |
protected InputStream |
retrieveCalendarHttp(String url,
org.apache.commons.httpclient.Credentials credentials)
Uses Commons HttpClient to retrieve the specified url (optionally with the provided
Credentials. |
void |
setCache(net.sf.ehcache.Cache cache)
|
void |
setCacheKeyGenerator(ICacheKeyGenerator cacheKeyGenerator)
|
void |
setCacheKeyPrefix(String cacheKeyPrefix)
|
void |
setContentProcessor(IContentProcessor contentProcessor)
|
void |
setCredentialsExtractor(ICredentialsExtractor credentialsExtractor)
|
void |
setUrlCreator(IUrlCreator urlCreator)
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
log
protected final org.apache.commons.logging.Log log
ConfigurableHttpCalendarAdapter
public ConfigurableHttpCalendarAdapter()
setCache
public void setCache(net.sf.ehcache.Cache cache)
- Parameters:
cache - the cache to set
setUrlCreator
public void setUrlCreator(IUrlCreator urlCreator)
- Parameters:
urlCreator - the urlCreator to set
setCredentialsExtractor
public void setCredentialsExtractor(ICredentialsExtractor credentialsExtractor)
- Parameters:
credentialsExtractor - the credentialsExtractor to set
setContentProcessor
public void setContentProcessor(IContentProcessor contentProcessor)
- Parameters:
contentProcessor - the contentProcessor to set
setCacheKeyPrefix
public void setCacheKeyPrefix(String cacheKeyPrefix)
- Parameters:
cacheKeyPrefix - the cacheKeyPrefix to set
setCacheKeyGenerator
public void setCacheKeyGenerator(ICacheKeyGenerator cacheKeyGenerator)
getEvents
public Set<CalendarEvent> getEvents(CalendarConfiguration calendarConfiguration,
net.fortuna.ical4j.model.Period period,
javax.portlet.PortletRequest request)
throws CalendarException
- Workflow for this implementation:
- consult the configured
IUrlCreator for the url to request
- consult the cache to see if the fetch via HTTP is necessary (if not return the cached events)
- if the fetch is necessary, consult the
ICredentialsExtractor for necessary Credentials
- Invoke retrieveCalendarHttp
- Pass the returned
InputStream into the configured IContentProcessor
- Return the
CalendarEvents
(non-Javadoc)
- Specified by:
getEvents in interface ICalendarAdapter
- Parameters:
calendarConfiguration - calendar configuration for which to retrieve eventsperiod - time period for which to retrieve eventsrequest - user's portlet request
- Returns:
- Set of events for this calendar and time period
- Throws:
CalendarException- See Also:
ICalendarAdapter.getEvents(org.jasig.portlet.calendar.CalendarConfiguration, net.fortuna.ical4j.model.Period, javax.portlet.PortletRequest)
getEvent
public CalendarEvent getEvent(CalendarConfiguration calendar,
net.fortuna.ical4j.model.Period period,
String uid,
String recurrenceId,
javax.portlet.PortletRequest request)
throws CalendarException
- Specified by:
getEvent in interface ISingleEventSupport
- Returns:
-
- Throws:
CalendarException
getLink
public String getLink(CalendarConfiguration calendar,
net.fortuna.ical4j.model.Period period,
javax.portlet.PortletRequest request)
- Description copied from interface:
ICalendarAdapter
- Get hyper link for the defined calendar. In cases where the calendar resource
has a web interface, this method allows provides access to the url.
- Specified by:
getLink in interface ICalendarAdapter
- Parameters:
calendar - calendar configuration for which to retrieve eventsperiod - time period for which to retrieve eventsrequest - user's servlet request
- Returns:
- Set of events for this calendar and time period
retrieveCalendarHttp
protected InputStream retrieveCalendarHttp(String url,
org.apache.commons.httpclient.Credentials credentials)
throws CalendarException
- Uses Commons HttpClient to retrieve the specified url (optionally with the provided
Credentials.
The response body is returned as an InputStream.
- Parameters:
url - URL of the calendar to be retrievedcredentials - Credentials to use with the request, if necessary (null is ok if credentials not required)
- Returns:
- the body of the http response as a stream
- Throws:
CalendarException - wraps all potential Exception types
Copyright © 2011 Jasig. All Rights Reserved.