public abstract class AbstractMessagingConnector extends AbstractLogEnabled implements MessagingConnector, Initializable, Serviceable
MessagingConnector
with cache.Modifier and Type | Class and Description |
---|---|
(package private) class |
AbstractMessagingConnector.EmailCacheKey
Internal class for key of events count cache
|
(package private) class |
AbstractMessagingConnector.EventCacheKey
Internal class for key of events cache
|
(package private) class |
AbstractMessagingConnector.EventCountCacheKey
Internal class for key of events count cache
|
MessagingConnector.AttendeeInformation, MessagingConnector.FreeBusyStatus, MessagingConnector.ResponseType
Modifier and Type | Field and Description |
---|---|
protected CryptoHelper |
_cryptoHelper
The crypto helper
|
protected CurrentUserProvider |
_currentUserProvider
The current user provider
|
private Cache<AbstractMessagingConnector.EmailCacheKey,List<EmailMessage>> |
_emailsCache |
private Cache<UserIdentity,Integer> |
_emailsCountCache |
private Cache<MessagingConnectorException.ExceptionType,Set<UserIdentity>> |
_errorCache |
private Cache<AbstractMessagingConnector.EventCacheKey,List<CalendarEvent>> |
_eventsCache |
private Cache<AbstractMessagingConnector.EventCountCacheKey,Integer> |
_eventsCountCache |
private List<String> |
_populationIds |
private Cache<MessagingConnectorException.ExceptionType,Set<UserIdentity>> |
_timeoutErrorCache |
protected UserPopulationDAO |
_userPopulationDAO
The user population DAO
|
protected UserPreferencesManager |
_userPref
The user preferences
|
private static int |
TIMEOUT_CACHE_DURATION_SECONDS
Duration of the cache for timeout errors, no calls will be done again for one user
|
ROLE
Constructor and Description |
---|
AbstractMessagingConnector() |
Modifier and Type | Method and Description |
---|---|
private MessagingConnectorException.ExceptionType |
_getExceptionTypeFromCache(UserIdentity userIdentity) |
private void |
_invalidateExceptionForUserInCache(UserIdentity userIdentity,
MessagingConnectorException.ExceptionType type) |
private void |
_putExceptionInCache(UserIdentity userIdentity,
MessagingConnectorException.ExceptionType type) |
private void |
_throwMessagingConnectorExceptionIfInCache(UserIdentity userIdentity) |
String |
createEvent(String title,
String description,
String place,
boolean isAllDay,
Date startDate,
Date endDate,
EventRecurrenceTypeEnum recurrenceType,
Date untilDate,
Map<String,Boolean> attendees,
UserIdentity organiser)
Create an event
|
void |
deleteEvent(String eventId,
UserIdentity organiser)
Delete an event
|
List<String> |
getAllowedPopulationIds()
Get the list of population id allowed to the messaging connector
|
Map<String,MessagingConnector.AttendeeInformation> |
getAttendees(String eventId,
UserIdentity organiser)
Get the map of attendees for an event
|
List<CalendarEvent> |
getEvents(UserIdentity userIdentity,
int maxDays,
int maxEvents)
Get the list of upcoming events from now for a given user
|
int |
getEventsCount(UserIdentity userIdentity,
int maxDays)
Return the number of upcoming events
|
Map<String,MessagingConnector.FreeBusyStatus> |
getFreeBusy(Date startDate,
Date endDate,
boolean isAllDay,
Set<String> attendees,
UserIdentity organiser)
Get free/busy status for attendees for a time window
|
int |
getUnreadEmailCount(UserIdentity userIdentity)
Return the number of unread mails for a given user
|
List<EmailMessage> |
getUnreadEmails(UserIdentity userIdentity,
int maxEmails)
Return the unread emails for a given user
|
protected String |
getUserCryptedPassword(UserIdentity userIdentity)
Get the user password, still crypted
|
protected String |
getUserPassword(UserIdentity userIdentity)
Get the user password for the messaging connector
|
void |
initialize() |
protected String |
internalCreateEvent(String title,
String description,
String place,
boolean isAllDay,
Date startDate,
Date endDate,
EventRecurrenceTypeEnum recurrenceType,
Date untilDate,
Map<String,Boolean> attendees,
UserIdentity organiser)
Create an event
|
protected void |
internalDeleteEvent(String eventId,
UserIdentity organiser)
Delete an event
|
protected Map<String,MessagingConnector.AttendeeInformation> |
internalGetAttendees(String eventId,
UserIdentity organiser)
Get the map of attendees for an event
|
protected abstract List<EmailMessage> |
internalGetEmails(UserIdentity userIdentity,
int maxEmails)
Get emails (no caching)
|
protected abstract int |
internalGetEmailsCount(UserIdentity userIdentity)
Get emails count (no caching)
|
protected abstract List<CalendarEvent> |
internalGetEvents(UserIdentity userIdentity,
int maxDays,
int maxEvents)
Get upcoming events (no caching)
|
protected abstract int |
internalGetEventsCount(UserIdentity userIdentity,
int maxDays)
Get upcoming events count (no caching)
|
protected Map<String,MessagingConnector.FreeBusyStatus> |
internalGetFreeBusy(Date startDate,
Date endDate,
boolean isAllDay,
Set<String> attendees,
UserIdentity organiser)
Get free/busy status for attendees for a time window
|
protected boolean |
internalIsEventExist(String eventId,
UserIdentity organiser)
True if the event exist in the messaging connector
|
protected void |
internalSetAttendees(String eventId,
Map<String,Boolean> attendees,
UserIdentity organiser)
Set attendees for an event
|
protected void |
internalUpdateEvent(String eventId,
String title,
String description,
String place,
boolean isAllDay,
Date startDate,
Date endDate,
EventRecurrenceTypeEnum recurrenceType,
Date untilDate,
Map<String,Boolean> attendees,
UserIdentity organiser)
Update an event
|
protected boolean |
isAllowed(UserIdentity userIdentity)
True if the user is allowed
|
boolean |
isEventExist(String eventId,
UserIdentity organiser)
True if the event exist in the messaging connector
|
boolean |
isUserExist(UserIdentity userIdentity)
True if the user exist
|
void |
service(ServiceManager manager) |
void |
setAttendees(String eventId,
Map<String,Boolean> attendees,
UserIdentity organiser)
Set attendees for an event
|
void |
setUserPassword(UserIdentity userIdentity,
String password)
Set a new password for the user
|
boolean |
supportInvitation()
Tell if the messaging connector supports event invitation
|
boolean |
supportUserCredential()
Check if a user credential should be saved
|
void |
updateEvent(String eventId,
String title,
String description,
String place,
boolean isAllDay,
Date startDate,
Date endDate,
EventRecurrenceTypeEnum recurrenceType,
Date untilDate,
Map<String,Boolean> attendees,
UserIdentity organiser)
Update an event
|
boolean |
userCredentialNeeded()
Check if the service needs user credential (some implementation can use a central API key or impersonation, some don't)
|
getLogger, setLogger
private static final int TIMEOUT_CACHE_DURATION_SECONDS
protected UserPopulationDAO _userPopulationDAO
protected UserPreferencesManager _userPref
protected CryptoHelper _cryptoHelper
protected CurrentUserProvider _currentUserProvider
private Cache<AbstractMessagingConnector.EventCacheKey,List<CalendarEvent>> _eventsCache
private Cache<AbstractMessagingConnector.EventCountCacheKey,Integer> _eventsCountCache
private Cache<AbstractMessagingConnector.EmailCacheKey,List<EmailMessage>> _emailsCache
private Cache<UserIdentity,Integer> _emailsCountCache
private Cache<MessagingConnectorException.ExceptionType,Set<UserIdentity>> _errorCache
private Cache<MessagingConnectorException.ExceptionType,Set<UserIdentity>> _timeoutErrorCache
private List<String> _populationIds
public AbstractMessagingConnector()
public void service(ServiceManager manager) throws ServiceException
service
in interface Serviceable
ServiceException
public void initialize()
initialize
in interface Initializable
public List<String> getAllowedPopulationIds()
MessagingConnector
getAllowedPopulationIds
in interface MessagingConnector
protected boolean isAllowed(UserIdentity userIdentity)
userIdentity
- the user identitypublic List<CalendarEvent> getEvents(UserIdentity userIdentity, int maxDays, int maxEvents) throws MessagingConnectorException
MessagingConnector
getEvents
in interface MessagingConnector
userIdentity
- the owner of the eventsmaxDays
- The maximum number of days to search for from nowmaxEvents
- the maximum number of events to retrieveMessagingConnectorException
- if failed to get eventspublic int getEventsCount(UserIdentity userIdentity, int maxDays) throws MessagingConnectorException
MessagingConnector
getEventsCount
in interface MessagingConnector
userIdentity
- the owner of the eventsmaxDays
- The maximum number of days to search for from nowMessagingConnectorException
- if failed to get events' countpublic List<EmailMessage> getUnreadEmails(UserIdentity userIdentity, int maxEmails) throws MessagingConnectorException
MessagingConnector
getUnreadEmails
in interface MessagingConnector
userIdentity
- the recipient of the mailsmaxEmails
- The max number of emails to returnMessagingConnectorException
- if failed to get mailspublic int getUnreadEmailCount(UserIdentity userIdentity) throws MessagingConnectorException
MessagingConnector
getUnreadEmailCount
in interface MessagingConnector
userIdentity
- the receiver of the mailsMessagingConnectorException
- if failed to get unread mails ' countprotected abstract List<CalendarEvent> internalGetEvents(UserIdentity userIdentity, int maxDays, int maxEvents) throws MessagingConnectorException
userIdentity
- The user identitymaxDays
- The maximum number of days to search formaxEvents
- The maximum number of events to retrieveMessagingConnectorException
- if failed to get events from serverprotected abstract int internalGetEventsCount(UserIdentity userIdentity, int maxDays) throws MessagingConnectorException
userIdentity
- The user identitymaxDays
- The maximum number of days to search forMessagingConnectorException
- if failed to get events from serverprotected abstract List<EmailMessage> internalGetEmails(UserIdentity userIdentity, int maxEmails) throws MessagingConnectorException
userIdentity
- The user identitymaxEmails
- The maximum number of emails to retrieveMessagingConnectorException
- if failed to get events from serverprotected String getUserPassword(UserIdentity userIdentity) throws UserPreferencesException
userIdentity
- user to checkUserPreferencesException
- error while reading user preferencesprotected String getUserCryptedPassword(UserIdentity userIdentity) throws UserPreferencesException
userIdentity
- user to checkUserPreferencesException
- error while reading user preferencespublic void setUserPassword(UserIdentity userIdentity, String password) throws UserPreferencesException, MessagingConnectorException
MessagingConnector
setUserPassword
in interface MessagingConnector
userIdentity
- user that have a password changepassword
- new passwordUserPreferencesException
- An exception occured while saving the passwordMessagingConnectorException
- Thrown when the messaging connector does not support user credentialsprotected abstract int internalGetEmailsCount(UserIdentity userIdentity) throws MessagingConnectorException
userIdentity
- The user identityMessagingConnectorException
- if failed to get events from serverpublic boolean supportInvitation() throws MessagingConnectorException
MessagingConnector
supportInvitation
in interface MessagingConnector
MessagingConnectorException
- if failed to get events from serverpublic boolean isEventExist(String eventId, UserIdentity organiser) throws MessagingConnectorException
MessagingConnector
isEventExist
in interface MessagingConnector
eventId
- the event idorganiser
- the organiserMessagingConnectorException
- if an error occurredprotected boolean internalIsEventExist(String eventId, UserIdentity organiser) throws MessagingConnectorException
eventId
- the event idorganiser
- the organiserMessagingConnectorException
- if an error occurredpublic String createEvent(String title, String description, String place, boolean isAllDay, Date startDate, Date endDate, EventRecurrenceTypeEnum recurrenceType, Date untilDate, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
MessagingConnector
createEvent
in interface MessagingConnector
title
- the event titledescription
- the event descriptionplace
- the event placeisAllDay
- if the event is all daystartDate
- the event start dateendDate
- the event end daterecurrenceType
- recurrence typeuntilDate
- until date of the recurring eventattendees
- the map of attendees (email -> optional or requested) to setorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverprotected String internalCreateEvent(String title, String description, String place, boolean isAllDay, Date startDate, Date endDate, EventRecurrenceTypeEnum recurrenceType, Date untilDate, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
title
- the event titledescription
- the event descriptionplace
- the event placeisAllDay
- if the event is all daystartDate
- the event start dateendDate
- the event end daterecurrenceType
- recurrence typeuntilDate
- until date of the recurring eventattendees
- the map of attendees (email -> optional or requested) to setorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverpublic void updateEvent(String eventId, String title, String description, String place, boolean isAllDay, Date startDate, Date endDate, EventRecurrenceTypeEnum recurrenceType, Date untilDate, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
MessagingConnector
updateEvent
in interface MessagingConnector
eventId
- the event id to deletetitle
- the event titledescription
- the event descriptionplace
- the event placeisAllDay
- if the event is all daystartDate
- the event start dateendDate
- the event end daterecurrenceType
- recurrence typeuntilDate
- until date of the recurring eventattendees
- the map of attendees (email -> optional or requested) to setorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverprotected void internalUpdateEvent(String eventId, String title, String description, String place, boolean isAllDay, Date startDate, Date endDate, EventRecurrenceTypeEnum recurrenceType, Date untilDate, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
eventId
- the event id to deletetitle
- the event titledescription
- the event descriptionplace
- the event placeisAllDay
- if the event is all daystartDate
- the event start dateendDate
- the event end daterecurrenceType
- recurrence typeuntilDate
- until date of the recurring eventattendees
- the map of attendees (email -> optional or requested) to setorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverpublic void deleteEvent(String eventId, UserIdentity organiser) throws MessagingConnectorException
MessagingConnector
deleteEvent
in interface MessagingConnector
eventId
- the event id to deleteorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverprotected void internalDeleteEvent(String eventId, UserIdentity organiser) throws MessagingConnectorException
eventId
- the event id to deleteorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverpublic Map<String,MessagingConnector.AttendeeInformation> getAttendees(String eventId, UserIdentity organiser) throws MessagingConnectorException
MessagingConnector
getAttendees
in interface MessagingConnector
eventId
- the event idorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverprotected Map<String,MessagingConnector.AttendeeInformation> internalGetAttendees(String eventId, UserIdentity organiser) throws MessagingConnectorException
eventId
- the event idorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverpublic void setAttendees(String eventId, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
MessagingConnector
setAttendees
in interface MessagingConnector
eventId
- the event idattendees
- the map of attendees (email -> optional or requested) to setorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverprotected void internalSetAttendees(String eventId, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
eventId
- the event idattendees
- the map of attendees (email -> optional or requested) to setorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverpublic Map<String,MessagingConnector.FreeBusyStatus> getFreeBusy(Date startDate, Date endDate, boolean isAllDay, Set<String> attendees, UserIdentity organiser) throws MessagingConnectorException
MessagingConnector
getFreeBusy
in interface MessagingConnector
startDate
- the start dateendDate
- the end dateisAllDay
- true if is an allday eventattendees
- the list of attendees emailorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverprotected Map<String,MessagingConnector.FreeBusyStatus> internalGetFreeBusy(Date startDate, Date endDate, boolean isAllDay, Set<String> attendees, UserIdentity organiser) throws MessagingConnectorException
startDate
- the start dateendDate
- the end dateisAllDay
- true if is an allday eventattendees
- the list of attendees emailorganiser
- the event organiserMessagingConnectorException
- if failed to get events from serverpublic boolean userCredentialNeeded()
MessagingConnector
userCredentialNeeded
in interface MessagingConnector
public boolean supportUserCredential()
MessagingConnector
supportUserCredential
in interface MessagingConnector
public boolean isUserExist(UserIdentity userIdentity) throws MessagingConnectorException
MessagingConnector
isUserExist
in interface MessagingConnector
userIdentity
- the user identityMessagingConnectorException
- if failed to get events from serverprivate void _invalidateExceptionForUserInCache(UserIdentity userIdentity, MessagingConnectorException.ExceptionType type)
private void _putExceptionInCache(UserIdentity userIdentity, MessagingConnectorException.ExceptionType type)
private MessagingConnectorException.ExceptionType _getExceptionTypeFromCache(UserIdentity userIdentity)
private void _throwMessagingConnectorExceptionIfInCache(UserIdentity userIdentity) throws MessagingConnectorException
MessagingConnectorException