Beispiel #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;
  }
  public CalendarBooking updateCalendarBooking(
      long userId,
      long calendarBookingId,
      long calendarId,
      Map<Locale, String> titleMap,
      Map<Locale, String> descriptionMap,
      String location,
      long startDate,
      long endDate,
      boolean allDay,
      String recurrence,
      long firstReminder,
      String firstReminderType,
      long secondReminder,
      String secondReminderType,
      int status,
      ServiceContext serviceContext)
      throws PortalException, SystemException {

    CalendarBooking calendarBooking =
        calendarBookingPersistence.findByPrimaryKey(calendarBookingId);

    List<CalendarBooking> childCalendarBookings =
        calendarBookingPersistence.findByParentCalendarBookingId(calendarBookingId);

    long[] childCalendarIds = new long[childCalendarBookings.size()];

    for (int i = 0; i < childCalendarIds.length; i++) {
      CalendarBooking childCalendarBooking = childCalendarBookings.get(i);

      if (childCalendarBooking.getCalendarId() == calendarBooking.getCalendarId()) {

        childCalendarIds[i] = calendarId;
      } else {
        childCalendarIds[i] = childCalendarBooking.getCalendarId();
      }
    }

    return updateCalendarBooking(
        userId,
        calendarBookingId,
        calendarId,
        childCalendarIds,
        titleMap,
        descriptionMap,
        location,
        startDate,
        endDate,
        allDay,
        recurrence,
        firstReminder,
        firstReminderType,
        secondReminder,
        secondReminderType,
        status,
        serviceContext);
  }
  protected void addChildCalendarBookings(
      CalendarBooking calendarBooking, long[] childCalendarIds, ServiceContext serviceContext)
      throws PortalException, SystemException {

    if (!calendarBooking.isMasterBooking()) {
      return;
    }

    List<CalendarBooking> childCalendarBookings =
        calendarBookingPersistence.findByParentCalendarBookingId(
            calendarBooking.getCalendarBookingId());

    for (CalendarBooking childCalendarBooking : childCalendarBookings) {
      if (childCalendarBooking.isMasterBooking()
          || ArrayUtil.contains(childCalendarIds, childCalendarBooking.getCalendarId())) {

        continue;
      }

      deleteCalendarBooking(childCalendarBooking.getCalendarBookingId());
    }

    for (long calendarId : childCalendarIds) {
      int count =
          calendarBookingPersistence.countByC_P(calendarId, calendarBooking.getCalendarBookingId());

      if (count > 0) {
        continue;
      }

      CalendarBooking childCalendarBooking =
          addCalendarBooking(
              calendarBooking.getUserId(),
              calendarId,
              new long[0],
              calendarBooking.getCalendarBookingId(),
              calendarBooking.getTitleMap(),
              calendarBooking.getDescriptionMap(),
              calendarBooking.getLocation(),
              calendarBooking.getStartDate(),
              calendarBooking.getEndDate(),
              calendarBooking.getAllDay(),
              calendarBooking.getRecurrence(),
              calendarBooking.getFirstReminder(),
              calendarBooking.getFirstReminderType(),
              calendarBooking.getSecondReminder(),
              calendarBooking.getSecondReminderType(),
              serviceContext);

      try {
        NotificationType notificationType =
            NotificationType.parse(PortletPropsValues.CALENDAR_NOTIFICATION_DEFAULT_TYPE);

        NotificationUtil.notifyCalendarBookingInvites(childCalendarBooking, notificationType);
      } catch (Exception e) {
      }
    }
  }
Beispiel #4
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);
  }
Beispiel #5
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;
  }
Beispiel #6
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);
  }
Beispiel #7
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);
  }