Skip to content

Commit

Permalink
issue #75:
Browse files Browse the repository at this point in the history
if calendarResource isn't a user instead of throwing nullPointerException it will use the default language of the calendar
  • Loading branch information
Diego De Mattia committed Oct 24, 2023
1 parent 1a51096 commit 4a3f785
Showing 1 changed file with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public void afterContentImported(String ics, Calendar calendar)

if (calendarBooking != null) {
updateBookingAttendees(calendarBooking, vEvent);
updateAltDescription(calendarBooking, vEvent);
updateAltDescription(calendarBooking, vEvent, calendar);

long userId = PrincipalThreadLocal.getUserId();

Expand Down Expand Up @@ -226,7 +226,7 @@ public String beforeContentImported(String ics, Calendar calendar)
_calendarBookingLocalService.fetchCalendarBooking(
calendar.getCalendarId(), vEventUidValue);

updateAltDescription(calendarBooking, vEvent);
updateAltDescription(calendarBooking, vEvent, calendar);
}
}
}
Expand Down Expand Up @@ -455,7 +455,7 @@ protected void updateAllDayDateExport(
}

protected void updateAltDescription(
CalendarBooking calendarBooking, VEvent vEvent)
CalendarBooking calendarBooking, VEvent vEvent, Calendar calendar)
throws PortalException {

XProperty vEventXAltDesc = (XProperty)vEvent.getProperty("X-ALT-DESC");
Expand All @@ -466,8 +466,10 @@ protected void updateAltDescription(

if (calendarBooking != null) {
User calendarBookingUser = getCalendarBookingUser(calendarBooking);

Locale locale = calendarBookingUser.getLocale();

Locale locale = Validator.isNotNull(calendarBookingUser) ?
calendarBookingUser.getLocale() :
LocaleUtil.fromLanguageId(calendar.getDefaultLanguageId());

String calendarBookingDescription = calendarBooking.getDescription(
locale);
Expand Down

0 comments on commit 4a3f785

Please sign in to comment.