Exemplo n.º 1
1
  protected static List<CalendarBooking> filterCalendarBookings(
      List<CalendarBooking> calendarBookings, PermissionChecker permissionChecker, String actionId)
      throws PortalException, SystemException {

    calendarBookings = ListUtil.copy(calendarBookings);

    Iterator<CalendarBooking> itr = calendarBookings.iterator();

    while (itr.hasNext()) {
      CalendarBooking calendarBooking = itr.next();

      if (!CalendarPermission.contains(
          permissionChecker, calendarBooking.getCalendarId(), ACTION_VIEW_BOOKING_DETAILS)) {

        if (!CalendarPermission.contains(
            permissionChecker, calendarBooking.getCalendarId(), actionId)) {

          itr.remove();
        } else {
          filterCalendarBooking(calendarBooking, permissionChecker);
        }
      }
    }

    return calendarBookings;
  }
Exemplo n.º 2
1
  public CalendarBooking getCalendarBooking(long calendarId, long parentCalendarBookingId)
      throws PortalException, SystemException {

    CalendarPermission.check(getPermissionChecker(), calendarId, ActionKeys.MANAGE_BOOKINGS);

    return calendarBookingLocalService.getCalendarBooking(calendarId, parentCalendarBookingId);
  }
Exemplo n.º 3
1
  public static List<Calendar> getAllCalendars(PermissionChecker permissionChecker)
      throws PortalException, SystemException {

    List<Calendar> calendars = new ArrayList<Calendar>();

    calendars = new ArrayList<Calendar>();

    if (PortletPropsValues.PROPFIND_PROVIDE_SESSIONCLICKS_CALENDARS) {
      calendars.addAll(getUserCalendars(permissionChecker.getUserId()));

      calendars.addAll(getUserGroupCalendars(permissionChecker));

      calendars.addAll(getSelectedCalendars(permissionChecker.getUserId()));
    } else {
      List<Calendar> allCalendars =
          CalendarLocalServiceUtil.getCalendars(QueryUtil.ALL_POS, QueryUtil.ALL_POS);

      for (Calendar calendar : allCalendars) {
        if (CalendarPermission.contains(permissionChecker, calendar, ActionKeys.VIEW)) {

          calendars.add(calendar);
        }
      }
    }

    return calendars;
  }
  @Override
  public Calendar getCalendar(long calendarId) throws PortalException, SystemException {

    CalendarPermission.check(getPermissionChecker(), calendarId, ActionKeys.VIEW);

    return calendarLocalService.getCalendar(calendarId);
  }
Exemplo n.º 5
1
  public static List<Calendar> getUserGroupCalendars(PermissionChecker permissionChecker)
      throws PortalException, SystemException {

    List<Calendar> calendars = new ArrayList<Calendar>();

    long classNameId = PortalUtil.getClassNameId(Group.class.getName());

    List<CalendarResource> calendarResources =
        CalendarResourceServiceUtil.search(
            permissionChecker.getCompanyId(),
            new long[] {},
            new long[] {classNameId},
            null,
            true,
            true,
            QueryUtil.ALL_POS,
            QueryUtil.ALL_POS,
            null);

    for (CalendarResource calendarResource : calendarResources) {
      for (Calendar calendar : calendarResource.getCalendars()) {
        if (CalendarPermission.contains(permissionChecker, calendar, ActionKeys.VIEW)) {

          calendars.add(calendar);
        }
      }
    }

    return calendars;
  }
Exemplo n.º 6
0
  public CalendarBooking addCalendarBooking(
      long calendarId,
      Map<Locale, String> titleMap,
      Map<Locale, String> descriptionMap,
      String location,
      Date startDate,
      Date endDate,
      boolean allDay,
      String recurrence,
      int firstReminder,
      int secondReminder,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    CalendarPermission.check(getPermissionChecker(), calendarId, ActionKeys.MANAGE_BOOKINGS);

    return calendarBookingLocalService.addCalendarBooking(
        getUserId(),
        calendarId,
        titleMap,
        descriptionMap,
        location,
        startDate,
        endDate,
        allDay,
        recurrence,
        firstReminder,
        secondReminder,
        serviceContext);
  }
  @Override
  public Calendar updateColor(long calendarId, int color, ServiceContext serviceContext)
      throws PortalException, SystemException {

    CalendarPermission.check(getPermissionChecker(), calendarId, ActionKeys.UPDATE);

    return calendarLocalService.updateColor(calendarId, color, serviceContext);
  }
  @Override
  public boolean hasPermission(
      PermissionChecker permissionChecker,
      String entryClassName,
      long entryClassPK,
      String actionId)
      throws Exception {

    return CalendarPermission.contains(permissionChecker, entryClassPK, ActionKeys.VIEW);
  }
Exemplo n.º 9
0
  public CalendarBooking deleteCalendarBooking(long calendarBookingId)
      throws PortalException, SystemException {

    CalendarBooking calendarBooking =
        calendarBookingPersistence.findByPrimaryKey(calendarBookingId);

    CalendarPermission.check(
        getPermissionChecker(), calendarBooking.getCalendarId(), ActionKeys.MANAGE_BOOKINGS);

    return calendarBookingLocalService.deleteCalendarBooking(calendarBookingId);
  }
Exemplo n.º 10
0
  protected CalendarBooking filterCalendarBooking(CalendarBooking calendarBooking)
      throws PortalException, SystemException {

    if (!CalendarPermission.contains(
        getPermissionChecker(), calendarBooking.getCalendarId(), ActionKeys.VIEW_BOOKING_DETAILS)) {

      calendarBooking.setTitle(StringPool.BLANK);
      calendarBooking.setDescription(StringPool.BLANK);
      calendarBooking.setLocation(StringPool.BLANK);
    }

    return calendarBooking;
  }
Exemplo n.º 11
0
  public void invokeTransition(
      long calendarBookingId, String transitionName, ServiceContext serviceContext)
      throws PortalException, SystemException {

    CalendarBooking calendarBooking =
        calendarBookingPersistence.findByPrimaryKey(calendarBookingId);

    CalendarPermission.check(
        getPermissionChecker(), calendarBooking.getCalendarId(), ActionKeys.MANAGE_BOOKINGS);

    calendarBookingApprovalWorkflow.invokeTransition(
        getUserId(), calendarBookingId, transitionName, serviceContext);
  }
  @Override
  public Calendar fetchCalendar(long calendarId) throws PortalException, SystemException {

    Calendar calendar = calendarPersistence.fetchByPrimaryKey(calendarId);

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

    CalendarPermission.check(getPermissionChecker(), calendar, ActionKeys.VIEW);

    return calendar;
  }
  @Override
  public Calendar updateCalendar(
      long calendarId,
      Map<Locale, String> nameMap,
      Map<Locale, String> descriptionMap,
      int color,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    CalendarPermission.check(getPermissionChecker(), calendarId, ActionKeys.UPDATE);

    return calendarLocalService.updateCalendar(
        calendarId, nameMap, descriptionMap, color, serviceContext);
  }
Exemplo n.º 14
0
  protected static CalendarBooking filterCalendarBooking(
      CalendarBooking calendarBooking, PermissionChecker permissionChecker)
      throws PortalException, SystemException {

    if (!CalendarPermission.contains(
        permissionChecker, calendarBooking.getCalendarId(), ACTION_VIEW_BOOKING_DETAILS)) {

      calendarBooking.setTitle(StringPool.BLANK);
      calendarBooking.setDescription(StringPool.BLANK);
      calendarBooking.setLocation(StringPool.BLANK);
    }

    return calendarBooking;
  }
  @Override
  public boolean hasPermission(PermissionChecker permissionChecker, long classPK, String actionId)
      throws Exception {

    CalendarBooking calendarBooking = _calendarBookingLocalService.getCalendarBooking(classPK);

    if (actionId.equals(ActionKeys.DELETE) || actionId.equals(ActionKeys.UPDATE)) {

      actionId = CalendarActionKeys.MANAGE_BOOKINGS;
    }

    return CalendarPermission.contains(
        permissionChecker, calendarBooking.getCalendarId(), actionId);
  }
  protected List<Calendar> filterCalendars(List<Calendar> calendars, String actionId)
      throws PrincipalException {

    calendars = ListUtil.copy(calendars);

    Iterator<Calendar> itr = calendars.iterator();

    while (itr.hasNext()) {
      Calendar calendar = itr.next();

      if (!CalendarPermission.contains(getPermissionChecker(), calendar, actionId)) {

        itr.remove();
      }
    }

    return calendars;
  }
  @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);
  }