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_userManagerThe 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.ExchangeServicegetService(UserIdentity userIdentity)Get the service of connexion to the server exchangeprotected static Stringhtml2text(String html)Converts a given html String into a plain text StringStringinternalCreateEvent(String title, String description, String place, boolean isAllDay, Date startDate, Date endDate, EventRecurrenceTypeEnum recurrenceType, Date untilDate, Map<String,Boolean> attendees, UserIdentity organiser)Create an eventvoidinternalDeleteEvent(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 intinternalGetEmailsCount(UserIdentity userIdentity)Get emails count (no caching)protected List<CalendarEvent>internalGetEvents(UserIdentity userIdentity, int maxDays, int maxEvents)Get upcoming events (no caching)protected intinternalGetEventsCount(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 windowbooleaninternalIsEventExist(String eventId, UserIdentity organiser)True if the event exist in the messaging connectorvoidinternalSetAttendees(String eventId, Map<String,Boolean> attendees, UserIdentity organiser)Set attendees for an eventvoidinternalUpdateEvent(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 eventbooleanisUserExist(UserIdentity userIdentity)True if the user existvoidservice(ServiceManager manager)booleansupportInvitation()Tell if the messaging connector supports event invitationbooleansupportUserCredential()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:
servicein interfaceServiceable- Overrides:
servicein 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:MessagingConnectorCheck if a user credential should be saved- Specified by:
supportUserCredentialin interfaceMessagingConnector- Overrides:
supportUserCredentialin 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:AbstractMessagingConnectorGet upcoming events (no caching)- Specified by:
internalGetEventsin 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:AbstractMessagingConnectorGet upcoming events count (no caching)- Specified by:
internalGetEventsCountin 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:AbstractMessagingConnectorGet emails (no caching)- Specified by:
internalGetEmailsin 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:AbstractMessagingConnectorGet emails count (no caching)- Specified by:
internalGetEmailsCountin 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:MessagingConnectorTell if the messaging connector supports event invitation- Specified by:
supportInvitationin interfaceMessagingConnector- Overrides:
supportInvitationin 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:AbstractMessagingConnectorTrue if the event exist in the messaging connector- Overrides:
internalIsEventExistin 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:AbstractMessagingConnectorCreate an event- Overrides:
internalCreateEventin 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:AbstractMessagingConnectorUpdate an event- Overrides:
internalUpdateEventin 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:AbstractMessagingConnectorDelete an event- Overrides:
internalDeleteEventin 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:AbstractMessagingConnectorGet the map of attendees for an event- Overrides:
internalGetAttendeesin 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:AbstractMessagingConnectorSet attendees for an event- Overrides:
internalSetAttendeesin 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:AbstractMessagingConnectorGet free/busy status for attendees for a time window- Overrides:
internalGetFreeBusyin 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:MessagingConnectorTrue if the user exist- Specified by:
isUserExistin interfaceMessagingConnector- Overrides:
isUserExistin 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
-
-