Search in sources :

Example 96 with BwCalendar

use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.

the class AuthUserFieldRule method field.

/* (non-Javadoc)
   * @see org.bedework.dumprestore.restore.rules.EntityFieldRule#field(java.lang.String)
   */
@Override
public void field(final String name) throws Throwable {
    BwEventProperty ep = null;
    BwCalendar cal = null;
    try {
        if (top() instanceof BwEventProperty) {
            ep = (BwEventProperty) pop();
        } else if (top() instanceof BwCalendar) {
            cal = (BwCalendar) pop();
        }
        BwAuthUser au = (BwAuthUser) top();
        if (name.equals("id") || name.equals("seq")) {
            return;
        }
        if (name.equals("userHref")) {
            au.setUserHref(Util.buildPath(false, stringFld()));
        // } else if (name.equals("account")) {   old?
        // au.setUserHref(globals.rintf.getUser(stringFld()).getPrincipalRef());
        // } else if (name.equals("user")) {
        // // done above
        } else if (name.equals("usertype")) {
            int type = intFld();
            au.setUsertype(type);
        /* Prefs stuff next */
        } else if (name.equals("autoAdd")) {
            if (inCategoryPrefs) {
                getCategoryPrefs(au).setAutoAdd(booleanFld());
            } else if (inCollectionsPrefs) {
                getCalendarPrefs(au).setAutoAdd(booleanFld());
            } else if (inContactPrefs) {
                getContactPrefs(au).setAutoAdd(booleanFld());
            } else if (inLocationPrefs) {
                getLocationPrefs(au).setAutoAdd(booleanFld());
            } else {
                error("Not in any prefs for autoAdd");
            }
        } else if (name.equals("category")) {
            au.getPrefs().getCategoryPrefs().add((BwCategory) ep);
        } else if (name.equals("collection")) {
            au.getPrefs().getCalendarPrefs().add(cal);
        } else if (name.equals("contact")) {
            au.getPrefs().getContactPrefs().add((BwContact) ep);
        } else if (name.equals("location")) {
            au.getPrefs().getLocationPrefs().add((BwLocation) ep);
        } else if (name.equals("categoryPrefs")) {
            inCategoryPrefs = false;
        } else if (name.equals("calendarPrefs")) {
            inCollectionsPrefs = false;
        } else if (name.equals("contactPrefs")) {
            inContactPrefs = false;
        } else if (name.equals("locationPrefs")) {
            inLocationPrefs = false;
        } else if (name.equals("prefs")) {
        } else if (name.equals("byteSize")) {
        } else {
            unknownTag(name);
        }
    } catch (Throwable t) {
        handleException(t);
    }
}
Also used : BwAuthUser(org.bedework.calfacade.svc.BwAuthUser) BwCategory(org.bedework.calfacade.BwCategory) BwEventProperty(org.bedework.calfacade.BwEventProperty) BwCalendar(org.bedework.calfacade.BwCalendar) BwContact(org.bedework.calfacade.BwContact)

Example 97 with BwCalendar

use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.

the class Restore method makeUserHome.

private void makeUserHome(final BwCalendar userRoot, final BwPrincipal user) throws Throwable {
    // Create root user home and default calendar
    final BwCalendar userHome = makeCal(userRoot, user, BwCalendar.calTypeFolder, user.getAccount(), null);
    makeCal(userHome, user, BwCalendar.calTypeCalendarCollection, RestoreGlobals.getBasicSyspars().getUserDefaultCalendar(), null);
}
Also used : BwCalendar(org.bedework.calfacade.BwCalendar)

Example 98 with BwCalendar

use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.

the class Restore method makeCal.

private BwCalendar makeCal(final BwCalendar parent, final BwPrincipal owner, final int type, final String name, final String encodedAcl) throws Throwable {
    final BwCalendar cal = new BwCalendar();
    cal.setCalType(type);
    String ppath = null;
    if (parent != null) {
        ppath = parent.getPath();
    }
    cal.setColPath(ppath);
    cal.setName(name);
    cal.setPath(Util.buildPath(colPathEndsWithSlash, ppath, "/", cal.getName()));
    cal.setSummary(cal.getName());
    cal.setOwnerHref(owner.getPrincipalRef());
    cal.setCreatorHref(owner.getPrincipalRef());
    cal.setAccess(encodedAcl);
    globals.rintf.saveRootCalendar(cal);
    return cal;
}
Also used : BwCalendar(org.bedework.calfacade.BwCalendar)

Example 99 with BwCalendar

use of org.bedework.calfacade.BwCalendar in project bw-calendar-engine by Bedework.

the class CollectionLastmodRule method end.

public void end(String ns, String name) throws Exception {
    BwCollectionLastmod lm = (BwCollectionLastmod) pop();
    BwCalendar ent = (BwCalendar) top();
    ent.setLastmod(lm);
    lm.setDbEntity(ent);
}
Also used : BwCollectionLastmod(org.bedework.calfacade.BwCollectionLastmod) BwCalendar(org.bedework.calfacade.BwCalendar)

Example 100 with BwCalendar

use of org.bedework.calfacade.BwCalendar 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)

Aggregations

BwCalendar (org.bedework.calfacade.BwCalendar)134 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)46 EventInfo (org.bedework.calfacade.svc.EventInfo)23 BwEvent (org.bedework.calfacade.BwEvent)19 ArrayList (java.util.ArrayList)18 CalFacadeAccessException (org.bedework.calfacade.exc.CalFacadeAccessException)18 BwPrincipal (org.bedework.calfacade.BwPrincipal)15 TreeSet (java.util.TreeSet)10 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)10 BwCategory (org.bedework.calfacade.BwCategory)10 BwResource (org.bedework.calfacade.BwResource)10 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)9 FilterBase (org.bedework.caldav.util.filter.FilterBase)8 BwPreferences (org.bedework.calfacade.svc.BwPreferences)8 BwEventProxy (org.bedework.calfacade.BwEventProxy)7 CalendarWrapper (org.bedework.calfacade.wrappers.CalendarWrapper)7 CurrentAccess (org.bedework.access.Acl.CurrentAccess)6 CalendarsI (org.bedework.calsvci.CalendarsI)6 Acl (org.bedework.access.Acl)5 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)5