Class IcsReader
- java.lang.Object
-
- org.ametys.plugins.calendar.icsreader.IcsReader
-
- All Implemented Interfaces:
LogEnabled
,Initializable
,Component
,Serviceable
public class IcsReader extends Object implements Serviceable, Component, Initializable, LogEnabled
Read a distant ICS file for a certain number of events in the future
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
IcsReader.IcsEvents
Object wrapper for ics events
-
Field Summary
Fields Modifier and Type Field Description private static String
__ICS_CACHE_ID
private AbstractCacheManager
_abstractCacheManager
protected org.slf4j.Logger
_logger
loggerstatic String
ROLE
The Avalon role.
-
Constructor Summary
Constructors Constructor Description IcsReader()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private Date
_getEventDateTime(CalendarComponent event, String property)
Return a string representing the start/end date of an event, or null if no start/end date was foundprotected IcsReader.IcsEvents
_getEventList(String url, EventsFilterHelper.DateRange dateRange, Long nbEvents, Long maxFileSize)
Get a list of events from an ics file, without trying the cacheList<LocalVEvent>
getEventDates(VEvent event, EventsFilterHelper.DateRange dateRange, Tag tag)
Get a list ofLocalDate
covered by this eventIcsReader.IcsEvents
getEventList(String url, EventsFilterHelper.DateRange dateRange, Long nbEvents, Long maxFileSize)
Get a list of events from an ics fileprivate long
getFileSize(String url)
Try to get the size of the file, and download it if neededprivate Cache<CacheKey,IcsReader.IcsEvents>
getIcsCache()
private org.slf4j.Logger
getLogger()
void
initialize()
void
service(ServiceManager smanager)
void
setLogger(org.slf4j.Logger logger)
Called at creation time to provide aLogger
.
-
-
-
Field Detail
-
__ICS_CACHE_ID
private static final String __ICS_CACHE_ID
-
_logger
protected org.slf4j.Logger _logger
logger
-
_abstractCacheManager
private AbstractCacheManager _abstractCacheManager
-
-
Constructor Detail
-
IcsReader
public IcsReader()
-
-
Method Detail
-
service
public void service(ServiceManager smanager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Throws:
ServiceException
-
getEventList
public IcsReader.IcsEvents getEventList(String url, EventsFilterHelper.DateRange dateRange, Long nbEvents, Long maxFileSize)
Get a list of events from an ics file- Parameters:
url
- url of the ics filedateRange
- range of dates to fetchnbEvents
- number of events to readmaxFileSize
- max ics file size (in bytes)- Returns:
- a List of
VEvent
-
_getEventList
protected IcsReader.IcsEvents _getEventList(String url, EventsFilterHelper.DateRange dateRange, Long nbEvents, Long maxFileSize)
Get a list of events from an ics file, without trying the cache- Parameters:
url
- url of the ics filedateRange
- range of dates to fetchnbEvents
- number of events to readmaxFileSize
- max ics file size (in bytes)- Returns:
- a List of
VEvent
-
initialize
public void initialize() throws Exception
- Specified by:
initialize
in interfaceInitializable
- Throws:
Exception
-
getIcsCache
private Cache<CacheKey,IcsReader.IcsEvents> getIcsCache()
-
getFileSize
private long getFileSize(String url) throws IOException
Try to get the size of the file, and download it if needed- Parameters:
url
- the url to get- Returns:
- size in octet, or -1 if error
- Throws:
IOException
- Something went wrong
-
getEventDates
public List<LocalVEvent> getEventDates(VEvent event, EventsFilterHelper.DateRange dateRange, Tag tag)
Get a list ofLocalDate
covered by this event- Parameters:
event
- the event to testdateRange
- the dates to check, can be null but this will return nulltag
- the tag used for this ICS- Returns:
- a list of
LocalDate
for the days in which this event appears, or null if nothing matches
-
_getEventDateTime
private Date _getEventDateTime(CalendarComponent event, String property)
Return a string representing the start/end date of an event, or null if no start/end date was found- Parameters:
event
- the event to readproperty
- aProperty
to check (Property.DTSTART
orProperty.DTEND
)- Returns:
- a string representing the date
-
setLogger
public void setLogger(org.slf4j.Logger logger)
Description copied from interface:LogEnabled
Called at creation time to provide aLogger
.- Specified by:
setLogger
in interfaceLogEnabled
- Parameters:
logger
- aLogger
for messages.
-
getLogger
private org.slf4j.Logger getLogger()
-
-