Class AbstractMessagingConnector
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.messagingconnector.AbstractMessagingConnector
-
- All Implemented Interfaces:
MessagingConnector,LogEnabled,Initializable,Component,Serviceable
- Direct Known Subclasses:
EWSConnector,ExchangeConnector,GraphConnector,ZimbraConnector
public abstract class AbstractMessagingConnector extends AbstractLogEnabled implements MessagingConnector, Initializable, Serviceable
Abstract implementation ofMessagingConnectorwith cache.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.ametys.plugins.messagingconnector.MessagingConnector
MessagingConnector.AttendeeInformation, MessagingConnector.FreeBusyStatus, MessagingConnector.ResponseType
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractCacheManager_cacheManagerCacheManager used to create and get cacheprotected CryptoHelper_cryptoHelperThe crypto helperprotected CurrentUserProvider_currentUserProviderThe current user providerprotected UserPopulationDAO_userPopulationDAOThe user population DAOprotected UserPreferencesManager_userPrefThe user preferences-
Fields inherited from interface org.ametys.plugins.messagingconnector.MessagingConnector
ROLE
-
-
Constructor Summary
Constructors Constructor Description AbstractMessagingConnector()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StringcreateEvent(String title, String description, String place, boolean isAllDay, ZonedDateTime startDate, ZonedDateTime endDate, EventRecurrenceTypeEnum recurrenceType, ZonedDateTime untilDate, Map<String,Boolean> attendees, UserIdentity organiser)Create an eventvoiddeleteEvent(String eventId, UserIdentity organiser)Delete an eventList<String>getAllowedPopulationIds()Get the list of population id allowed to the messaging connectorMap<String,MessagingConnector.AttendeeInformation>getAttendees(String eventId, UserIdentity organiser)Get the map of attendees for an eventList<CalendarEvent>getEvents(UserIdentity userIdentity, int maxDays, int maxEvents)Get the list of upcoming events from now for a given userintgetEventsCount(UserIdentity userIdentity, int maxDays)Return the number of upcoming eventsMap<String,MessagingConnector.FreeBusyStatus>getFreeBusy(Date startDate, Date endDate, boolean isAllDay, Set<String> attendees, UserIdentity organiser)Get free/busy status for attendees for a time windowintgetUnreadEmailCount(UserIdentity userIdentity)Return the number of unread mails for a given userList<EmailMessage>getUnreadEmails(UserIdentity userIdentity, int maxEmails)Return the unread emails for a given userprotected StringgetUserCryptedPassword(UserIdentity userIdentity)Get the user password, still cryptedprotected StringgetUserPassword(UserIdentity userIdentity)Get the user password for the messaging connectorvoidinitialize()protected StringinternalCreateEvent(String title, String description, String place, boolean isAllDay, ZonedDateTime startDate, ZonedDateTime endDate, EventRecurrenceTypeEnum recurrenceType, ZonedDateTime untilDate, Map<String,Boolean> attendees, UserIdentity organiser)Create an eventprotected voidinternalDeleteEvent(String eventId, UserIdentity organiser)Delete an eventprotected Map<String,MessagingConnector.AttendeeInformation>internalGetAttendees(String eventId, UserIdentity organiser)Get the map of attendees for an eventprotected abstract List<EmailMessage>internalGetEmails(UserIdentity userIdentity, int maxEmails)Get emails (no caching)protected abstract intinternalGetEmailsCount(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 intinternalGetEventsCount(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 windowprotected booleaninternalIsEventExist(String eventId, UserIdentity organiser)True if the event exist in the messaging connectorprotected voidinternalSetAttendees(String eventId, Map<String,Boolean> attendees, UserIdentity organiser)Set attendees for an eventprotected voidinternalUpdateEvent(String eventId, String title, String description, String place, boolean isAllDay, ZonedDateTime startDate, ZonedDateTime endDate, EventRecurrenceTypeEnum recurrenceType, ZonedDateTime untilDate, Map<String,Boolean> attendees, UserIdentity organiser)Update an eventprotected booleanisAllowed(UserIdentity userIdentity)True if the user is allowedbooleanisEventExist(String eventId, UserIdentity organiser)True if the event exist in the messaging connectorbooleanisUserExist(UserIdentity userIdentity)True if the user existvoidservice(ServiceManager manager)voidsetAttendees(String eventId, Map<String,Boolean> attendees, UserIdentity organiser)Set attendees for an eventvoidsetUserPassword(UserIdentity userIdentity, String password)Set a new password for the userbooleansupportInvitation()Tell if the messaging connector supports event invitationbooleansupportUserCredential(UserIdentity userIdentity)Check if a user credential should be savedvoidupdateEvent(String eventId, String title, String description, String place, boolean isAllDay, ZonedDateTime startDate, ZonedDateTime endDate, EventRecurrenceTypeEnum recurrenceType, ZonedDateTime untilDate, Map<String,Boolean> attendees, UserIdentity organiser)Update an eventbooleanuserCredentialNeeded(UserIdentity userIdentity)Check if the service needs user credential (some implementation can use a central API key or impersonation, some don't)-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_userPopulationDAO
protected UserPopulationDAO _userPopulationDAO
The user population DAO
-
_userPref
protected UserPreferencesManager _userPref
The user preferences
-
_cryptoHelper
protected CryptoHelper _cryptoHelper
The crypto helper
-
_currentUserProvider
protected CurrentUserProvider _currentUserProvider
The current user provider
-
_cacheManager
protected AbstractCacheManager _cacheManager
CacheManager used to create and get cache
-
-
Constructor Detail
-
AbstractMessagingConnector
public AbstractMessagingConnector()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
public void initialize()
- Specified by:
initializein interfaceInitializable
-
getAllowedPopulationIds
public List<String> getAllowedPopulationIds()
Description copied from interface:MessagingConnectorGet the list of population id allowed to the messaging connector- Specified by:
getAllowedPopulationIdsin interfaceMessagingConnector- Returns:
- the list of population id allowed to the messaging connector
-
isAllowed
protected boolean isAllowed(UserIdentity userIdentity)
True if the user is allowed- Parameters:
userIdentity- the user identity- Returns:
- true if the user is allowed
-
getEvents
public List<CalendarEvent> getEvents(UserIdentity userIdentity, int maxDays, int maxEvents) throws MessagingConnectorException
Description copied from interface:MessagingConnectorGet the list of upcoming events from now for a given user- Specified by:
getEventsin interfaceMessagingConnector- Parameters:
userIdentity- the owner of the eventsmaxDays- The maximum number of days to search for from nowmaxEvents- the maximum number of events to retrieve- Returns:
- the next events
- Throws:
MessagingConnectorException- if failed to get events
-
getEventsCount
public int getEventsCount(UserIdentity userIdentity, int maxDays) throws MessagingConnectorException
Description copied from interface:MessagingConnectorReturn the number of upcoming events- Specified by:
getEventsCountin interfaceMessagingConnector- Parameters:
userIdentity- the owner of the eventsmaxDays- The maximum number of days to search for from now- Returns:
- the number of upcoming events
- Throws:
MessagingConnectorException- if failed to get events' count
-
getUnreadEmails
public List<EmailMessage> getUnreadEmails(UserIdentity userIdentity, int maxEmails) throws MessagingConnectorException
Description copied from interface:MessagingConnectorReturn the unread emails for a given user- Specified by:
getUnreadEmailsin interfaceMessagingConnector- Parameters:
userIdentity- the recipient of the mailsmaxEmails- The max number of emails to return- Returns:
- a mail messsages
- Throws:
MessagingConnectorException- if failed to get mails
-
getUnreadEmailCount
public int getUnreadEmailCount(UserIdentity userIdentity) throws MessagingConnectorException
Description copied from interface:MessagingConnectorReturn the number of unread mails for a given user- Specified by:
getUnreadEmailCountin interfaceMessagingConnector- Parameters:
userIdentity- the receiver of the mails- Returns:
- the number of unread mails
- Throws:
MessagingConnectorException- if failed to get unread mails ' count
-
internalGetEvents
protected abstract List<CalendarEvent> internalGetEvents(UserIdentity userIdentity, int maxDays, int maxEvents) throws MessagingConnectorException
Get upcoming events (no caching)- Parameters:
userIdentity- The user identitymaxDays- The maximum number of days to search formaxEvents- The maximum number of events to retrieve- Returns:
- The calendar events
- Throws:
MessagingConnectorException- if failed to get events from server
-
internalGetEventsCount
protected abstract int internalGetEventsCount(UserIdentity userIdentity, int maxDays) throws MessagingConnectorException
Get upcoming events count (no caching)- Parameters:
userIdentity- The user identitymaxDays- The maximum number of days to search for- Returns:
- The number of calendar events
- Throws:
MessagingConnectorException- if failed to get events from server
-
internalGetEmails
protected abstract List<EmailMessage> internalGetEmails(UserIdentity userIdentity, int maxEmails) throws MessagingConnectorException
Get emails (no caching)- Parameters:
userIdentity- The user identitymaxEmails- The maximum number of emails to retrieve- Returns:
- The emails
- Throws:
MessagingConnectorException- if failed to get events from server
-
getUserPassword
protected String getUserPassword(UserIdentity userIdentity) throws UserPreferencesException
Get the user password for the messaging connector- Parameters:
userIdentity- user to check- Returns:
- the decrypted user password
- Throws:
UserPreferencesException- error while reading user preferences
-
getUserCryptedPassword
protected String getUserCryptedPassword(UserIdentity userIdentity) throws UserPreferencesException
Get the user password, still crypted- Parameters:
userIdentity- user to check- Returns:
- the still crypted user password
- Throws:
UserPreferencesException- error while reading user preferences
-
setUserPassword
public void setUserPassword(UserIdentity userIdentity, String password) throws UserPreferencesException, MessagingConnectorException
Description copied from interface:MessagingConnectorSet a new password for the user- Specified by:
setUserPasswordin interfaceMessagingConnector- Parameters:
userIdentity- user that have a password changepassword- new password- Throws:
UserPreferencesException- An exception occured while saving the passwordMessagingConnectorException- Thrown when the messaging connector does not support user credentials
-
internalGetEmailsCount
protected abstract int internalGetEmailsCount(UserIdentity userIdentity) throws MessagingConnectorException
Get emails count (no caching)- Parameters:
userIdentity- The user identity- Returns:
- The emails count
- Throws:
MessagingConnectorException- if failed to get events from server
-
supportInvitation
public boolean supportInvitation() throws MessagingConnectorException
Description copied from interface:MessagingConnectorTell if the messaging connector supports event invitation- Specified by:
supportInvitationin interfaceMessagingConnector- Returns:
- true if the messaging connector supports event invitation
- Throws:
MessagingConnectorException- if failed to get events from server
-
isEventExist
public boolean isEventExist(String eventId, UserIdentity organiser) throws MessagingConnectorException
Description copied from interface:MessagingConnectorTrue if the event exist in the messaging connector- Specified by:
isEventExistin interfaceMessagingConnector- Parameters:
eventId- the event idorganiser- the organiser- Returns:
- true if the event exist
- Throws:
MessagingConnectorException- if an error occurred
-
internalIsEventExist
protected boolean internalIsEventExist(String eventId, UserIdentity organiser) throws MessagingConnectorException
True if the event exist in the messaging connector- Parameters:
eventId- the event idorganiser- the organiser- Returns:
- true if the event exist
- Throws:
MessagingConnectorException- if an error occurred
-
createEvent
public String createEvent(String title, String description, String place, boolean isAllDay, ZonedDateTime startDate, ZonedDateTime endDate, EventRecurrenceTypeEnum recurrenceType, ZonedDateTime untilDate, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
Description copied from interface:MessagingConnectorCreate an event- Specified by:
createEventin interfaceMessagingConnector- Parameters:
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 organiser- Returns:
- the id of the event created
- Throws:
MessagingConnectorException- if failed to get events from server
-
internalCreateEvent
protected String internalCreateEvent(String title, String description, String place, boolean isAllDay, ZonedDateTime startDate, ZonedDateTime endDate, EventRecurrenceTypeEnum recurrenceType, ZonedDateTime untilDate, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
Create an event- Parameters:
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 organiser- Returns:
- the id of the event created
- Throws:
MessagingConnectorException- if failed to get events from server
-
updateEvent
public void updateEvent(String eventId, String title, String description, String place, boolean isAllDay, ZonedDateTime startDate, ZonedDateTime endDate, EventRecurrenceTypeEnum recurrenceType, ZonedDateTime untilDate, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
Description copied from interface:MessagingConnectorUpdate an event- Specified by:
updateEventin interfaceMessagingConnector- Parameters:
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 organiser- Throws:
MessagingConnectorException- if failed to get events from server
-
internalUpdateEvent
protected void internalUpdateEvent(String eventId, String title, String description, String place, boolean isAllDay, ZonedDateTime startDate, ZonedDateTime endDate, EventRecurrenceTypeEnum recurrenceType, ZonedDateTime untilDate, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
Update an event- Parameters:
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 organiser- Throws:
MessagingConnectorException- if failed to get events from server
-
deleteEvent
public void deleteEvent(String eventId, UserIdentity organiser) throws MessagingConnectorException
Description copied from interface:MessagingConnectorDelete an event- Specified by:
deleteEventin interfaceMessagingConnector- Parameters:
eventId- the event id to deleteorganiser- the event organiser- Throws:
MessagingConnectorException- if failed to get events from server
-
internalDeleteEvent
protected void internalDeleteEvent(String eventId, UserIdentity organiser) throws MessagingConnectorException
Delete an event- Parameters:
eventId- the event id to deleteorganiser- the event organiser- Throws:
MessagingConnectorException- if failed to get events from server
-
getAttendees
public Map<String,MessagingConnector.AttendeeInformation> getAttendees(String eventId, UserIdentity organiser) throws MessagingConnectorException
Description copied from interface:MessagingConnectorGet the map of attendees for an event- Specified by:
getAttendeesin interfaceMessagingConnector- Parameters:
eventId- the event idorganiser- the event organiser- Returns:
- the map of attendees (email -> attendee information)
- Throws:
MessagingConnectorException- if failed to get events from server
-
internalGetAttendees
protected Map<String,MessagingConnector.AttendeeInformation> internalGetAttendees(String eventId, UserIdentity organiser) throws MessagingConnectorException
Get the map of attendees for an event- Parameters:
eventId- the event idorganiser- the event organiser- Returns:
- the map of attendees (email -> attendee information)
- Throws:
MessagingConnectorException- if failed to get events from server
-
setAttendees
public void setAttendees(String eventId, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
Description copied from interface:MessagingConnectorSet attendees for an event- Specified by:
setAttendeesin interfaceMessagingConnector- Parameters:
eventId- the event idattendees- the map of attendees (email -> optional or requested) to setorganiser- the event organiser- Throws:
MessagingConnectorException- if failed to get events from server
-
internalSetAttendees
protected void internalSetAttendees(String eventId, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
Set attendees for an event- Parameters:
eventId- the event idattendees- the map of attendees (email -> optional or requested) to setorganiser- the event organiser- Throws:
MessagingConnectorException- if failed to get events from server
-
getFreeBusy
public Map<String,MessagingConnector.FreeBusyStatus> getFreeBusy(Date startDate, Date endDate, boolean isAllDay, Set<String> attendees, UserIdentity organiser) throws MessagingConnectorException
Description copied from interface:MessagingConnectorGet free/busy status for attendees for a time window- Specified by:
getFreeBusyin interfaceMessagingConnector- Parameters:
startDate- the start dateendDate- the end dateisAllDay- true if is an allday eventattendees- the list of attendees emailorganiser- the event organiser- Returns:
- the map of attendees (email -> freeBusy status)
- Throws:
MessagingConnectorException- if failed to get events from server
-
internalGetFreeBusy
protected Map<String,MessagingConnector.FreeBusyStatus> internalGetFreeBusy(Date startDate, Date endDate, boolean isAllDay, Set<String> attendees, UserIdentity organiser) throws MessagingConnectorException
Get free/busy status for attendees for a time window- Parameters:
startDate- the start dateendDate- the end dateisAllDay- true if is an allday eventattendees- the list of attendees emailorganiser- the event organiser- Returns:
- the map of attendees (email -> freeBusy status)
- Throws:
MessagingConnectorException- if failed to get events from server
-
userCredentialNeeded
public boolean userCredentialNeeded(UserIdentity userIdentity)
Description copied from interface:MessagingConnectorCheck if the service needs user credential (some implementation can use a central API key or impersonation, some don't)- Specified by:
userCredentialNeededin interfaceMessagingConnector- Parameters:
userIdentity- The useridentity involved in the demand- Returns:
- True if the service is configured to ask for user credential
-
supportUserCredential
public boolean supportUserCredential(UserIdentity userIdentity)
Description copied from interface:MessagingConnectorCheck if a user credential should be saved- Specified by:
supportUserCredentialin interfaceMessagingConnector- Parameters:
userIdentity- The useridentity involved in the demand- Returns:
- true if this implementation supports user credential (and is configured to use them)
-
isUserExist
public boolean isUserExist(UserIdentity userIdentity) throws MessagingConnectorException
Description copied from interface:MessagingConnectorTrue if the user exist- Specified by:
isUserExistin interfaceMessagingConnector- Parameters:
userIdentity- the user identity- Returns:
- true if the user exist
- Throws:
MessagingConnectorException- if failed to get events from server
-
-