@Override protected void afterUpdate(final TeamCalDO obj, final TeamCalDO dbObj) { super.afterUpdate(obj, dbObj); if (obj != null && dbObj != null && obj.isExternalSubscription() == true && StringUtils.equals(obj.getExternalSubscriptionUrl(), dbObj.getExternalSubscriptionUrl()) == false) { // only update if the url has changed! getTeamEventExternalSubscriptionCache().updateCache(obj); } // if calendar is present in subscription cache and is not an external subscription anymore -> cleanup! if (obj != null && obj.isExternalSubscription() == false && getTeamEventExternalSubscriptionCache().isExternalSubscribedCalendar(obj.getId())) { obj.setExternalSubscriptionCalendarBinary(null); obj.setExternalSubscriptionUrl(null); obj.setExternalSubscriptionUpdateInterval(null); obj.setExternalSubscriptionHash(null); getTeamEventExternalSubscriptionCache().updateCache(obj, true); } }
private boolean addReminders(PFUserDO user) if (teamCal.getOwnerId() != null && teamCal.getOwnerId().equals(user.getId()) == true) { return true; if (StringUtils.isBlank(teamCal.getFullAccessUserIds()) == false) { List<String> fullAccessUserIds = Arrays.asList(teamCal.getFullAccessUserIds().split(",")); if (fullAccessUserIds.contains(String.valueOf(user.getId()))) { return true; if (StringUtils.isBlank(teamCal.getReadonlyAccessUserIds()) == false) { List<String> readonlyAccessUserIds = Arrays.asList(teamCal.getReadonlyAccessUserIds().split(",")); if (readonlyAccessUserIds.contains(String.valueOf(user.getId()))) { return true; StringUtils.isBlank(teamCal.getFullAccessGroupIds()) == false ? Arrays.asList(teamCal.getFullAccessGroupIds().split(",")) : Collections.emptyList(); List<String> readonlyAccessGroupIds = StringUtils.isBlank(teamCal.getReadonlyAccessGroupIds()) == false ? Arrays.asList(teamCal.getReadonlyAccessGroupIds().split(",")) : Collections.emptyList(); for (Integer groupId : userGroupsIds) {
@Override public String getDisplayValue(final TeamCalDO teamCal) { return teamCal.getTitle(); }
fs.add(new Label(fs.newChildId(), data.getId())); if (data.getOwner() == null) { data.setOwner(getUser()); || ObjectUtils.equals(data.getOwnerId(), getUserId()) == true) { final UserSelectPanel userSelectPanel = new UserSelectPanel(fs.newChildId(), new PropertyModel<PFUserDO>(data, "owner"), parentPage, userSelectPanel.init(); } else { fs.add(new Label(fs.newChildId(), data.getOwner().getUsername() + "")); fsExternalSubscriptionUrl.getFieldset().setOutputMarkupId(true); fsExternalSubscriptionUrl.getFieldset().setOutputMarkupPlaceholderTag(true); fsExternalSubscriptionUrl.getFieldset().setVisible(data.isExternalSubscription() == true); fsExternalSubscriptionUrl.addHelpIcon(new ResourceModel("plugins.teamcal.externalsubscription.label.tooltip"), new ResourceModel( fsExternalSubscriptionInterval.getFieldset().setOutputMarkupId(true); fsExternalSubscriptionInterval.getFieldset().setOutputMarkupPlaceholderTag(true); fsExternalSubscriptionInterval.getFieldset().setVisible(data.isExternalSubscription() == true); final UsersProvider usersProvider = new UsersProvider(userDao); final Collection<PFUserDO> fullAccessUsers = new UsersProvider(userDao) .getSortedUsers(getData().getFullAccessUserIds()); fullAccessUsersListHelper = new MultiChoiceListHelper<PFUserDO>().setComparator(new UsersComparator()) .setFullList(
this.teamCalId = teamCalDO.getId(); currentInitializedHash = null; lastUpdated = null; String url = teamCalDO.getExternalSubscriptionUrl(); if (teamCalDO.isExternalSubscription() == false || StringUtils.isEmpty(url)) { final String displayUrl = teamCalDO.getExternalSubscriptionUrlAnonymized(); log.info("Getting subscribed calendar #" + teamCalDO.getId() + " from: " + displayUrl); byte[] bytes = null; try { + teamCalDO.getId() + " information, using database from url '" + displayUrl if (StringUtils.equals(md5, teamCalDO.getExternalSubscriptionHash()) == false) { teamCalDO.setExternalSubscriptionHash(md5); teamCalDO.setExternalSubscriptionCalendarBinary(bytes); bytes = teamCalDO.getExternalSubscriptionCalendarBinary(); error("Unable to gather subscription calendar #" + teamCalDO.getId() + " information, using database from url '" + displayUrl error("Unable to use database subscription calendar #" + teamCalDO.getId() + " information, quit from url '" + displayUrl + "'.", null);
protected Integer getCalendarId() { return calendar != null ? calendar.getId() : null; }
@Test public void testICalHandlerEventToDeleteNotFound() throws IOException { TeamCalDO calendar = new TeamCalDO(); calendar.setId(100); // delete -------------------------------------------------------------------------------------------------------------------- ICalHandler handler = eventService.getEventHandler(calendar); Assert.assertNotNull(handler); boolean result = handler.readICal(IOUtils.toString(this.getClass().getResourceAsStream("/ical/normal_delete.ics"), "UTF-8"), HandleMethod.CANCEL); Assert.assertTrue(result); Assert.assertEquals(1, handler.eventCount()); result = handler.validate(); Assert.assertTrue(result); final EventHandle handle = handler.getSingleEventHandles().get(0); Assert.assertEquals(1, handle.getWarnings().size()); Assert.assertEquals(EventHandleError.WARN_EVENT_TO_DELETE_NOT_FOUND, handle.getWarnings().get(0)); }
public static CalendarObject getCalendarObject(final TeamCalDO src, UserRightService userRights) { if (src == null) { return null; } final Integer userId = ThreadLocalUserContext.getUserId(); final CalendarObject cal = new CalendarObject(); DOConverter.copyFields(cal, src); cal.setTitle(src.getTitle()); cal.setDescription(src.getDescription()); cal.setExternalSubscription(src.isExternalSubscription()); final TeamCalRight right = (TeamCalRight) userRights.getRight(UserRightId.PLUGIN_CALENDAR); cal.setMinimalAccess(right.hasMinimalAccess(src, userId)); cal.setReadonlyAccess(right.hasReadonlyAccess(src, userId)); cal.setFullAccess(right.hasFullAccess(src, userId)); cal.setOwner(ObjectUtils.equals(userId, src.getOwnerId())); return cal; } }
@Override public AbstractSecuredBasePage onSaveOrUpdate() { teamCalDao.setFullAccessUsers(getData(), form.fullAccessUsersListHelper.getAssignedItems()); teamCalDao.setReadonlyAccessUsers(getData(), form.readonlyAccessUsersListHelper.getAssignedItems()); teamCalDao.setMinimalAccessUsers(getData(), form.minimalAccessUsersListHelper.getAssignedItems()); teamCalDao.setFullAccessGroups(getData(), form.fullAccessGroupsListHelper.getAssignedItems()); teamCalDao.setReadonlyAccessGroups(getData(), form.readonlyAccessGroupsListHelper.getAssignedItems()); teamCalDao.setMinimalAccessGroups(getData(), form.minimalAccessGroupsListHelper.getAssignedItems()); TeamCalDO data = form.getData(); if (data.isExternalSubscription() == false) { data.setExternalSubscriptionUrl(""); data.setExternalSubscriptionUpdateInterval(null); } return super.onSaveOrUpdate(); }
public boolean hasUpdateAccess(final PFUserDO user, final TeamCalDO calendar) { if (calendar != null && calendar.isExternalSubscription() == true) { return false; } if (ObjectUtils.equals(user.getId(), calendar.getOwnerId()) == true) { // User has full access to it's own calendars. return true; } final Integer userId = user.getId(); if (teamCalRight.hasFullAccess(calendar, userId) == true || accessChecker.isDemoUser() == true) { return true; } return false; }
final Integer id = form.getData().getId(); ContentMenuEntryPanel menu = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Void>(ContentMenuEntryPanel.LINK_ID) final TeamCalRight right = new TeamCalRight(accessChecker); if (isNew() == true || right.hasFullAccess(getData(), getUserId()) == true && getData().isExternalSubscription() == false) { menu = new ContentMenuEntryPanel(getNewContentMenuChildId(), new Link<Void>(ContentMenuEntryPanel.LINK_ID)
public boolean isOwner(final Integer userId, final TeamCalDO cal) { if (cal == null || userId == null) { return false; } return ObjectUtils.equals(userId, cal.getOwnerId()) == true; }
@Override public void query(String term, final int page, final Response<TeamCalDO> response) { // add all access groups final List<TeamCalDO> fullAccessTeamCals = getTeamCalDao().getList(new TeamCalFilter()); final List<TeamCalDO> result = new ArrayList<TeamCalDO>(); term = term != null ? term.toLowerCase() : ""; final int offset = page * RESULT_PAGE_SIZE; int matched = 0; boolean hasMore = false; for (final TeamCalDO teamCal : fullAccessTeamCals) { if (result.size() == RESULT_PAGE_SIZE) { hasMore = true; break; } if (teamCal.getTitle().toLowerCase().contains(term) == true || teamCal.getOwner().getFullname().toLowerCase().contains(term) == true || teamCal.getOwner().getUsername().toLowerCase().contains(term) == true) { matched++; if (matched > offset) { result.add(teamCal); } } } response.addAll(result); response.setHasMore(hasMore); }
@Override protected void afterSave(final TeamCalDO obj) { super.afterSave(obj); if (obj.isExternalSubscription() == true) { getTeamEventExternalSubscriptionCache().updateCache(obj); } }
public boolean hasFullAccess(final TeamCalDO calendar, final Integer userId) { if (calendar == null || userId == null) { return false; } if (isOwner(userId, calendar) == true) { return true; } final Integer[] groupIds = StringHelper.splitToIntegers(calendar.getFullAccessGroupIds(), ","); final Integer[] userIds = StringHelper.splitToIntegers(calendar.getFullAccessUserIds(), ","); return hasAccess(groupIds, userIds, userId); }
public boolean hasMinimalAccess(final TeamCalDO calendar, final Integer userId) { if (calendar == null || userId == null) { return false; } if (hasFullAccess(calendar, userId) == true || hasReadonlyAccess(calendar, userId) == true) { // User has full access or read-only access (which is more than minimal access). return false; } final Integer[] groupIds = StringHelper.splitToIntegers(calendar.getMinimalAccessGroupIds(), ","); final Integer[] userIds = StringHelper.splitToIntegers(calendar.getMinimalAccessUserIds(), ","); return hasAccess(groupIds, userIds, userId); }
final Integer calId = calendar.getId(); if (calId == null) { log.error("Oups, calId is null (can't update subscription): " + calendar); final Long addedTime = calendar.getExternalSubscriptionUpdateInterval() == null ? SUBSCRIPTION_UPDATE_TIME : 1000L * calendar .getExternalSubscriptionUpdateInterval(); if (teamEventSubscription == null) { subscriptions.put(calendar.getId(), teamEventSubscription); teamEventSubscription.update(teamCalDao, calendar); } else if (force == true || teamEventSubscription.getLastUpdated() == null