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 of
MessagingConnector with cache.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.ametys.plugins.messagingconnector.MessagingConnector
MessagingConnector.AttendeeInformation, MessagingConnector.FreeBusyStatus, MessagingConnector.ResponseType -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected AbstractCacheManagerCacheManager used to create and get cacheprotected CryptoHelperThe crypto helperprotected CurrentUserProviderThe current user providerprotected UserPopulationDAOThe user population DAOprotected UserPreferencesManagerThe user preferencesFields inherited from interface org.ametys.plugins.messagingconnector.MessagingConnector
ROLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncreateEvent(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 eventGet the list of population id allowed to the messaging connectorgetAttendees(String eventId, UserIdentity organiser) Get the map of attendees for an eventgetEvents(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 eventsgetFreeBusy(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 usergetUnreadEmails(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 connectorvoidprotected 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 userbooleanTell 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 Details
-
_userPopulationDAO
The user population DAO -
_userPref
The user preferences -
_cryptoHelper
The crypto helper -
_currentUserProvider
The current user provider -
_cacheManager
CacheManager used to create and get cache
-
-
Constructor Details
-
AbstractMessagingConnector
public AbstractMessagingConnector()
-
-
Method Details
-
service
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
initialize
- Specified by:
initializein interfaceInitializable
-
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
- Throws:
MessagingConnectorException- if failed to get populations
-
isAllowed
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
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
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
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
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 MessagingConnectorExceptionDescription 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 MessagingConnectorExceptionCreate 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 MessagingConnectorExceptionDescription 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 MessagingConnectorExceptionUpdate 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
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 MessagingConnectorExceptionDescription 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 MessagingConnectorExceptionSet 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
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
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
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
-