Package org.ametys.plugins.exchange
Class ExchangeConnector
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.messagingconnector.AbstractMessagingConnector
-
- org.ametys.plugins.exchange.ExchangeConnector
-
- All Implemented Interfaces:
MessagingConnector
,LogEnabled
,Initializable
,Component
,Serviceable
public class ExchangeConnector extends AbstractMessagingConnector
The connector used by the messaging connector plugin when the exchange mail server is used. Implements the methods of the MessagingConnector interface in order to get the informations from the mail server
-
-
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 private UserManager
_userManager
The user manager-
Fields inherited from class org.ametys.plugins.messagingconnector.AbstractMessagingConnector
_cryptoHelper, _currentUserProvider, _userPopulationDAO, _userPref
-
Fields inherited from interface org.ametys.plugins.messagingconnector.MessagingConnector
ROLE
-
-
Constructor Summary
Constructors Constructor Description ExchangeConnector()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private MessagingConnectorException.ExceptionType
_getExceptionType(Throwable exception)
get the type of exception from the Throwableprivate microsoft.exchange.webservices.data.core.ExchangeService
_getImpersonatedService(UserIdentity userIdentity)
private MessagingConnector.ResponseType
_getResponseStatus(microsoft.exchange.webservices.data.core.enumeration.property.MeetingResponseType meetingResponseType)
private microsoft.exchange.webservices.data.core.ExchangeService
_getSimpleService(UserIdentity userIdentity)
private microsoft.exchange.webservices.data.core.ExchangeService
_initService(String userName, String password)
private void
_setAttendees(microsoft.exchange.webservices.data.core.service.item.Appointment appointment, Map<String,Boolean> attendees)
private void
_setDataEvent(microsoft.exchange.webservices.data.core.ExchangeService service, microsoft.exchange.webservices.data.core.service.item.Appointment appointment, String title, String description, String place, boolean isAllDay, Date startDate, Date endDate, EventRecurrenceTypeEnum recurrenceType, Date untilDate, Map<String,Boolean> attendees)
private void
_setRecurrence(microsoft.exchange.webservices.data.core.service.item.Appointment appointment, Date startDate, EventRecurrenceTypeEnum recurrenceType, Date untilDate)
protected microsoft.exchange.webservices.data.core.ExchangeService
getService(UserIdentity userIdentity)
Get the service of connexion to the server exchangeprotected static String
html2text(String html)
Converts a given html String into a plain text StringString
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 eventvoid
internalDeleteEvent(String eventId, UserIdentity organiser)
Delete an eventMap<String,MessagingConnector.AttendeeInformation>
internalGetAttendees(String eventId, UserIdentity organiser)
Get the map of attendees for an eventprotected List<EmailMessage>
internalGetEmails(UserIdentity userIdentity, int maxEmails)
Get emails (no caching)protected int
internalGetEmailsCount(UserIdentity userIdentity)
Get emails count (no caching)protected List<CalendarEvent>
internalGetEvents(UserIdentity userIdentity, int maxDays, int maxEvents)
Get upcoming events (no caching)protected int
internalGetEventsCount(UserIdentity userIdentity, int maxDays)
Get upcoming events count (no caching)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 windowboolean
internalIsEventExist(String eventId, UserIdentity organiser)
True if the event exist in the messaging connectorvoid
internalSetAttendees(String eventId, Map<String,Boolean> attendees, UserIdentity organiser)
Set attendees for an eventvoid
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 eventboolean
isUserExist(UserIdentity userIdentity)
True if the user existvoid
service(ServiceManager manager)
boolean
supportInvitation()
Tell if the messaging connector supports event invitationboolean
supportUserCredential()
Check if a user credential should be saved-
Methods inherited from class org.ametys.plugins.messagingconnector.AbstractMessagingConnector
createEvent, deleteEvent, getAllowedPopulationIds, getAttendees, getEvents, getEventsCount, getFreeBusy, getUnreadEmailCount, getUnreadEmails, getUserCryptedPassword, getUserPassword, initialize, isAllowed, isEventExist, setAttendees, setUserPassword, updateEvent, userCredentialNeeded
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
_userManager
private UserManager _userManager
The user manager
-
-
Constructor Detail
-
ExchangeConnector
public ExchangeConnector()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
service
in interfaceServiceable
- Overrides:
service
in classAbstractMessagingConnector
- Throws:
ServiceException
-
getService
protected microsoft.exchange.webservices.data.core.ExchangeService getService(UserIdentity userIdentity) throws URISyntaxException
Get the service of connexion to the server exchange- Parameters:
userIdentity
- The user identity- Returns:
- the service
- Throws:
URISyntaxException
- if an error occurred
-
supportUserCredential
public boolean supportUserCredential()
Description copied from interface:MessagingConnector
Check if a user credential should be saved- Specified by:
supportUserCredential
in interfaceMessagingConnector
- Overrides:
supportUserCredential
in classAbstractMessagingConnector
- Returns:
- true if this implementation supports user credential (and is configured to use them)
-
_getSimpleService
private microsoft.exchange.webservices.data.core.ExchangeService _getSimpleService(UserIdentity userIdentity)
-
_getImpersonatedService
private microsoft.exchange.webservices.data.core.ExchangeService _getImpersonatedService(UserIdentity userIdentity)
-
_initService
private microsoft.exchange.webservices.data.core.ExchangeService _initService(String userName, String password)
-
internalGetEvents
protected List<CalendarEvent> internalGetEvents(UserIdentity userIdentity, int maxDays, int maxEvents) throws MessagingConnectorException
Description copied from class:AbstractMessagingConnector
Get upcoming events (no caching)- Specified by:
internalGetEvents
in classAbstractMessagingConnector
- 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 int internalGetEventsCount(UserIdentity userIdentity, int maxDays) throws MessagingConnectorException
Description copied from class:AbstractMessagingConnector
Get upcoming events count (no caching)- Specified by:
internalGetEventsCount
in classAbstractMessagingConnector
- 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 List<EmailMessage> internalGetEmails(UserIdentity userIdentity, int maxEmails) throws MessagingConnectorException
Description copied from class:AbstractMessagingConnector
Get emails (no caching)- Specified by:
internalGetEmails
in classAbstractMessagingConnector
- Parameters:
userIdentity
- The user identitymaxEmails
- The maximum number of emails to retrieve- Returns:
- The emails
- Throws:
MessagingConnectorException
- if failed to get events from server
-
internalGetEmailsCount
protected int internalGetEmailsCount(UserIdentity userIdentity) throws MessagingConnectorException
Description copied from class:AbstractMessagingConnector
Get emails count (no caching)- Specified by:
internalGetEmailsCount
in classAbstractMessagingConnector
- 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:MessagingConnector
Tell if the messaging connector supports event invitation- Specified by:
supportInvitation
in interfaceMessagingConnector
- Overrides:
supportInvitation
in classAbstractMessagingConnector
- Returns:
- true if the messaging connector supports event invitation
- Throws:
MessagingConnectorException
- if failed to get events from server
-
internalIsEventExist
public boolean internalIsEventExist(String eventId, UserIdentity organiser) throws MessagingConnectorException
Description copied from class:AbstractMessagingConnector
True if the event exist in the messaging connector- Overrides:
internalIsEventExist
in classAbstractMessagingConnector
- Parameters:
eventId
- the event idorganiser
- the organiser- Returns:
- true if the event exist
- Throws:
MessagingConnectorException
- if an error occurred
-
internalCreateEvent
public 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
Description copied from class:AbstractMessagingConnector
Create an event- Overrides:
internalCreateEvent
in classAbstractMessagingConnector
- 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
-
internalUpdateEvent
public 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
Description copied from class:AbstractMessagingConnector
Update an event- Overrides:
internalUpdateEvent
in classAbstractMessagingConnector
- 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
-
_setDataEvent
private void _setDataEvent(microsoft.exchange.webservices.data.core.ExchangeService service, microsoft.exchange.webservices.data.core.service.item.Appointment appointment, String title, String description, String place, boolean isAllDay, Date startDate, Date endDate, EventRecurrenceTypeEnum recurrenceType, Date untilDate, Map<String,Boolean> attendees) throws Exception
- Throws:
Exception
-
_setRecurrence
private void _setRecurrence(microsoft.exchange.webservices.data.core.service.item.Appointment appointment, Date startDate, EventRecurrenceTypeEnum recurrenceType, Date untilDate) throws Exception
- Throws:
Exception
-
internalDeleteEvent
public void internalDeleteEvent(String eventId, UserIdentity organiser) throws MessagingConnectorException
Description copied from class:AbstractMessagingConnector
Delete an event- Overrides:
internalDeleteEvent
in classAbstractMessagingConnector
- Parameters:
eventId
- the event id to deleteorganiser
- the event organiser- Throws:
MessagingConnectorException
- if failed to get events from server
-
internalGetAttendees
public Map<String,MessagingConnector.AttendeeInformation> internalGetAttendees(String eventId, UserIdentity organiser) throws MessagingConnectorException
Description copied from class:AbstractMessagingConnector
Get the map of attendees for an event- Overrides:
internalGetAttendees
in classAbstractMessagingConnector
- 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
-
internalSetAttendees
public void internalSetAttendees(String eventId, Map<String,Boolean> attendees, UserIdentity organiser) throws MessagingConnectorException
Description copied from class:AbstractMessagingConnector
Set attendees for an event- Overrides:
internalSetAttendees
in classAbstractMessagingConnector
- 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
-
internalGetFreeBusy
public Map<String,MessagingConnector.FreeBusyStatus> internalGetFreeBusy(Date startDate, Date endDate, boolean isAllDay, Set<String> attendees, UserIdentity organiser) throws MessagingConnectorException
Description copied from class:AbstractMessagingConnector
Get free/busy status for attendees for a time window- Overrides:
internalGetFreeBusy
in classAbstractMessagingConnector
- 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
-
isUserExist
public boolean isUserExist(UserIdentity userIdentity) throws MessagingConnectorException
Description copied from interface:MessagingConnector
True if the user exist- Specified by:
isUserExist
in interfaceMessagingConnector
- Overrides:
isUserExist
in classAbstractMessagingConnector
- Parameters:
userIdentity
- the user identity- Returns:
- true if the user exist
- Throws:
MessagingConnectorException
- if failed to get events from server
-
_getResponseStatus
private MessagingConnector.ResponseType _getResponseStatus(microsoft.exchange.webservices.data.core.enumeration.property.MeetingResponseType meetingResponseType)
-
_setAttendees
private void _setAttendees(microsoft.exchange.webservices.data.core.service.item.Appointment appointment, Map<String,Boolean> attendees) throws Exception
- Throws:
Exception
-
html2text
protected static String html2text(String html)
Converts a given html String into a plain text String- Parameters:
html
- the html String that will be converted- Returns:
- a String plain text of the given html
-
_getExceptionType
private MessagingConnectorException.ExceptionType _getExceptionType(Throwable exception)
get the type of exception from the Throwable- Parameters:
exception
- exception thrown by Exchange API- Returns:
MessagingConnectorException.ExceptionType
-
-