use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class XpropertyRule method end.
@Override
public void end(final String ns, final String name) throws Exception {
BwXproperty entity = (BwXproperty) pop();
if (top() instanceof EventInfo) {
EventInfo ei = (EventInfo) top();
BwEvent e = ei.getEvent();
if (e instanceof BwEventProxy) {
e = ((BwEventProxy) e).getRef();
}
// XXX From before 4.0
if (entity.getName().equals(BwXproperty.bedeworkAlias) || entity.getName().equals(BwXproperty.bedeworkSubmitAlias)) {
entity.setValue(Util.buildPath(false, entity.getValue()));
}
e.addXproperty(entity);
}
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class EventBwRequestStatusRule method end.
public void end(String ns, String name) throws Exception {
BwRequestStatus entity = (BwRequestStatus) pop();
EventInfo ei = (EventInfo) top();
BwEvent e = ei.getEvent();
if (e instanceof BwEventProxy) {
e = ((BwEventProxy) e).getRef();
}
e.addRequestStatus(entity);
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class EventRule method end.
@Override
public void end(final String ns, final String name) throws Exception {
if (!(top() instanceof EventInfo)) {
warn("Top is not an event");
warn(top().toString());
return;
}
if (globals.entityError) {
warn("Not restoring event because of previous error");
warn(top().toString());
return;
}
EventInfo ei = (EventInfo) top();
BwEvent entity = ei.getEvent();
if (entity instanceof BwEventProxy) {
entity = ((BwEventProxy) entity).getRef();
}
boolean override = (entity instanceof BwEventAnnotation) && (((BwEventAnnotation) entity).getOverride());
boolean alias = (entity instanceof BwEventAnnotation) && !override;
globals.counts[globals.events]++;
if ((globals.counts[globals.events] % 100) == 0) {
info("Restore event # " + globals.counts[globals.events]);
}
if (!override) {
fixSharableEntity(entity, "Event");
}
if ((entity.getEntityType() == IcalDefs.entityTypeTodo) && entity.getNoStart() && (entity.getEndType() == StartEndComponent.endTypeNone)) {
/* The end date should be sometime in the distant future. If it isn't make
* it so.
* A bug was creating essentially one day events.
*/
Date sdt = BwDateTimeUtil.getDate(entity.getDtstart());
Date edt = BwDateTimeUtil.getDate(entity.getDtend());
// about 9 years of millis
long years9 = 52L * 7L * 24L * 60L * 60L * 1000L * 9L;
if ((edt.getTime() - sdt.getTime()) < years9) {
// about 10 years
Dur years10 = new Dur(520);
net.fortuna.ical4j.model.Date newDt = new net.fortuna.ical4j.model.Date(sdt.getTime());
DtEnd dtEnd = new DtEnd(new net.fortuna.ical4j.model.Date(years10.getTime(newDt)));
entity.setDtend(BwDateTime.makeBwDateTime(dtEnd));
warn("Fixed task uid=" + entity.getUid());
}
}
// Out here for debugging
BwEvent target = null;
BwEvent master = null;
try {
if (override) {
pop();
if (!(top() instanceof EventInfo)) {
warn("Not restoring event because of previous error");
warn(top().toString());
return;
}
if (debug) {
trace("Add override to event ");
}
EventInfo masterei = (EventInfo) top();
masterei.addOverride(ei);
return;
}
if (alias) {
BwEventAnnotation ann = (BwEventAnnotation) entity;
/* It's an alias, save an entry in the alias table then remove the dummy target.
* We'll update them all at the end
*/
// XXX Never did get on table globals.aliasTbl.put(ann);
target = ann.getTarget();
BwPrincipal annOwner = globals.getPrincipal(ann.getOwnerHref());
BwEvent ntarget = globals.rintf.getEvent(annOwner, target.getColPath(), target.getRecurrenceId(), target.getUid());
if (ntarget == null) {
error("Unknown target " + target);
}
ann.setTarget(ntarget);
master = ann.getMaster();
if (master.equals(target)) {
ann.setMaster(ntarget);
} else {
BwEvent nmaster = globals.rintf.getEvent(annOwner, master.getColPath(), master.getRecurrenceId(), master.getUid());
if (nmaster == null) {
error("Unknown master " + master);
}
ann.setMaster(nmaster);
}
}
boolean ok = true;
if ((entity.getUid() == null) || (entity.getUid().length() == 0)) {
error("Unable to save event " + entity + ". Has no guid.");
ok = false;
}
if (entity.getColPath() == null) {
error("Unable to save event " + entity + ". Has no calendar.");
ok = false;
}
BwEvent ev = ei.getEvent();
if (ok && (globals.rintf != null) && globals.onlyUsersMap.check(ev)) {
globals.currentUser = globals.getPrincipal(ev.getOwnerHref());
globals.rintf.restoreEvent(ei);
}
} catch (CalFacadeException cfe) {
if (cfe.getMessage().equals(CalFacadeException.noRecurrenceInstances)) {
error("Event has no recurrence instances - not restored." + entity.getUid() + "\n" + atLine());
} else {
error("Unable to save event " + entity.getUid() + "\n" + atLine());
cfe.printStackTrace();
}
} catch (Throwable t) {
error("Unable to save event " + entity.getUid() + "\n" + atLine());
t.printStackTrace();
}
pop();
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class EventStringKeyRule method field.
public void field(String name) throws Throwable {
try {
/* Top should now be an event object */
EventInfo ei = (EventInfo) getTop(EventInfo.class, name);
BwEventAnnotation ann = null;
BwEvent e = ei.getEvent();
if (e instanceof BwEventProxy) {
ann = ((BwEventProxy) e).getRef();
if (ann.getOverride()) {
// Overrides have everything set already
return;
}
String match = getDigester().getMatch();
if (match.contains("/target/")) {
e = ann.getTarget();
} else if (match.contains("/master/")) {
e = ann.getMaster();
} else {
e = ann;
}
}
if (name.equals("uid")) {
e.setUid(stringFld());
} else if (name.equals("recurrenceId")) {
e.setRecurrenceId(stringFld());
} else {
unknownTag(name);
}
} catch (Throwable t) {
handleException(t);
}
}
use of org.bedework.calfacade.svc.EventInfo in project bw-calendar-engine by Bedework.
the class OrganizerRule method end.
@Override
public void end(final String ns, final String name) throws Exception {
BwOrganizer entity = (BwOrganizer) pop();
EventInfo ei = (EventInfo) getTop(EventInfo.class, name);
BwEvent e = ei.getEvent();
e.setOrganizer(entity);
}
Aggregations