use of org.bedework.calfacade.BwEventProxy 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.BwEventProxy 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.BwEventProxy in project bw-calendar-engine by Bedework.
the class EventInfo method getOverrideProxies.
/* *
* @param val
* @return boolean true if removed.
* /
public boolean removeOverride(final BwEventAnnotation val) {
Collection<EventInfo> os = getOverrides();
if (os == null) {
return false;
}
return os.remove(val);
}*/
/**
* @return Collection of override proxy events or null
*/
public Collection<BwEventProxy> getOverrideProxies() {
if (getNumOverrides() == 0) {
return null;
}
TreeSet<BwEventProxy> proxies = new TreeSet<>();
for (EventInfo ei : getOverrides()) {
BwEventProxy proxy = (BwEventProxy) ei.getEvent();
proxies.add(proxy);
}
return proxies;
}
use of org.bedework.calfacade.BwEventProxy in project bw-calendar-engine by Bedework.
the class EventInfo method getDeletedOverrideProxies.
/**
* @param userHref
* @return Collection of deleted override proxy events or null
* @throws CalFacadeException
*/
public Collection<BwEventProxy> getDeletedOverrideProxies(final String userHref) throws CalFacadeException {
TreeSet<BwEventProxy> proxies = new TreeSet<>();
if ((retrievedOverrides == null) || instanceOnly) {
return proxies;
}
for (EventOverride eo : retrievedOverrides) {
if (overrides.contains(eo)) {
continue;
}
BwEventProxy proxy = (BwEventProxy) eo.getEvent();
if (proxy.getRef().unsaved()) {
throw new RuntimeException("Unsaved override in delete list");
}
if (proxy.getXproperty(BwXproperty.peruserInstance) == null) {
/* Not peruser - remove it. */
proxies.add(proxy);
continue;
}
BwXproperty pu = proxy.findPeruserXprop(userHref, BwXproperty.peruserPropTransp);
if (pu != null) {
/* remove it */
proxy.removeXproperty(pu);
}
/* Remove any alarm(s) */
List<BwAlarm> toRemove = new ArrayList<>();
for (BwAlarm a : proxy.getAlarms()) {
if (a.getOwnerHref().equals(userHref)) {
toRemove.add(a);
}
}
for (BwAlarm a : toRemove) {
proxy.removeAlarm(a);
}
if (Util.isEmpty(proxy.getXproperties(BwXproperty.peruserPropTransp)) && Util.isEmpty(proxy.getAlarms())) {
/* No more peruser data - add to remove list */
proxies.add(proxy);
}
/* Update the changes */
ChangeTable chg = getChangeset(userHref);
if (pu != null) {
chg.addValue(PropertyInfoIndex.XPROP, pu);
}
if (!Util.isEmpty(toRemove)) {
for (BwAlarm a : toRemove) {
chg.addValue(PropertyInfoIndex.VALARM, a);
}
}
}
return proxies;
}
use of org.bedework.calfacade.BwEventProxy in project bw-calendar-engine by Bedework.
the class SchedulingBase method significantChange.
/**
* Return true if there is a significant change for the entity or any overrides
*
* @param ei
* @return true if something important changed
* @throws CalFacadeException
*/
protected boolean significantChange(final EventInfo ei) throws CalFacadeException {
if (ei.getNewEvent() || ei.getChangeset(getPrincipalHref()).getSignificantChange()) {
return true;
}
BwEvent ev = ei.getEvent();
boolean override = ev instanceof BwEventProxy;
if (override || (ei.getOverrides() == null)) {
return false;
}
for (EventInfo oei : ei.getOverrides()) {
if (significantChange(oei)) {
return true;
}
}
return false;
}
Aggregations