Skip to content

Instantly share code, notes, and snippets.

@eduardolundgren
Created November 29, 2012 18:13
Show Gist options
  • Save eduardolundgren/4170873 to your computer and use it in GitHub Desktop.
Save eduardolundgren/4170873 to your computer and use it in GitHub Desktop.
protected void addCalendarJSONObject(
PortletRequest portletRequest, JSONArray jsonArray,
long classNameId, long classPK, String permissionAction)
throws PortalException, SystemException {
CalendarResource calendarResource =
CalendarResourceUtil.getCalendarResource(
portletRequest, classNameId, classPK);
if (calendarResource == null) {
return;
}
ThemeDisplay themeDisplay = (ThemeDisplay)portletRequest.getAttribute(
WebKeys.THEME_DISPLAY);
PermissionChecker permissionChecker =
themeDisplay.getPermissionChecker();
List<Calendar> calendars =
CalendarLocalServiceUtil.getCalendarResourceCalendars(
calendarResource.getGroupId(),
calendarResource.getCalendarResourceId());
for (Calendar calendar : calendars) {
if (Validator.isNotNull(permissionAction) &&
!CalendarPermission.contains(
permissionChecker, calendar, permissionAction)) {
continue;
}
JSONObject jsonObject = CalendarUtil.toCalendarJSONObject(
themeDisplay, calendar);
jsonArray.put(jsonObject);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment