Skip to content

Commit

Permalink
fix: synchronize location, description and web conf URL - EXO-62884 (#…
Browse files Browse the repository at this point in the history
…119)

The fix will add location, description and web conferencing call URL to the event pushed to MS Exchange.

The properties location, description and web conferencing URL were not synchronized with Exchange, the fix will add them to the object sent when synchronizing.
  • Loading branch information
ahamdi committed Oct 31, 2024
1 parent 0925f3c commit b2c551a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
import java.time.format.TextStyle;
import java.util.*;

import microsoft.exchange.webservices.data.core.enumeration.property.BodyType;
import microsoft.exchange.webservices.data.core.enumeration.property.time.DayOfTheWeek;
import microsoft.exchange.webservices.data.core.enumeration.property.time.Month;
import microsoft.exchange.webservices.data.core.exception.misc.ArgumentOutOfRangeException;
import microsoft.exchange.webservices.data.property.complex.MessageBody;
import microsoft.exchange.webservices.data.property.complex.recurrence.pattern.Recurrence;
import org.apache.commons.lang3.StringUtils;
import org.exoplatform.agenda.model.Event;
Expand All @@ -33,6 +35,7 @@
import org.exoplatform.agenda.service.AgendaEventService;
import org.exoplatform.agenda.service.AgendaRemoteEventService;
import org.exoplatform.agenda.util.AgendaDateUtils;
import org.exoplatform.agenda.util.NotificationUtils;
import org.exoplatform.agendaconnector.model.ExchangeUserSetting;
import org.exoplatform.agendaconnector.storage.ExchangeConnectorStorage;
import org.exoplatform.agendaconnector.utils.ExchangeConnectorUtils;
Expand All @@ -59,13 +62,13 @@

public class ExchangeConnectorServiceImpl implements ExchangeConnectorService {

private ExchangeConnectorStorage exchangeConnectorStorage;
private ExchangeConnectorStorage exchangeConnectorStorage;

private AgendaRemoteEventService agendaRemoteEventService;
private AgendaRemoteEventService agendaRemoteEventService;

private AgendaEventService agendaEventService;
private AgendaEventService agendaEventService;

private static final Log LOG = ExoLogger.getLogger(ExchangeConnectorServiceImpl.class);
private static final Log LOG = ExoLogger.getLogger(ExchangeConnectorServiceImpl.class);


public ExchangeConnectorServiceImpl(ExchangeConnectorStorage exchangeConnectorStorage,
Expand Down Expand Up @@ -179,6 +182,7 @@ public List<EventEntity> getExchangeEvents(long userIdentityId,
@Override
public void pushEventToExchange(long userIdentityId, EventEntity event, ZoneId userTimeZone) throws IllegalAccessException {
ExchangeUserSetting exchangeUserSetting = getExchangeSetting(userIdentityId);
Event eventOneXo = agendaEventService.getEventById(event.getId());
try (ExchangeService exchangeService = ExchangeConnectorUtils.connectExchangeServer(exchangeUserSetting)) {
RemoteEvent remoteEvent = agendaRemoteEventService.findRemoteEvent(event.getId(), userIdentityId);
if (remoteEvent == null) {
Expand All @@ -188,6 +192,12 @@ public void pushEventToExchange(long userIdentityId, EventEntity event, ZoneId u
ZonedDateTime endDate = AgendaDateUtils.parseRFC3339ToZonedDateTime(event.getEnd(), userTimeZone);
appointment.setStart(AgendaDateUtils.toDate(startDate));
appointment.setEnd(AgendaDateUtils.toDate(endDate));
appointment.setLocation(event.getLocation());
appointment.setBody(new MessageBody(BodyType.HTML, event.getDescription()));
String webConferenceURL = NotificationUtils.getWebConferenceLink(eventOneXo);
if(StringUtils.isNotBlank(webConferenceURL)) {
appointment.setMeetingWorkspaceUrl(webConferenceURL);
}
appointment.setRecurrence(getEventRecurrence(event.getId()));
appointment.save(new FolderId(WellKnownFolderName.Calendar), SendInvitationsMode.SendToAllAndSaveCopy);
remoteEvent = new RemoteEvent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
import java.util.Collections;
import java.util.List;

import org.apache.ecs.html.Col;
import org.exoplatform.agenda.constant.EventRecurrenceFrequency;
import org.exoplatform.agenda.constant.EventRecurrenceType;
import org.exoplatform.agenda.model.Event;
import org.exoplatform.agenda.model.EventRecurrence;
import org.exoplatform.agenda.service.AgendaEventService;
import org.exoplatform.agenda.util.NotificationUtils;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -45,7 +45,7 @@
import microsoft.exchange.webservices.data.search.filter.SearchFilter;

@RunWith(PowerMockRunner.class)
@PrepareForTest({ ExchangeConnectorUtils.class, ExchangeService.class })
@PrepareForTest({ ExchangeConnectorUtils.class, ExchangeService.class, NotificationUtils.class })
public class ExchangeConnectorServiceImplTest {

private ExchangeConnectorServiceImpl exchangeConnectorService;
Expand All @@ -68,6 +68,7 @@ public void setUp() throws Exception {
exchangeConnectorService = new ExchangeConnectorServiceImpl(exchangeConnectorStorage,
agendaRemoteEventService,
agendaEventService);
PowerMockito.mockStatic(NotificationUtils.class);
}

@Test
Expand Down Expand Up @@ -103,7 +104,7 @@ public void testCreateExchangeEvent() throws Exception {

when(agendaRemoteEventService.findRemoteEvent(1, 1)).thenReturn(null);
when(exchangeService.getRequestedServerVersion()).thenReturn(ExchangeVersion.Exchange2010_SP2);

// When
EventEntity eventEntity = new EventEntity();
eventEntity.setId(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ export default {
const exchangeEvent = {
id: event.id,
summary: event.summary,
description: event.description,
location: event.location,
conferences: event.conferences,
start: event.start,
end: event.end,
remoteProviderName: this.name,
Expand Down

0 comments on commit b2c551a

Please sign in to comment.