use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class OwnerRule method end.
@Override
public void end(final String ns, final String name) throws Exception {
error("OwnerRule called");
BwPrincipal p = doPrincipal();
if (top() instanceof OwnerUidKey) {
OwnerUidKey key = (OwnerUidKey) top();
key.setOwnerHref(p.getPrincipalRef());
globals.inOwnerKey = false;
return;
}
if (top() instanceof BwAdminGroup) {
BwAdminGroup ag = (BwAdminGroup) top();
if (name.equals("owner")) {
ag.setOwnerHref(p.getPrincipalRef());
} else if (name.equals("owner-key")) {
// PRE3.5
ag.setOwnerHref(p.getPrincipalRef());
} else {
ag.setGroupOwnerHref(p.getPrincipalRef());
}
globals.inOwnerKey = false;
return;
}
BwOwnedDbentity o = null;
if (top() == null) {
error("Null stack top when setting owner. Match: " + getDigester().getMatch());
return;
}
if (top() instanceof EventInfo) {
o = ((EventInfo) top()).getEvent();
} else if (!(top() instanceof BwOwnedDbentity)) {
if (top() instanceof BwOrganizer) {
// No owner now
} else if (top() instanceof BwView) {
// No owner now
} else if (top() instanceof SkipThis) {
} else {
// We expect organizer in old data
warn("top() is not BwOwnedDbentity:" + top().getClass().getCanonicalName());
warn(" match: " + getDigester().getMatch());
}
globals.inOwnerKey = false;
return;
} else {
o = (BwOwnedDbentity) top();
}
o.setOwnerHref(p.getPrincipalRef());
globals.inOwnerKey = false;
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class ContactKeyRule method storeEntity.
@Override
public void storeEntity(final OwnerUidKey key) throws Exception {
BwContact ent;
try {
ent = globals.rintf.getContact(key.getUid());
} catch (Throwable t) {
throw new Exception(t);
}
if (ent == null) {
throw new Exception("Missing contact with key " + key + " for " + top());
}
if (top() instanceof EventInfo) {
BwEvent ev = ((EventInfo) top()).getEvent();
ev.addContact(ent);
return;
}
throw new Exception("Unhandled class for contacts " + top());
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class ContainerPathRule method field.
public void field(String name) throws Throwable {
if (name.equals("path")) {
/* If the top is an override skip this - container is set already. */
BwEventAnnotation ann = null;
BwEvent e = null;
if (top() instanceof EventInfo) {
EventInfo ei = (EventInfo) getTop(EventInfo.class, name);
e = ei.getEvent();
if (e instanceof BwEventProxy) {
ann = ((BwEventProxy) e).getRef();
if (ann.getOverride()) {
// Overrides have everything set already
return;
}
}
}
BwCalendar cal = globals.rintf.getCalendar(stringFld());
if (cal == null) {
error("No calendar for path " + stringFld());
}
if (top() instanceof BwShareableContainedDbentity) {
BwShareableContainedDbentity scde = (BwShareableContainedDbentity) top();
scde.setColPath(stringFld());
} else if (top() instanceof EventInfo) {
if (ann != null) {
/* Could be target or master */
String match = getDigester().getMatch();
if (match.contains("/target/")) {
ann.getTarget().setColPath(stringFld());
} else if (match.contains("/master/")) {
ann.getMaster().setColPath(stringFld());
} else {
ann.setColPath(stringFld());
}
}
e.setColPath(stringFld());
} else {
handleException(new Exception("Unexpected stack top "));
}
} else {
unknownTag(name);
}
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class CreatorRule method end.
@Override
public void end(final String ns, final String name) throws Exception {
error("CreatorRule called");
BwPrincipal p = doPrincipal();
BwShareableDbentity o;
if (top() instanceof EventInfo) {
o = ((EventInfo) top()).getEvent();
} else {
o = (BwShareableDbentity) top();
}
if (o == null) {
error("Null stack top when setting creator");
return;
}
o.setCreatorHref(p.getPrincipalRef());
globals.inOwnerKey = false;
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class IcalTranslator method makeIc.
private Icalendar makeIc(final BwCalendar col, final Icalendar ic, final Calendar cal, final boolean diff, final boolean mergeAttendees) throws CalFacadeException {
try {
if (cal == null) {
return ic;
}
PropertyList pl = cal.getProperties();
Property prop = pl.getProperty(Property.PRODID);
if (prop != null) {
ic.setProdid(prop.getValue());
}
prop = pl.getProperty(Property.VERSION);
if (prop != null) {
ic.setVersion(prop.getValue());
}
ic.setMethod(getMethod(cal));
prop = pl.getProperty(Property.CALSCALE);
if (prop != null) {
ic.setCalscale(prop.getValue());
}
Collection<CalendarComponent> clist = orderedComponents(cal.getComponents());
for (CalendarComponent comp : clist) {
if (comp instanceof VFreeBusy) {
EventInfo ei = BwEventUtil.toEvent(cb, col, ic, comp, diff, mergeAttendees);
if (ei != null) {
ic.addComponent(ei);
}
} else if (comp instanceof VTimeZone) {
ic.addTimeZone(doTimeZone((VTimeZone) comp));
} else if ((comp instanceof VEvent) || (comp instanceof VToDo) || (comp instanceof VPoll) || (comp instanceof VAvailability)) {
EventInfo ei = BwEventUtil.toEvent(cb, col, ic, comp, diff, mergeAttendees);
if (ei != null) {
ic.addComponent(ei);
}
}
}
return ic;
} catch (CalFacadeException cfe) {
throw cfe;
} catch (Throwable t) {
throw new CalFacadeException(t);
}
}
Aggregations