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);
}
}
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);
}
}
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);
}
}
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);
}
}
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);
}
Aggregations