use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class Events method markDeleted.
/* (non-Javadoc)
* @see org.bedework.calsvci.EventsI#markDeleted(org.bedework.calfacade.BwEvent)
*/
@Override
public void markDeleted(final BwEvent event) throws CalFacadeException {
/* Trash disabled
if (getCal().checkAccess(event, PrivilegeDefs.privWrite, true).accessAllowed) {
// Have write access - just set the flag and move it into the owners trash
event.setDeleted(true);
GetSpecialCalendarResult gscr = getCal().getSpecialCalendar(getUser(), //event.getOwner(),
BwCalendar.calTypeTrash,
true,
PrivilegeDefs.privWriteContent);
if (gscr.created) {
getCal().flush();
}
event.setCalendar(gscr.cal);
if (!event.getOwner().equals(getUser())) {
// Claim ownership
event.setOwner(getUser());
}
EventInfo ei = new EventInfo(event);
/* Names have to be unique. Just keep extending the name out till it works. I guess
* a better approach would be a random suffix.
* /
int limit = 100;
for (int i = 0; i < limit; i++) {
try {
update(ei, false, null, null, null);
break;
} catch (CalFacadeDupNameException dup) {
if ((i + 1) == limit) {
throw dup;
}
event.setName("a" + event.getName());
}
}
return;
}
*/
// Need to annotate it as deleted
BwEventProxy proxy = BwEventProxy.makeAnnotation(event, event.getOwnerHref(), false);
// Where does the ref go? Not in the same calendar - we have no access
BwCalendar cal = getCal().getSpecialCalendar(getPrincipal(), BwCalendar.calTypeDeleted, true, PrivilegeDefs.privRead).cal;
proxy.setOwnerHref(getPrincipal().getPrincipalRef());
proxy.setDeleted(true);
proxy.setColPath(cal.getPath());
add(new EventInfo(proxy), true, false, false, false);
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class Events method get.
@Override
public EventInfo get(final BwCalendar col, final String name, final String recurrenceId, final List<String> retrieveList) throws CalFacadeException {
if ((col == null) || (name == null)) {
throw new CalFacadeException(CalFacadeException.badRequest);
}
if (col.getInternalAlias()) {
final String expr = "(vpath='" + SfpTokenizer.escapeQuotes(col.getPath()) + "') and (name='" + SfpTokenizer.escapeQuotes(name) + "')";
final SimpleFilterParser sfp = getSvc().getFilterParser();
final ParseResult pr = sfp.parse(expr, true, null);
if (!pr.ok) {
throw new CalFacadeException("Failed to parse " + expr + ": message was " + pr.message);
}
final Collection<EventInfo> evs = getEvents(null, pr.filter, // start
null, // end
null, RetrieveList.getRetrieveList(retrieveList), DeletedState.noDeleted, RecurringRetrievalMode.overrides);
if (evs.size() == 0) {
return null;
}
if (evs.size() == 1) {
return evs.iterator().next();
}
throw new CalFacadeException("Multiple results");
}
String path = col.getPath();
if (col.getCalType() == BwCalendar.calTypeEventList) {
/* Find the event in the list using the name */
final SortedSet<EventListEntry> eles = col.getEventList();
findHref: {
for (final EventListEntry ele : eles) {
if (ele.getName().equals(name)) {
path = ele.getPath();
break findHref;
}
}
// Not in list
return null;
}
// findHref
}
return get(path, name, null);
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class Events method getMatching.
/**
* Method which allows us to flag it as a scheduling action
*
* @param cals
* @param filter
* @param startDate
* @param endDate
* @param retrieveList
* @param recurRetrieval
* @param freeBusy
* @return Collection of matching events
* @throws CalFacadeException
*/
Collection<EventInfo> getMatching(final Collection<BwCalendar> cals, final FilterBase filter, final BwDateTime startDate, final BwDateTime endDate, final List<BwIcalPropertyInfoEntry> retrieveList, final DeletedState delState, final RecurringRetrievalMode recurRetrieval, final boolean freeBusy) throws CalFacadeException {
TreeSet<EventInfo> ts = new TreeSet<EventInfo>();
if ((filter != null) && (filter.equals(BooleanFilter.falseFilter))) {
return ts;
}
Collection<BwCalendar> calSet = null;
if (cals != null) {
/* Turn the calendar reference into a set of calendar collections
*/
calSet = new ArrayList<BwCalendar>();
for (BwCalendar cal : cals) {
buildCalendarSet(calSet, cal, freeBusy);
}
}
ts.addAll(postProcess(getCal().getEvents(calSet, filter, startDate, endDate, retrieveList, delState, recurRetrieval, freeBusy)));
return ts;
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class ImplicitSchedulingHandler method sendReply.
/* (non-Javadoc)
* @see org.bedework.calsvci.SchedulingI#sendReply(org.bedework.calfacade.svc.EventInfo, int, java.lang.String)
*/
@Override
public ScheduleResult sendReply(final EventInfo ei, final int partstat, final String comment) throws CalFacadeException {
ScheduleResult sr = new ScheduleResult();
BwEvent ev = ei.getEvent();
if (!ev.getAttendeeSchedulingObject()) {
sr.errorCode = CalFacadeException.schedulingBadMethod;
return sr;
}
BwAttendee att = findUserAttendee(ev);
if (att == null) {
sr.errorCode = CalFacadeException.schedulingNotAttendee;
return sr;
}
att = (BwAttendee) att.clone();
att.setPartstat(IcalDefs.partstats[partstat]);
att.setRsvp(partstat == IcalDefs.partstatNeedsAction);
BwEvent outEv = new BwEventObj();
EventInfo outEi = new EventInfo(outEv);
outEv.setScheduleMethod(ScheduleMethods.methodTypeReply);
outEv.addRequestStatus(new BwRequestStatus(IcalDefs.requestStatusSuccess.getCode(), IcalDefs.requestStatusSuccess.getDescription()));
outEv.addRecipient(ev.getOrganizer().getOrganizerUri());
outEv.setOriginator(att.getAttendeeUri());
outEv.updateDtstamp();
outEv.setOrganizer((BwOrganizer) ev.getOrganizer().clone());
outEv.getOrganizer().setDtstamp(outEv.getDtstamp());
outEv.addAttendee(att);
outEv.setUid(ev.getUid());
outEv.setRecurrenceId(ev.getRecurrenceId());
outEv.setDtstart(ev.getDtstart());
outEv.setDtend(ev.getDtend());
outEv.setDuration(ev.getDuration());
outEv.setNoStart(ev.getNoStart());
outEv.setSummary(ev.getSummary());
outEv.setRecurring(false);
if (comment != null) {
outEv.addComment(new BwString(null, comment));
}
sr = scheduleResponse(outEi);
outEv.setScheduleState(BwEvent.scheduleStateProcessed);
return sr;
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class OutBoxHandler method addToOutBox.
protected String addToOutBox(final EventInfo ei, final BwCalendar outBox, final Set<String> externalRcs) throws CalFacadeException {
// We have external recipients. Put in the outbox for mailing
EventInfo outEi = copyEventInfo(ei, getPrincipal());
BwEvent event = outEi.getEvent();
event.setScheduleState(BwEvent.scheduleStateNotProcessed);
event.setRecipients(externalRcs);
event.setColPath(outBox.getPath());
String ecode = addEvent(outEi, "Out-" + Uid.getUid() + "-" + event.getDtstamp(), BwCalendar.calTypeOutbox, true);
if (ecode != null) {
return ecode;
}
addAutoScheduleMessage(false, outBox.getOwnerHref(), event.getName());
return null;
}
Aggregations