Search in sources :

Example 31 with BwCalendar

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

the class Notifications method update.

@Override
public boolean update(final NotificationType val) throws CalFacadeException {
    if ((val == null) || (val.getNotification() == null) || (val.getNotification().getElementName() == null)) {
        return false;
    }
    try {
        final String xml = val.toXml(true);
        if (xml == null) {
            return false;
        }
        final BwCalendar ncol = getCols().getSpecial(BwCalendar.calTypeNotifications, true);
        if (ncol == null) {
            return false;
        }
        final BwResource noteRsrc = getSvc().getResourcesHandler().get(Util.buildPath(false, ncol.getPath(), "/", val.getName()));
        if (noteRsrc == null) {
            return false;
        }
        BwResourceContent rc = noteRsrc.getContent();
        if (rc == null) {
            rc = new BwResourceContent();
            noteRsrc.setContent(rc);
        }
        final byte[] xmlData = xml.getBytes();
        rc.setValue(getSvc().getBlob(xmlData));
        noteRsrc.setContentLength(xmlData.length);
        noteRsrc.setContentType(val.getContentType());
        getSvc().getResourcesHandler().update(noteRsrc, true);
        getNoteClient().informNotifier(getPrincipalHref(), noteRsrc.getName());
        return true;
    } catch (final CalFacadeException cfe) {
        throw cfe;
    } catch (final Throwable t) {
        throw new CalFacadeException(t);
    }
}
Also used : BwResource(org.bedework.calfacade.BwResource) BwResourceContent(org.bedework.calfacade.BwResourceContent) BwCalendar(org.bedework.calfacade.BwCalendar) CalFacadeException(org.bedework.calfacade.exc.CalFacadeException)

Example 32 with BwCalendar

use of org.bedework.calfacade.BwCalendar 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 33 with BwCalendar

use of org.bedework.calfacade.BwCalendar 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 34 with BwCalendar

use of org.bedework.calfacade.BwCalendar 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)

Example 35 with BwCalendar

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

the class BwSysIntfImpl method newCollectionObject.

/* ====================================================================
   *                   Collections
   * ==================================================================== */
/* (non-Javadoc)
   * @see org.bedework.caldav.server.SysIntf#newCollectionObject(boolean, java.lang.String)
   */
@Override
public CalDAVCollection newCollectionObject(final boolean isCalendarCollection, final String parentPath) throws WebdavException {
    BwCalendar col = new BwCalendar();
    if (isCalendarCollection) {
        col.setCalType(BwCalendar.calTypeCalendarCollection);
    } else {
        col.setCalType(BwCalendar.calTypeFolder);
    }
    col.setColPath(parentPath);
    col.setOwnerHref(currentPrincipal.getPrincipalRef());
    return new BwCalDAVCollection(this, col);
}
Also used : BwCalendar(org.bedework.calfacade.BwCalendar)

Aggregations

BwCalendar (org.bedework.calfacade.BwCalendar)134 CalFacadeException (org.bedework.calfacade.exc.CalFacadeException)46 EventInfo (org.bedework.calfacade.svc.EventInfo)23 BwEvent (org.bedework.calfacade.BwEvent)19 ArrayList (java.util.ArrayList)18 CalFacadeAccessException (org.bedework.calfacade.exc.CalFacadeAccessException)18 BwPrincipal (org.bedework.calfacade.BwPrincipal)15 TreeSet (java.util.TreeSet)10 CoreEventInfo (org.bedework.calcorei.CoreEventInfo)10 BwCategory (org.bedework.calfacade.BwCategory)10 BwResource (org.bedework.calfacade.BwResource)10 WebdavException (org.bedework.webdav.servlet.shared.WebdavException)9 FilterBase (org.bedework.caldav.util.filter.FilterBase)8 BwPreferences (org.bedework.calfacade.svc.BwPreferences)8 BwEventProxy (org.bedework.calfacade.BwEventProxy)7 CalendarWrapper (org.bedework.calfacade.wrappers.CalendarWrapper)7 CurrentAccess (org.bedework.access.Acl.CurrentAccess)6 CalendarsI (org.bedework.calsvci.CalendarsI)6 Acl (org.bedework.access.Acl)5 BwEventAnnotation (org.bedework.calfacade.BwEventAnnotation)5