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);
}
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;
}
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;
}
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;
}
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);
}
}
Aggregations