Search in sources :

Example 6 with WebdavException

use of org.bedework.webdav.servlet.shared.WebdavException 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 7 with WebdavException

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

the class BwSysIntfImpl method getCalPrincipalInfo.

private CalPrincipalInfo getCalPrincipalInfo(final BwPrincipalInfo pi) throws WebdavException {
    try {
        // SCHEDULE - just get home path and get default cal from user prefs.
        String userHomePath = Util.buildPath(false, "/", basicSysProperties.getUserCalendarRoot());
        if (pi.getPrincipalHref() == null) {
            return new CalPrincipalInfo(null, pi.getCard(), pi.getCardStr(), // userHomePath,
            null, // defaultCalendarPath,
            null, // inboxPath,
            null, // outboxPath,
            null, // notificationsPath,
            null, 0);
        }
        final BwPrincipal p = getSvci().getDirectories().getPrincipal(pi.getPrincipalHref());
        if (pi.getPrincipalHref().startsWith(BwPrincipal.userPrincipalRoot)) {
            userHomePath = Util.buildPath(true, userHomePath, pi.getPrincipalHref().substring(BwPrincipal.userPrincipalRoot.length()));
        } else {
            userHomePath = Util.buildPath(true, userHomePath, pi.getPrincipalHref());
        }
        final String defaultCalendarPath = Util.buildPath(true, userHomePath + basicSysProperties.getUserDefaultCalendar());
        final String inboxPath = Util.buildPath(true, userHomePath, "/", basicSysProperties.getUserInbox());
        final String outboxPath = Util.buildPath(true, userHomePath, "/", basicSysProperties.getUserOutbox());
        final String notificationsPath = Util.buildPath(true, userHomePath, "/", basicSysProperties.getDefaultNotificationsName());
        return new CalPrincipalInfo(p, pi.getCard(), pi.getCardStr(), userHomePath, defaultCalendarPath, inboxPath, outboxPath, notificationsPath, 0);
    } catch (final Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : BwPrincipal(org.bedework.calfacade.BwPrincipal) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) CalPrincipalInfo(org.bedework.caldav.server.sysinterface.CalPrincipalInfo)

Example 8 with WebdavException

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

the class BwSysIntfImpl method getFreebusySet.

/* ====================================================================
   *                   Scheduling
   * ==================================================================== */
@Override
public Collection<String> getFreebusySet() throws WebdavException {
    try {
        Collection<BwCalendar> cals = svci.getScheduler().getFreebusySet();
        Collection<String> hrefs = new ArrayList<String>();
        if (cals == null) {
            return hrefs;
        }
        for (BwCalendar cal : cals) {
            hrefs.add(getUrlHandler().prefix(cal.getPath()));
        // hrefs.add(getUrlPrefix() + cal.getPath());
        }
        return hrefs;
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : ArrayList(java.util.ArrayList) WebdavException(org.bedework.webdav.servlet.shared.WebdavException) BwCalendar(org.bedework.calfacade.BwCalendar)

Example 9 with WebdavException

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

the class BwSysIntfImpl method toIcalString.

@Override
public String toIcalString(final Calendar cal, final String contentType) throws WebdavException {
    try {
        String ctype = null;
        if (contentType != null) {
            final String[] contentTypePars = contentType.split(";");
            ctype = contentTypePars[0];
        }
        if (ctype == null) {
            throw new WebdavException("Null content type");
        }
        if (ctype.equals("text/calendar")) {
            return IcalTranslator.toIcalString(cal);
        }
        if (ctype.equals("application/calendar+json")) {
            return IcalTranslator.toJcal(cal, null);
        }
        throw new WebdavException("Unhandled content type" + contentType);
    } catch (Throwable t) {
        throw new WebdavException(t);
    }
}
Also used : WebdavException(org.bedework.webdav.servlet.shared.WebdavException)

Example 10 with WebdavException

use of org.bedework.webdav.servlet.shared.WebdavException 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)

Aggregations

WebdavException (org.bedework.webdav.servlet.shared.WebdavException)55 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)32 BwEvent (org.bedework.calfacade.BwEvent)20 WebdavForbidden (org.bedework.webdav.servlet.shared.WebdavForbidden)20 CalFacadeAccessException (org.bedework.calfacade.exc.CalFacadeAccessException)13 UpdateResult (org.bedework.caldav.server.sysinterface.SysIntf.UpdateResult)11 BwCalendar (org.bedework.calfacade.BwCalendar)10 ChangeTableEntry (org.bedework.calfacade.util.ChangeTableEntry)10 ArrayList (java.util.ArrayList)9 EventInfo (org.bedework.calfacade.svc.EventInfo)9 WebdavBadRequest (org.bedework.webdav.servlet.shared.WebdavBadRequest)8 BwDateTime (org.bedework.calfacade.BwDateTime)7 BwString (org.bedework.calfacade.BwString)6 DateDatetimePropertyType (ietf.params.xml.ns.icalendar_2.DateDatetimePropertyType)4 TextPropertyType (ietf.params.xml.ns.icalendar_2.TextPropertyType)3 Holder (javax.xml.ws.Holder)3 CalDAVEvent (org.bedework.caldav.server.CalDAVEvent)3 SysiIcalendar (org.bedework.caldav.server.SysiIcalendar)3 CalPrincipalInfo (org.bedework.caldav.server.sysinterface.CalPrincipalInfo)3 BwCategory (org.bedework.calfacade.BwCategory)3