Search in sources :

Example 16 with CalFacadeAccessException

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

the class BwSysIntfImpl method copyMove.

/* (non-Javadoc)
   * @see org.bedework.caldav.server.SysIntf#copyMove(org.bedework.caldav.server.CalDAVCollection, org.bedework.caldav.server.CalDAVCollection, boolean, boolean)
   */
@Override
public void copyMove(final CalDAVCollection from, final CalDAVCollection to, final boolean copy, final boolean overwrite) throws WebdavException {
    try {
        BwCalendar bwFrom = unwrap(from);
        BwCalendar bwTo = unwrap(to);
        if (!copy) {
            /* Move the from collection to the new location "to".
         * If the parent calendar is the same in both cases, this is just a rename.
         */
            if ((bwFrom.getColPath() == null) || (bwTo.getColPath() == null)) {
                throw new WebdavForbidden("Cannot move root");
            }
            if (bwFrom.getColPath().equals(bwTo.getColPath())) {
                // Rename
                getSvci().getCalendarsHandler().rename(bwFrom, to.getName());
                return;
            }
        }
    } catch (CalFacadeAccessException cfae) {
        throw new WebdavForbidden();
    } catch (CalFacadeException cfe) {
        throw new WebdavException(cfe);
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
    throw new WebdavException("unimplemented");
}
Also used : WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) BwCalendar(org.bedework.calfacade.BwCalendar) CalFacadeAccessException(org.bedework.calfacade.exc.CalFacadeAccessException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 17 with CalFacadeAccessException

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

the class BwSysIntfImpl method getSyncReport.

@Override
public SynchReportData getSyncReport(final String path, final String token, final int limit, final boolean recurse) throws WebdavException {
    try {
        String syncToken = null;
        if (token != null) {
            if (!token.startsWith("data:,")) {
                throw new WebdavForbidden(WebdavTags.validSyncToken, token);
            }
            syncToken = token.substring(6);
        }
        if ((syncToken != null) && (syncToken.length() == 16)) {
            // Force a full reload
            syncToken = null;
        }
        final SynchReport sr = getSvci().getSynchReport(path, syncToken, limit, recurse);
        if (sr == null) {
            return null;
        }
        final SynchReportData srd = new SynchReportData();
        srd.items = new ArrayList<>();
        srd.token = "data:," + sr.getToken();
        srd.truncated = sr.getTruncated();
        for (final SynchReportItem sri : sr.getItems()) {
            final SynchReportDataItem srdi;
            if (sri.getEvent() != null) {
                srdi = new SynchReportDataItem(sri.getVpath(), new BwCalDAVEvent(this, sri.getEvent()), sri.getToken());
            } else if (sri.getResource() != null) {
                srdi = new SynchReportDataItem(sri.getVpath(), new BwCalDAVResource(this, sri.getResource()), sri.getToken());
            } else if (sri.getCol() != null) {
                srdi = new SynchReportDataItem(sri.getVpath(), new BwCalDAVCollection(this, sri.getCol()), sri.getToken(), sri.getCanSync());
            } else {
                throw new RuntimeException("Unhandled sync report item type");
            }
            srd.items.add(srdi);
        }
        return srd;
    } catch (final CalFacadeAccessException cfae) {
        throw new WebdavForbidden();
    } catch (final CalFacadeInvalidSynctoken cist) {
        throw new WebdavBadRequest(WebdavTags.validSyncToken);
    } catch (final CalFacadeException cfe) {
        throw new WebdavException(cfe);
    } catch (final WebdavException we) {
        throw we;
    } catch (final Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : WebdavBadRequest(org.bedework.webdav.servlet.shared.WebdavBadRequest) WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) CalFacadeAccessException(org.bedework.calfacade.exc.CalFacadeAccessException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) SynchReport(org.bedework.calsvci.SynchReport) SynchReportDataItem(org.bedework.caldav.server.sysinterface.SysIntf.SynchReportData.SynchReportDataItem) CalFacadeInvalidSynctoken(org.bedework.calfacade.exc.CalFacadeInvalidSynctoken) SynchReportItem(org.bedework.calsvci.SynchReportItem)

Example 18 with CalFacadeAccessException

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

the class BwSysIntfImpl method schedule.

@Override
public Collection<SchedRecipientResult> schedule(final CalDAVEvent ev) throws WebdavException {
    try {
        ScheduleResult sr;
        BwEvent event = getEvent(ev);
        event.setOwnerHref(currentPrincipal.getPrincipalRef());
        if (Icalendar.itipReplyMethodType(event.getScheduleMethod())) {
            sr = getSvci().getScheduler().scheduleResponse(getEvinfo(ev));
        } else {
            sr = getSvci().getScheduler().schedule(getEvinfo(ev), null, null, // iSchedule
            true);
        }
        return checkStatus(sr);
    } catch (WebdavException we) {
        throw we;
    } catch (CalFacadeAccessException cfae) {
        throw new WebdavForbidden();
    } catch (CalFacadeException cfe) {
        if (CalFacadeException.duplicateGuid.equals(cfe.getMessage())) {
            throw new WebdavBadRequest("Duplicate-guid");
        }
        throw new WebdavException(cfe);
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : WebdavBadRequest(org.bedework.webdav.servlet.shared.WebdavBadRequest) ScheduleResult(org.bedework.calfacade.ScheduleResult) WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) BwEvent(org.bedework.calfacade.BwEvent) CalFacadeAccessException(org.bedework.calfacade.exc.CalFacadeAccessException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 19 with CalFacadeAccessException

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

the class BwSysIntfImpl method addEvent.

/* ====================================================================
   *                   Events
   * ==================================================================== */
/* (non-Javadoc)
   * @see org.bedework.caldav.server.SysIntf#addEvent(org.bedework.caldav.server.CalDAVEvent, boolean, boolean)
   */
@Override
public Collection<CalDAVEvent> addEvent(final CalDAVEvent ev, final boolean noInvites, final boolean rollbackOnError) throws WebdavException {
    try {
        /* Is the event a scheduling object? */
        final EventInfo ei = getEvinfo(ev);
        final Collection<BwEventProxy> bwevs = getSvci().getEventsHandler().add(ei, noInvites, // scheduling - inbox
        false, // autocreate
        false, rollbackOnError).failedOverrides;
        if (bwevs == null) {
            return null;
        }
        final Collection<CalDAVEvent> evs = new ArrayList<CalDAVEvent>();
        for (final BwEvent bwev : bwevs) {
            evs.add(new BwCalDAVEvent(this, new EventInfo(bwev)));
        }
        return evs;
    } catch (final CalFacadeAccessException cfae) {
        throw new WebdavForbidden();
    } catch (final CalFacadeException cfe) {
        if (CalFacadeException.schedulingTooManyAttendees.equals(cfe.getDetailMessage())) {
            throw new WebdavForbidden(CaldavTags.maxAttendeesPerInstance, ev.getParentPath() + "/" + cfe.getExtra());
        }
        if (CalFacadeException.invalidOverride.equals(cfe.getDetailMessage())) {
            throw new WebdavForbidden(CaldavTags.validCalendarData, ev.getParentPath() + "/" + cfe.getExtra());
        }
        if (CalFacadeException.duplicateGuid.equals(cfe.getDetailMessage())) {
            throw new WebdavForbidden(CaldavTags.noUidConflict, ev.getParentPath() + "/" + cfe.getExtra());
        }
        if (CalFacadeException.duplicateName.equals(cfe.getDetailMessage())) {
            throw new WebdavForbidden(CaldavTags.noUidConflict, ev.getParentPath() + "/" + ev.getName());
        }
        throw new WebdavException(cfe);
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : EventInfo(org.bedework.calfacade.svc.EventInfo) WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) ArrayList(java.util.ArrayList) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) BwEvent(org.bedework.calfacade.BwEvent) BwEventProxy(org.bedework.calfacade.BwEventProxy) CalFacadeAccessException(org.bedework.calfacade.exc.CalFacadeAccessException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) CalDAVEvent(org.bedework.caldav.server.CalDAVEvent)

Example 20 with CalFacadeAccessException

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

the class CoreCalendars method resolveAlias.

/*
    indexer != null => Use ES for the searches
   */
private BwCalendar resolveAlias(final BwCalendar val, final boolean resolveSubAlias, final boolean freeBusy, final ArrayList<String> pathElements, final BwIndexer indexer) throws CalFacadeException {
    if ((val == null) || !val.getInternalAlias()) {
        return val;
    }
    final BwCalendar c = val.getAliasTarget();
    if (c != null) {
        if (!resolveSubAlias) {
            return c;
        }
        final BwCalendar res = resolveAlias(c, true, freeBusy, pathElements, indexer);
        res.setAliasOrigin(val);
        return res;
    }
    if (val.getDisabled()) {
        return null;
    }
    int desiredAccess = privRead;
    if (freeBusy) {
        desiredAccess = privReadFreeBusy;
    }
    final String path = val.getInternalAliasPath();
    if (pathElements.contains(path)) {
        disableAlias(val);
        return null;
    }
    pathElements.add(path);
    // if (debug) {
    // trace("Search for calendar \"" + path + "\"");
    // }
    BwCalendar col;
    try {
        if (indexer != null) {
            col = getCollectionIdx(indexer, path, desiredAccess, false);
        } else {
            col = getCalendar(path, desiredAccess, false);
        }
    } catch (final CalFacadeAccessException cfae) {
        col = null;
    }
    if (col == null) {
        /* Assume deleted - flag in the subscription if it's ours or a temp.
       */
        if ((val.getId() == CalFacadeDefs.unsavedItemKey) || val.getOwnerHref().equals(getPrincipal().getPrincipalRef())) {
            disableAlias(val);
        }
        return null;
    }
    val.setAliasTarget(col);
    if (!resolveSubAlias) {
        col.setAliasOrigin(val);
        return col;
    }
    final BwCalendar res = resolveAlias(col, true, freeBusy, pathElements, indexer);
    res.setAliasOrigin(val);
    return res;
}
Also used : BwCalendar(org.bedework.calfacade.BwCalendar) CalFacadeAccessException(org.bedework.calfacade.exc.CalFacadeAccessException)

Aggregations

CalFacadeAccessException (org.bedework.calfacade.exc.CalFacadeAccessException)29 BwCalendar (org.bedework.calfacade.BwCalendar)18 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)16 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)13 WebdavForbidden (org.bedework.webdav.servlet.shared.WebdavForbidden)13 EventInfo (org.bedework.calfacade.svc.EventInfo)7 BwEvent (org.bedework.calfacade.BwEvent)6 WebdavBadRequest (org.bedework.webdav.servlet.shared.WebdavBadRequest)6 ArrayList (java.util.ArrayList)5 TreeSet (java.util.TreeSet)3 CalFacadeForbidden (org.bedework.calfacade.exc.CalFacadeForbidden)3 Collection (java.util.Collection)2 CurrentAccess (org.bedework.access.Acl.CurrentAccess)2 CalDAVEvent (org.bedework.caldav.server.CalDAVEvent)2 FilterBase (org.bedework.caldav.util.filter.FilterBase)2 BwAttendee (org.bedework.calfacade.BwAttendee)2 BwCategory (org.bedework.calfacade.BwCategory)2 BwEventProxy (org.bedework.calfacade.BwEventProxy)2 BwPrincipal (org.bedework.calfacade.BwPrincipal)2 ScheduleResult (org.bedework.calfacade.ScheduleResult)2