Search in sources :

Example 36 with BwEventProxy

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);
    }
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEventAnnotation(org.bedework.calfacade.BwEventAnnotation) BwShareableContainedDbentity(org.bedework.calfacade.base.BwShareableContainedDbentity) BwEvent(org.bedework.calfacade.BwEvent) BwCalendar(org.bedework.calfacade.BwCalendar) BwEventProxy(org.bedework.calfacade.BwEventProxy)

Example 37 with BwEventProxy

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);
}
Also used : CoreEventInfo(org.bedework.calcorei.CoreEventInfo) EventInfo(org.bedework.calfacade.svc.EventInfo) BwCalendar(org.bedework.calfacade.BwCalendar) BwEventProxy(org.bedework.calfacade.BwEventProxy)

Example 38 with BwEventProxy

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;
}
Also used : TreeSet(java.util.TreeSet) BwEventProxy(org.bedework.calfacade.BwEventProxy)

Example 39 with BwEventProxy

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;
}
Also used : BwXproperty(org.bedework.calfacade.BwXproperty) TreeSet(java.util.TreeSet) ChangeTable(org.bedework.calfacade.util.ChangeTable) ArrayList(java.util.ArrayList) BwEventProxy(org.bedework.calfacade.BwEventProxy) BwAlarm(org.bedework.calfacade.BwAlarm)

Example 40 with BwEventProxy

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;
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) BwEvent(org.bedework.calfacade.BwEvent) BwEventProxy(org.bedework.calfacade.BwEventProxy)

Aggregations

BwEventProxy (org.bedework.calfacade.BwEventProxy)42 BwEvent (org.bedework.calfacade.BwEvent)33 EventInfo (org.bedework.calfacade.svc.EventInfo)24 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)19 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)12 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)11 BwDateTime (org.bedework.calfacade.BwDateTime)9 BwAttendee (org.bedework.calfacade.BwAttendee)7 BwCalendar (org.bedework.calfacade.BwCalendar)7 ArrayList (java.util.ArrayList)5 TreeSet (java.util.TreeSet)5 BwXproperty (org.bedework.calfacade.BwXproperty)5 Dur (net.fortuna.ical4j.model.Dur)4 BwRecurrenceInstance (org.bedework.calfacade.BwRecurrenceInstance)4 Collection (java.util.Collection)3 DateTime (net.fortuna.ical4j.model.DateTime)3 BwCategory (org.bedework.calfacade.BwCategory)3 BwContact (org.bedework.calfacade.BwContact)3 BwEventObj (org.bedework.calfacade.BwEventObj)3 BwString (org.bedework.calfacade.BwString)3