Search in sources :

Example 21 with BwPreferences

use of org.bedework.calfacade.svc.BwPreferences in project bw-calendar-engine by Bedework.

the class Users method initPrincipal.

private void initPrincipal(final BwPrincipal principal, final CalSvc svc) throws CalFacadeException {
    // Add preferences
    final BwPreferences prefs = new BwPreferences();
    prefs.setOwnerHref(principal.getPrincipalRef());
    prefs.setDefaultCalendarPath(Util.buildPath(colPathEndsWithSlash, getSvc().getPrincipalInfo().getCalendarHomePath(principal), "/", getBasicSyspars().getUserDefaultCalendar()));
    // Add a default view for the calendar home
    final BwView view = new BwView();
    view.setName(getAuthpars().getDefaultUserViewName());
    // Add default subscription to the user root.
    view.addCollectionPath(svc.getPrincipalInfo().getCalendarHomePath(principal));
    prefs.addView(view);
    prefs.setPreferredView(view.getName());
    prefs.setPreferredViewPeriod("week");
    prefs.setHour24(getAuthpars().getDefaultUserHour24());
    prefs.setScheduleAutoRespond(principal.getKind() == WhoDefs.whoTypeResource);
    svc.getPrefsHandler().update(prefs);
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) BwView(org.bedework.calfacade.svc.BwView)

Example 22 with BwPreferences

use of org.bedework.calfacade.svc.BwPreferences in project bw-calendar-engine by Bedework.

the class Views method add.

/* (non-Javadoc)
   * @see org.bedework.calsvci.ViewsI#add(org.bedework.calfacade.svc.BwView, boolean)
   */
@Override
public boolean add(final BwView val, final boolean makeDefault) throws CalFacadeException {
    if (val == null) {
        return false;
    }
    BwPreferences prefs = getSvc().getPrefsHandler().get();
    checkOwnerOrSuper(prefs);
    if (!prefs.addView(val)) {
        return false;
    }
    if (makeDefault) {
        prefs.setPreferredView(val.getName());
    }
    getSvc().getPrefsHandler().update(prefs);
    return true;
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences)

Example 23 with BwPreferences

use of org.bedework.calfacade.svc.BwPreferences in project bw-calendar-engine by Bedework.

the class Views method removeCollection.

/* (non-Javadoc)
   * @see org.bedework.calsvci.ViewsI#removeCollection(java.lang.String, java.lang.String)
   */
@Override
public boolean removeCollection(final String name, final String path) throws CalFacadeException {
    BwPreferences prefs = getSvc().getPrefsHandler().get(getPrincipal());
    checkOwnerOrSuper(prefs);
    BwView view = find(name);
    if (view == null) {
        return false;
    }
    view.removeCollectionPath(path);
    getSvc().getPrefsHandler().update(prefs);
    return true;
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) BwView(org.bedework.calfacade.svc.BwView)

Example 24 with BwPreferences

use of org.bedework.calfacade.svc.BwPreferences in project bw-calendar-engine by Bedework.

the class InCancel method process.

/**
 * @param ei the incoming event
 * @return ScheduleResult
 * @throws CalFacadeException on error
 */
@Override
public ProcessResult process(final EventInfo ei) throws CalFacadeException {
    /* We, as an attendee, received a CANCEL from the organizer.
     *
     */
    final ProcessResult pr = new ProcessResult();
    final BwEvent ev = ei.getEvent();
    final SchedulingI sched = getSvc().getScheduler();
    pr.removeInboxEntry = true;
    check: {
        if (ev.getOriginator() == null) {
            pr.sr.errorCode = CalFacadeException.schedulingNoOriginator;
            break check;
        }
        final BwPreferences prefs = getSvc().getPrefsHandler().get();
        final EventInfo colEi = sched.getStoredMeeting(ei.getEvent());
        if (colEi == null) {
            break check;
        }
        final BwEvent colEv = colEi.getEvent();
        if (prefs.getScheduleAutoCancelAction() == BwPreferences.scheduleAutoCancelSetStatus) {
            if (colEv.getSuppressed()) {
                if (colEi.getOverrides() != null) {
                    for (final EventInfo oei : colEi.getOverrides()) {
                        final BwEvent oev = oei.getEvent();
                        oev.setStatus(BwEvent.statusCancelled);
                        oev.setSequence(ev.getSequence());
                    }
                }
            } else {
                colEv.setStatus(BwEvent.statusCancelled);
                colEv.setSequence(ev.getSequence());
            }
            getSvc().getEventsHandler().update(colEi, true, null);
        } else {
            getSvc().getEventsHandler().delete(colEi, false);
        }
        pr.removeInboxEntry = false;
    }
    return pr;
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) SchedulingI(org.bedework.calsvci.SchedulingI)

Example 25 with BwPreferences

use of org.bedework.calfacade.svc.BwPreferences in project bw-calendar-engine by Bedework.

the class InProcessor method pendingToInbox.

/**
 * Update the inbox according to it's owners wishes (what if owner and proxy
 * have different wishes)
 *
 * @param ei - the pending inbox event
 * @param inboxOwnerHref href of
 * @param attendeeAccepting - is this the result of a REPLY with PARTSTAT accept?
 * @param forceDelete - it's inbox noise, delete it
 * @throws CalFacadeException
 */
public void pendingToInbox(final EventInfo ei, final String inboxOwnerHref, final boolean attendeeAccepting, final boolean forceDelete) throws CalFacadeException {
    boolean delete = forceDelete;
    if (!delete) {
        final BwPrincipal principal = getSvc().getUsersHandler().getPrincipal(inboxOwnerHref);
        if (principal == null) {
            delete = true;
        } else {
            final BwPreferences prefs = getSvc().getPrefsHandler().get(principal);
            final int sapr = prefs.getScheduleAutoProcessResponses();
            if (sapr == BwPreferences.scheduleAutoProcessResponsesNoNotify) {
                delete = true;
            } else if (sapr == BwPreferences.scheduleAutoProcessResponsesNoAcceptNotify) {
                delete = attendeeAccepting;
            }
        }
    }
    final BwEvent ev = ei.getEvent();
    final boolean vpoll = ev.getEntityType() == IcalDefs.entityTypeVpoll;
    if (delete) {
        getSvc().getEventsHandler().delete(ei, false);
    } else {
        final BwCalendar inbox = getSvc().getCalendarsHandler().getSpecial(BwCalendar.calTypeInbox, false);
        if (inbox == null) {
            return;
        }
        // if (vpoll) {
        /* Delete other notifications for the same event
         * NOTE: DON'T for non-vpoll - this was deleting changes that had to
         * be processed. Still an opportunity to improve this though.
         */
        final Collection<EventInfo> inevs = getEventsByUid(inbox.getPath(), ev.getUid());
        for (final EventInfo inei : inevs) {
            final BwEvent inev = inei.getEvent();
            if (inev.getScheduleState() != BwEvent.scheduleStateProcessed) {
                continue;
            }
            if (debug) {
                trace("delete earlier? event from inbox: " + inev.getName());
            }
            deleteEvent(inei, true, false);
        }
        if (debug) {
            trace("set event to scheduleStateProcessed: " + ev.getName());
        }
        final ChangeTable chg = ei.getChangeset(inboxOwnerHref);
        chg.changed(PropertyIndex.PropertyInfoIndex.SCHEDULE_STATE, ev.getScheduleState(), BwEvent.scheduleStateProcessed);
        ev.setScheduleState(BwEvent.scheduleStateProcessed);
        chg.changed(PropertyIndex.PropertyInfoIndex.COLPATH, ev.getColPath(), inbox.getPath());
        ev.setColPath(inbox.getPath());
        getSvc().getEventsHandler().update(ei, true, null);
    }
}
Also used : BwPrincipal(org.bedework.calfacade.BwPrincipal) BwPreferences(org.bedework.calfacade.svc.BwPreferences) EventInfo(org.bedework.calfacade.svc.EventInfo) ChangeTable(org.bedework.calfacade.util.ChangeTable) BwEvent(org.bedework.calfacade.BwEvent) BwCalendar(org.bedework.calfacade.BwCalendar)

Aggregations

BwPreferences (org.bedework.calfacade.svc.BwPreferences)28 BwView (org.bedework.calfacade.svc.BwView)7 BwCalendar (org.bedework.calfacade.BwCalendar)6 BwPrincipal (org.bedework.calfacade.BwPrincipal)6 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)5 EventInfo (org.bedework.calfacade.svc.EventInfo)5 BwEvent (org.bedework.calfacade.BwEvent)4 File (java.io.File)2 BwCategory (org.bedework.calfacade.BwCategory)2 UpdateResult (org.bedework.calfacade.svc.EventInfo.UpdateResult)2 SchedulingIntf (org.bedework.calsvc.scheduling.SchedulingIntf)2 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)2 TreeSet (java.util.TreeSet)1 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)1 UpdateEventResult (org.bedework.calcorei.CoreEventsI.UpdateEventResult)1 HibSession (org.bedework.calcorei.HibSession)1 BaseNotificationType (org.bedework.caldav.util.notifications.BaseNotificationType)1 NotificationType (org.bedework.caldav.util.notifications.NotificationType)1 ResourceChangeType (org.bedework.caldav.util.notifications.ResourceChangeType)1 UpdatedType (org.bedework.caldav.util.notifications.UpdatedType)1