@Override
  public PortletURL getURLAdd(
      LiferayPortletRequest liferayPortletRequest,
      LiferayPortletResponse liferayPortletResponse,
      long classTypeId)
      throws PortalException {

    ThemeDisplay themeDisplay =
        (ThemeDisplay) liferayPortletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    CalendarResource calendarResource =
        CalendarResourceUtil.getScopeGroupCalendarResource(
            liferayPortletRequest, themeDisplay.getScopeGroupId());

    if (calendarResource == null) {
      return null;
    }

    PortletURL portletURL =
        PortalUtil.getControlPanelPortletURL(
            liferayPortletRequest, CalendarPortletKeys.CALENDAR, PortletRequest.RENDER_PHASE);

    portletURL.setParameter("mvcPath", "/edit_calendar_booking.jsp");

    Calendar calendar = calendarResource.getDefaultCalendar();

    portletURL.setParameter("calendarId", String.valueOf(calendar.getCalendarId()));

    return portletURL;
  }
  protected CalendarResource getCalendarResource(long companyId, long groupId)
      throws PortalException, SystemException {

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setCompanyId(companyId);

    long userId = UserLocalServiceUtil.getDefaultUserId(companyId);

    serviceContext.setUserId(userId);

    Group group = groupLocalService.getGroup(groupId);

    if (group.isUser()) {
      return CalendarResourceUtil.getUserCalendarResource(group.getCreatorUserId(), serviceContext);
    }

    return CalendarResourceUtil.getGroupCalendarResource(groupId, serviceContext);
  }
  @Override
  public boolean hasAddPermission(
      PermissionChecker permissionChecker, long groupId, long classTypeId) throws Exception {

    ServiceContext serviceContext = new ServiceContext();

    serviceContext.setCompanyId(permissionChecker.getCompanyId());

    CalendarResource calendarResource =
        CalendarResourceUtil.getScopeGroupCalendarResource(groupId, serviceContext);

    if (calendarResource == null) {
      return false;
    }

    Calendar calendar = calendarResource.getDefaultCalendar();

    return CalendarPermission.contains(
        permissionChecker, calendar.getCalendarId(), CalendarActionKeys.MANAGE_BOOKINGS);
  }