Search in sources :

Example 1 with AliasesInfo

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

the class Calendars method findAliases.

private void findAliases(final BwCalendar col, final AliasesInfo rootAi) throws CalFacadeException {
    final String collectionHref = col.getPath();
    final boolean defaultEnabled = !Boolean.valueOf(System.getProperty("org.bedework.nochangenote", "false")) && getAuthpars().getDefaultChangesNotifications();
    if (notificationsEnabled(col, defaultEnabled)) {
        rootAi.setNotificationsEnabled(true);
    }
    /* Handle aliases that are not a result of calendar sharing.  These could be public or private.
     */
    for (final BwCalendar alias : findAlias(collectionHref)) {
        final AliasesInfo ai = new AliasesInfo(getPrincipal().getPrincipalRef(), alias, null);
        rootAi.addSharee(ai);
        findAliases(alias, ai);
    }
    /* for each sharee in the list find user collection(s) pointing to this
     * collection and add the sharee if any are enabled for notifications.
     */
    final InviteType invite = getSvc().getSharingHandler().getInviteStatus(col);
    if (invite == null) {
        // No sharees
        return;
    }
    /* for sharees - it's the alias which points at this collection
     * which holds the status.
     */
    for (final UserType u : invite.getUsers()) {
        final BwPrincipal principal = caladdrToPrincipal(u.getHref());
        if (principal == null) {
            final AliasesInfo ai = new AliasesInfo(u.getHref(), col, null);
            ai.setExternalCua(true);
            rootAi.addSharee(ai);
            continue;
        }
        try {
            pushPrincipal(principal);
            for (final BwCalendar alias : findAlias(collectionHref)) {
                if (!notificationsEnabled(alias, defaultEnabled)) {
                    continue;
                }
                final AliasesInfo ai = new AliasesInfo(principal.getPrincipalRef(), alias, null);
                rootAi.addSharee(ai);
                findAliases(alias, ai);
            }
        } finally {
            popPrincipal();
        }
    }
}
Also used : AliasesInfo(org.bedework.calfacade.AliasesInfo) BwPrincipal(org.bedework.calfacade.BwPrincipal) InviteType(org.bedework.caldav.util.sharing.InviteType) BwCalendar(org.bedework.calfacade.BwCalendar) UserType(org.bedework.caldav.util.sharing.UserType)

Example 2 with AliasesInfo

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

the class Notifier method doChangeNotification.

private ProcessMessageResult doChangeNotification(final OwnedHrefEvent msg, final NotificationType note) throws CalFacadeException {
    try {
        getSvci(msg.getOwnerHref());
        // Normalized
        final String ownerHref = getPrincipalHref();
        final String href = msg.getHref();
        if (debug) {
            trace(msg.toString());
            trace("Notification for entity " + href + " owner principal " + ownerHref);
        }
        final String[] split = Util.splitName(href);
        final AliasesInfo ai = getCols().getAliasesInfo(split[0], split[1]);
        if (ai == null) {
            // path pointing to non-existent collection
            return ProcessMessageResult.PROCESSED;
        }
        if (!ai.getShared()) {
            return ProcessMessageResult.PROCESSED;
        }
        if (!(note.getNotification() instanceof ResourceChangeType)) {
            // Don't know what to do with that
            return ProcessMessageResult.PROCESSED;
        }
        final ResourceChangeType rc = (ResourceChangeType) note.getNotification();
        // SCHEMA - encoding is the base64 encoded name
        if (rc.getEncoding() == null) {
            // No changes were added
            return ProcessMessageResult.PROCESSED;
        }
        if (processAliasInfo(ai, msg.getAuthPrincipalHref(), rc)) {
            return ProcessMessageResult.PROCESSED;
        }
        return ProcessMessageResult.IGNORED;
    } finally {
        closeSvci(getSvc());
    }
}
Also used : AliasesInfo(org.bedework.calfacade.AliasesInfo) ResourceChangeType(org.bedework.caldav.util.notifications.ResourceChangeType)

Example 3 with AliasesInfo

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

the class Calendars method updateAliasInfoMap.

private AliasesInfo updateAliasInfoMap(final AliasesInfo ai) {
    synchronized (aliasesInfoMap) {
        final String key = ai.makeKey();
        final AliasesInfo mapAi = aliasesInfoMap.get(key);
        if (mapAi != null) {
            // Somebody got there before us.
            return mapAi;
        }
        aliasesInfoMap.put(key, ai);
        return ai;
    }
}
Also used : AliasesInfo(org.bedework.calfacade.AliasesInfo)

Example 4 with AliasesInfo

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

the class Calendars method checkAliases.

/* ====================================================================
   *                   private methods
   * ==================================================================== */
private void checkAliases(final AliasesInfo rootAi, final String entityName) throws CalFacadeException {
    final Events eventsH = (Events) getSvc().getEventsHandler();
    for (final AliasesInfo ai : rootAi.getAliases()) {
        final boolean isVisible = eventsH.isVisible(ai.getCollection(), entityName);
        final AliasesInfo eai = ai.copyForEntity(entityName, isVisible);
        rootAi.addSharee(eai);
        checkAliases(eai, entityName);
    }
}
Also used : AliasesInfo(org.bedework.calfacade.AliasesInfo)

Example 5 with AliasesInfo

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

the class Calendars method getAliasesInfo.

private AliasesInfo getAliasesInfo(final String collectionHref) throws CalFacadeException {
    AliasesInfo ai = aliasesInfoMap.get(AliasesInfo.makeKey(collectionHref, null));
    if (ai != null) {
        return ai;
    }
    final BwCalendar col = getCal().getCalendar(collectionHref, PrivilegeDefs.privAny, true);
    if (col == null) {
        return null;
    }
    ai = new AliasesInfo(getPrincipal().getPrincipalRef(), col, null);
    findAliases(col, ai);
    return updateAliasInfoMap(ai);
}
Also used : AliasesInfo(org.bedework.calfacade.AliasesInfo) BwCalendar(org.bedework.calfacade.BwCalendar)

Aggregations

AliasesInfo (org.bedework.calfacade.AliasesInfo)5 BwCalendar (org.bedework.calfacade.BwCalendar)2 ResourceChangeType (org.bedework.caldav.util.notifications.ResourceChangeType)1 InviteType (org.bedework.caldav.util.sharing.InviteType)1 UserType (org.bedework.caldav.util.sharing.UserType)1 BwPrincipal (org.bedework.calfacade.BwPrincipal)1