use of org.bedework.calfacade.BwEvent in project bw-calendar-engine by Bedework.
the class Dumpling method dumpCollection.
private void dumpCollection(final Iterator<T> it) throws Throwable {
while (it.hasNext()) {
final DumpEntity d = unwrap(it.next());
globals.counts[countIndex]++;
if ((globals.counts[countIndex] % 100) == 0) {
info(" ... " + globals.counts[countIndex]);
}
if (d instanceof BwResource) {
dumpResource((BwResource) d);
continue;
}
if (d instanceof BwCalendar) {
dumpCollection((BwCalendar) d);
continue;
}
if (d instanceof BwEvent) {
dumpEvent((BwEvent) d);
continue;
}
/* Just dump any remaining classes - no special treatment */
d.dump(xml);
}
}
use of org.bedework.calfacade.BwEvent in project bw-calendar-engine by Bedework.
the class BwStringRule method end.
@Override
public void end(final String ns, final String name) throws Exception {
if (name.equals("bwstring")) {
// 3.5 onwards we wrapped with a tag. Do nothing
return;
}
BwString entity = (BwString) pop();
if (top() instanceof BwRequestStatus) {
BwRequestStatus rs = (BwRequestStatus) top();
rs.setDescription(entity);
return;
}
if (top() instanceof BwCategory) {
BwCategory cat = (BwCategory) top();
if (name.equals("keyword")) {
cat.setWord(entity);
} else if (name.equals("desc")) {
cat.setDescription(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwContact) {
BwContact ent = (BwContact) top();
if (name.equals("value")) {
ent.setCn(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwLocation) {
BwLocation loc = (BwLocation) top();
if (name.equals("addr")) {
loc.setAddress(entity);
} else if (name.equals("subaddr")) {
loc.setSubaddress(entity);
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwFilterDef) {
BwFilterDef f = (BwFilterDef) top();
if (name.equals("display-name")) {
f.addDisplayName(entity);
} else if (name.equals("subaddr")) {
f.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
} else {
unknownTag(name);
}
return;
}
if (top() instanceof BwAlarm) {
BwAlarm a = (BwAlarm) top();
if (name.equals("description")) {
a.addDescription(entity);
if (entity.getLang() != null) {
a.addXproperty(new BwXproperty(entity.getLang(), null, entity.getValue()));
} else {
a.addDescription(entity);
}
return;
}
if (name.equals("summary")) {
a.addSummary(entity);
} else {
unknownTag(name);
}
return;
}
EventInfo ei = (EventInfo) top();
BwEvent e = ei.getEvent();
if (e instanceof BwEventProxy) {
e = ((BwEventProxy) e).getRef();
}
if (name.equals("comment")) {
e.addComment(entity);
} else if (name.equals("description")) {
e.addDescription(new BwLongString(entity.getLang(), entity.getValue()));
} else if (name.equals("resource")) {
e.addResource(entity);
} else if (name.equals("summary")) {
e.addSummary(entity);
} else {
unknownTag(name);
}
}
use of org.bedework.calfacade.BwEvent in project bw-calendar-engine by Bedework.
the class AlarmRule method end.
public void end(String ns, String name) throws Exception {
BwAlarm entity = (BwAlarm) pop();
globals.counts[globals.valarms]++;
if (!(top() instanceof EventInfo)) {
warn("Expected an event info object: found " + top());
return;
}
BwEvent ev = ((EventInfo) top()).getEvent();
if (entity.getOwnerHref() == null) {
entity.setOwnerHref(ev.getOwnerHref());
}
entity.setEvent(ev);
ev.addAlarm(entity);
}
use of org.bedework.calfacade.BwEvent in project bw-calendar-engine by Bedework.
the class InScheduler method processScheduleUpdateEvent.
private ProcessMessageResult processScheduleUpdateEvent(final ScheduleUpdateEvent msg) {
try (final CalSvcI svci = getSvci(msg.getOwnerHref())) {
if (debug) {
trace("ScheduleUpdateEvent for principal " + msg.getOwnerHref());
}
final EventInfo ei = svci.getEventsHandler().get(getParentPath(msg.getHref()), getName(msg.getHref()));
if (ei == null) {
// Event deleted?.
if (debug) {
trace("InSchedule event deleted?");
}
return ProcessMessageResult.NO_ACTION;
}
final BwEvent ev = ei.getEvent();
SchedProcessor proc = null;
switch(msg.getChange()) {
case attendeeChange:
{
proc = new SchedAttendeeUpdate(svci);
break;
}
default:
warn("InSchedule: unhandled change type for " + ev.getOwnerHref() + " " + msg.getChange());
}
if (proc == null) {
return ProcessMessageResult.PROCESSED;
}
final SchedProcResult pr = proc.process(ei);
if (debug) {
trace("InSchedule " + pr.sr);
}
return ProcessMessageResult.PROCESSED;
} catch (final CalFacadeStaleStateException csse) {
if (debug) {
trace("Stale state exception");
}
rollback(getSvc());
return ProcessMessageResult.STALE_STATE;
} catch (final Throwable t) {
rollback(getSvc());
error(t);
}
return ProcessMessageResult.FAILED;
}
use of org.bedework.calfacade.BwEvent in project bw-calendar-engine by Bedework.
the class InReply method process.
@Override
public ProcessResult process(final EventInfo ei) throws CalFacadeException {
/* Process a response we as the organizer, or their proxy, received from
* an attendee
*/
final ProcessResult pr = new ProcessResult();
final SchedulingI sched = getSvc().getScheduler();
BwEvent ev = ei.getEvent();
final EventInfo colEi = sched.getStoredMeeting(ev);
/* The event should have a calendar set to the inbox it came from.
* That inbox may be owned by somebody other than the current user if a
* calendar user has delegated control of their inbox to some other user
* e.g. secretary.
*/
pr.attendeeAccepting = true;
check: {
if (colEi == null) {
// No corresponding stored meeting
break check;
}
if (ev.getOriginator() == null) {
pr.sr.errorCode = CalFacadeException.schedulingNoOriginator;
break check;
}
String attUri = null;
/* Should be exactly one attendee */
if (!ev.getSuppressed()) {
final Collection<BwAttendee> atts = ev.getAttendees();
if ((atts == null) || (atts.size() != 1)) {
pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
break check;
}
final BwAttendee att = atts.iterator().next();
if (!att.getPartstat().equals(acceptPartstat)) {
pr.attendeeAccepting = false;
}
attUri = att.getAttendeeUri();
}
if (ei.getNumOverrides() > 0) {
for (final EventInfo oei : ei.getOverrides()) {
ev = oei.getEvent();
final Collection<BwAttendee> atts = ev.getAttendees();
if ((atts == null) || (atts.size() != 1)) {
pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
break check;
}
final BwAttendee att = atts.iterator().next();
if (!att.getPartstat().equals(acceptPartstat)) {
pr.attendeeAccepting = false;
}
if (attUri == null) {
attUri = att.getAttendeeUri();
} else if (!attUri.equals(att.getAttendeeUri())) {
pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
break check;
}
}
}
if (attUri == null) {
pr.sr.errorCode = CalFacadeException.schedulingExpectOneAttendee;
break check;
}
/*TODO If the sequence of the incoming event is lower than the sequence on the
* calendar event we ignore it.
*/
final boolean vpoll = colEi.getEvent().getEntityType() == IcalDefs.entityTypeVpoll;
if (vpoll) {
if (!updateOrganizerPollCopy(colEi, ei, attUri, pr.sr)) {
break check;
}
} else if (!updateOrganizerCopy(colEi, ei, attUri, pr.sr)) {
break check;
}
pr.removeInboxEntry = false;
}
return pr;
}
Aggregations