Search in sources :

Example 1 with WebdavForbidden

use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.

the class BwSysIntfImpl method getEvents.

@Override
public Collection<CalDAVEvent> getEvents(final CalDAVCollection col, final FilterBase filter, final List<String> retrieveList, final RetrievalMode recurRetrieval) throws WebdavException {
    try {
        /* Limit the results to just this collection by adding an ANDed filter */
        final SimpleFilterParser sfp = getSvci().getFilterParser();
        final String expr = "(colPath='" + SfpTokenizer.escapeQuotes(col.getPath()) + "')";
        final ParseResult pr = sfp.parse(expr, true, null);
        if (!pr.ok) {
            throw new WebdavBadRequest("Failed to reference collection " + col.getPath() + ": message was " + pr.message);
        }
        final FilterBase f = FilterBase.addAndChild(filter, pr.filter);
        final Collection<EventInfo> bwevs = // Collection
        getSvci().getEventsHandler().getEvents(// Collection
        null, f, // start
        null, // end
        null, RetrieveList.getRetrieveList(retrieveList), DeletedState.noDeleted, getRrm(recurRetrieval));
        if (bwevs == null) {
            return null;
        }
        final Collection<CalDAVEvent> evs = new ArrayList<>();
        for (final EventInfo ei : bwevs) {
            if (recurRetrieval != null) {
                ei.getEvent().setForceUTC(recurRetrieval.getExpand() != null);
            }
            evs.add(new BwCalDAVEvent(this, ei));
        }
        return evs;
    } catch (final CalFacadeAccessException cfae) {
        throw new WebdavForbidden();
    } catch (final CalFacadeException cfe) {
        if (CalFacadeException.unknownProperty.equals(cfe.getMessage())) {
            throw new WebdavBadRequest("Unknown property " + cfe.getExtra());
        }
        throw new WebdavException(cfe);
    } catch (final WebdavException wde) {
        throw wde;
    } catch (final Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : WebdavBadRequest(org.bedework.webdav.servlet.shared.WebdavBadRequest) ParseResult(org.bedework.calfacade.filter.SimpleFilterParser.ParseResult) EventInfo(org.bedework.calfacade.svc.EventInfo) WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) ArrayList(java.util.ArrayList) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) SimpleFilterParser(org.bedework.calfacade.filter.SimpleFilterParser) CalFacadeAccessException(org.bedework.calfacade.exc.CalFacadeAccessException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException) CalDAVEvent(org.bedework.caldav.server.CalDAVEvent) FilterBase(org.bedework.caldav.util.filter.FilterBase)

Example 2 with WebdavForbidden

use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.

the class BwSysIntfImpl method updateEvent.

@Override
public UpdateResult updateEvent(final CalDAVEvent event, final List<ComponentSelectionType> updates) throws WebdavException {
    try {
        EventInfo ei = getEvinfo(event);
        if (updates == null) {
            return new UpdateResult("No updates");
        }
        UpdateResult ur = new BwUpdates(getPrincipal().getPrincipalRef()).updateEvent(ei, updates, getSvci().getIcalCallback());
        if (!ur.getOk()) {
            getSvci().rollbackTransaction();
            return ur;
        }
        getSvci().getEventsHandler().update(ei, false);
        return ur;
    } catch (CalFacadeAccessException cfae) {
        throw new WebdavForbidden();
    } catch (CalFacadeForbidden cff) {
        throw new WebdavForbidden(cff.getQname(), cff.getMessage());
    } 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) EventInfo(org.bedework.calfacade.svc.EventInfo) WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) CalFacadeForbidden(org.bedework.calfacade.exc.CalFacadeForbidden) CalFacadeAccessException(org.bedework.calfacade.exc.CalFacadeAccessException) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 3 with WebdavForbidden

use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.

the class BwSysIntfImpl method getInviteStatus.

@Override
public InviteType getInviteStatus(final CalDAVCollection col) throws WebdavException {
    try {
        InviteType inv = svci.getSharingHandler().getInviteStatus(unwrap(col));
        if (inv == null) {
            return null;
        }
        UrlHandler uh = getUrlHandler();
        for (UserType u : inv.getUsers()) {
            u.setHref(uh.prefix(u.getHref()));
        }
        return inv;
    } catch (CalFacadeForbidden cf) {
        throw new WebdavForbidden(cf.getMessage());
    } catch (WebdavException we) {
        throw we;
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : UrlHandler(org.bedework.webdav.servlet.shared.UrlHandler) WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) InviteType(org.bedework.caldav.util.sharing.InviteType) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) CalFacadeForbidden(org.bedework.calfacade.exc.CalFacadeForbidden) UserType(org.bedework.caldav.util.sharing.UserType)

Example 4 with WebdavForbidden

use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.

the class BwSysIntfImpl method getCollections.

@Override
public Collection<CalDAVCollection> getCollections(final CalDAVCollection col) throws WebdavException {
    try {
        final BwCalendar bwCol = unwrap(col);
        boolean isUserHome = false;
        List<Integer> provisionedTypes = null;
        /* Is this the calendar home? If so we have to ensure all
         provisioned collections exist */
        if (getPrincipal() != null) {
            final String userHomePath = Util.buildPath(true, getSvci().getPrincipalInfo().getCalendarHomePath(getPrincipal()));
            if (Util.buildPath(true, bwCol.getPath()).equals(userHomePath)) {
                isUserHome = true;
                provisionedTypes = new ArrayList<>();
                for (final BwCalendar.CollectionInfo ci : BwCalendar.getAllCollectionInfo()) {
                    if (ci.provision) {
                        provisionedTypes.add(ci.collectionType);
                    }
                }
            }
        }
        final CalendarsI ci = getSvci().getCalendarsHandler();
        final Collection<BwCalendar> bwch = ci.getChildren(bwCol);
        final Collection<CalDAVCollection> ch = new ArrayList<>();
        if (bwch == null) {
            return ch;
        }
        for (final BwCalendar c : bwch) {
            if (bedeworkExtensionsEnabled() || !c.getName().startsWith(".")) {
                ci.resolveAlias(c, true, false);
                ch.add(new BwCalDAVCollection(this, c));
            }
            if (isUserHome && !c.getAlias()) {
                provisionedTypes.remove(new Integer(c.getCalType()));
            }
        }
        if (isUserHome && !provisionedTypes.isEmpty()) {
            // Need to add some
            for (final int colType : provisionedTypes) {
                final BwCalendar pcol = ci.getSpecial(currentPrincipal, colType, true, PrivilegeDefs.privAny);
                ch.add(new BwCalDAVCollection(this, pcol));
            }
        }
        return ch;
    } catch (final CalFacadeAccessException cfae) {
        throw new WebdavForbidden();
    } catch (final Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : WebdavForbidden(org.bedework.webdav.servlet.shared.WebdavForbidden) ArrayList(java.util.ArrayList) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) BwCalendar(org.bedework.calfacade.BwCalendar) CalendarsI(org.bedework.calsvci.CalendarsI) CalDAVCollection(org.bedework.caldav.server.CalDAVCollection) CalFacadeAccessException(org.bedework.calfacade.exc.CalFacadeAccessException)

Example 5 with WebdavForbidden

use of org.bedework.webdav.servlet.shared.WebdavForbidden in project bw-calendar-engine by Bedework.

the class BwSysIntfImpl method getCollection.

/* (non-Javadoc)
   * @see org.bedework.caldav.server.SysIntf#getCollection(java.lang.String)
   */
@Override
public CalDAVCollection getCollection(final String path) throws WebdavException {
    try {
        BwCalendar col = getSvci().getCalendarsHandler().get(path);
        if (col == null) {
            return null;
        }
        getSvci().getCalendarsHandler().resolveAlias(col, true, false);
        return new BwCalDAVCollection(this, col);
    } catch (CalFacadeAccessException cfae) {
        throw new WebdavForbidden();
    } catch (CalFacadeException cfe) {
        throw new WebdavException(cfe);
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
}
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)

Aggregations

WebdavForbidden (org.bedework.webdav.servlet.shared.WebdavForbidden)21 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)20 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)15 CalFacadeAccessException (org.bedework.calfacade.exc.CalFacadeAccessException)13 EventInfo (org.bedework.calfacade.svc.EventInfo)8 BwCalendar (org.bedework.calfacade.BwCalendar)7 WebdavBadRequest (org.bedework.webdav.servlet.shared.WebdavBadRequest)7 ArrayList (java.util.ArrayList)6 BwEvent (org.bedework.calfacade.BwEvent)4 SysiIcalendar (org.bedework.caldav.server.SysiIcalendar)3 CalFacadeForbidden (org.bedework.calfacade.exc.CalFacadeForbidden)3 Icalendar (org.bedework.icalendar.Icalendar)3 CalDAVEvent (org.bedework.caldav.server.CalDAVEvent)2 BwResource (org.bedework.calfacade.BwResource)2 ScheduleResult (org.bedework.calfacade.ScheduleResult)2 IcalMalformedException (org.bedework.icalendar.IcalMalformedException)2 UrlHandler (org.bedework.webdav.servlet.shared.UrlHandler)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 InputStream (java.io.InputStream)1