Search in sources :

Example 16 with BwPreferences

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

the class CalSuites method getResourcesPath.

/* ====================================================================
   *                   Resource methods
   *  =================================================================== */
public String getResourcesPath(final BwCalSuite suite, final ResourceClass cl) throws CalFacadeException {
    if (cl == ResourceClass.global) {
        return getBasicSyspars().getGlobalResourcesPath();
    }
    final BwPrincipal eventsOwner = getPrincipal(suite.getGroup().getOwnerHref());
    final String home = getSvc().getPrincipalInfo().getCalendarHomePath(eventsOwner);
    final BwPreferences prefs = getSvc().getPrefsHandler().get(eventsOwner);
    String col = null;
    if (cl == ResourceClass.admin) {
        col = prefs.getAdminResourcesDirectory();
        if (col == null) {
            col = ".adminResources";
        }
    } else if (cl == ResourceClass.calsuite) {
        col = prefs.getSuiteResourcesDirectory();
        if (col == null) {
            col = ".csResources";
        }
    }
    if (col != null) {
        return Util.buildPath(colPathEndsWithSlash, home, "/", col);
    }
    throw new RuntimeException("System error");
}
Also used : BwPrincipal(org.bedework.calfacade.BwPrincipal) BwPreferences(org.bedework.calfacade.svc.BwPreferences)

Example 17 with BwPreferences

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

the class Notifications method subscribe.

@Override
public void subscribe(final String principalHref, final List<String> emails) throws CalFacadeException {
    try {
        pushPrincipal(principalHref);
        final BwPreferences prefs = getSvc().getPrefsHandler().get();
        prefs.setNotificationToken(UUID.randomUUID().toString());
        getNoteClient().subscribe(principalHref, emails, prefs.getNotificationToken());
    } finally {
        popPrincipal();
    }
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences)

Example 18 with BwPreferences

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

the class Notifications method subscribe.

public void subscribe(final BwPrincipal principal, final List<String> emails) throws CalFacadeException {
    final BwPreferences prefs = getSvc().getPrefsHandler().get(principal);
    prefs.setNotificationToken(UUID.randomUUID().toString());
    getNoteClient().subscribe(principal.getPrincipalRef(), emails, prefs.getNotificationToken());
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences)

Example 19 with BwPreferences

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

the class Preferences method get.

/**
 * Get the preferences for the current user
 *
 * @return the preferences for the current user
 * @throws CalFacadeException
 */
@Override
public BwPreferences get() throws CalFacadeException {
    if (prefs != null) {
        if (prefs.getOwnerHref() == null) {
            if (getPrincipal().getUnauthenticated()) {
                return prefs;
            }
        } else if (prefs.getOwnerHref().equals(getPrincipal().getPrincipalRef())) {
            return prefs;
        }
    }
    prefs = fetch();
    if (prefs == null) {
        if (getPrincipal().getUnauthenticated()) {
            prefs = new BwPreferences();
            return prefs;
        }
        getSvc().getUsersHandler().initPrincipal(getPrincipal());
        prefs = fetch();
    }
    if (prefs == null) {
        throw new CalFacadeException("org.bedework.unable.to.initialise", getPrincipal().getAccount());
    }
    return prefs;
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 20 with BwPreferences

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

the class RestoreImpl method restoreUserPrefs.

@Override
public void restoreUserPrefs(final BwPreferences o) throws Throwable {
    try {
        startTransaction();
        /* If the indexer or some other activity is running this can result in
       * a preferences object being created. See if one exists.
       */
        BwPreferences p = getSvc().getPreferences(o.getOwnerHref());
        if (p != null) {
            warn("Found instance of preferences for " + o.getOwnerHref());
            o.setId(p.getId());
            // noinspection UnusedAssignment
            p = (BwPreferences) getSvc().merge(o);
        } else {
            p = o;
            /* Ensure views are unsaved objects */
            final Collection<BwView> v = p.getViews();
            if (v != null) {
                for (final BwView view : v) {
                    view.markUnsaved();
                }
            }
            p.markUnsaved();
        }
        getCal().saveOrUpdate(o);
    } finally {
        endTransaction();
    }
}
Also used : BwPreferences(org.bedework.calfacade.svc.BwPreferences) BwView(org.bedework.calfacade.svc.BwView)

Aggregations

BwPreferences (org.bedework.calfacade.svc.BwPreferences)28 BwView (org.bedework.calfacade.svc.BwView)7 BwCalendar (org.bedework.calfacade.BwCalendar)6 BwPrincipal (org.bedework.calfacade.BwPrincipal)6 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)5 EventInfo (org.bedework.calfacade.svc.EventInfo)5 BwEvent (org.bedework.calfacade.BwEvent)4 File (java.io.File)2 BwCategory (org.bedework.calfacade.BwCategory)2 UpdateResult (org.bedework.calfacade.svc.EventInfo.UpdateResult)2 SchedulingIntf (org.bedework.calsvc.scheduling.SchedulingIntf)2 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)2 TreeSet (java.util.TreeSet)1 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)1 UpdateEventResult (org.bedework.calcorei.CoreEventsI.UpdateEventResult)1 HibSession (org.bedework.calcorei.HibSession)1 BaseNotificationType (org.bedework.caldav.util.notifications.BaseNotificationType)1 NotificationType (org.bedework.caldav.util.notifications.NotificationType)1 ResourceChangeType (org.bedework.caldav.util.notifications.ResourceChangeType)1 UpdatedType (org.bedework.caldav.util.notifications.UpdatedType)1