use of org.bedework.caldav.util.sharing.AccessType in project bw-calendar-engine by Bedework.
the class Sharing method reply.
@Override
public ReplyResult reply(final BwCalendar col, final InviteReplyType reply) throws CalFacadeException {
final BwCalendar home = getCols().getHome();
if (!home.getPath().equals(col.getPath())) {
throw new CalFacadeForbidden("Not calendar home");
}
/* We must have at least read access to the shared collection */
final BwCalendar sharerCol = getCols().get(Util.buildPath(colPathEndsWithSlash, reply.getHostUrl()));
if (sharerCol == null) {
// Bad hosturl
throw new CalFacadeForbidden("Bad hosturl or no access");
}
final Holder<AccessType> access = new Holder<>();
if (!updateSharingStatus(sharerCol.getOwnerHref(), sharerCol.getPath(), reply, access)) {
return null;
}
/* Accepted */
final AccessType at = access.value;
final boolean sharedWritable = (at != null) && at.testReadWrite();
/* This may be a change in access or a new sharing request. See if an alias
* already exists to the shared collection. If it does we're done.
* Otherwise we need to create an alias in the calendar home using the
* reply summary as the display name */
final List<BwCalendar> aliases = findAlias(sharerCol.getPath());
if (!Util.isEmpty(aliases)) {
final BwCalendar alias = aliases.get(0);
alias.setSharedWritable(sharedWritable);
getCols().update(alias);
return ReplyResult.success(alias.getPath());
}
final BwCalendar alias = new BwCalendar();
String summary = reply.getSummary();
if ((summary == null) || (summary.length() == 0)) {
summary = "Shared Calendar";
}
alias.setName(reply.getInReplyTo());
alias.setSummary(summary);
alias.setCalType(BwCalendar.calTypeAlias);
// alias.setPath(home.getPath() + "/" + UUID.randomUUID().toString());
alias.setAliasUri("bwcal://" + sharerCol.getPath());
alias.setShared(true);
alias.setSharedWritable(sharedWritable);
final BwCalendar createdAlias = getCols().add(alias, home.getPath());
return ReplyResult.success(createdAlias.getPath());
}
use of org.bedework.caldav.util.sharing.AccessType in project bw-calendar-engine by Bedework.
the class NotificationConf method sendInvite.
/* ========================================================================
* Operations
* ======================================================================== */
@Override
public String sendInvite(final String cua, final String href) {
try {
final ShareType share = new ShareType();
final SetType set = new SetType();
set.setHref(cua);
set.setSummary("Test Collection");
final AccessType at = new AccessType();
at.setRead(true);
set.setAccess(at);
share.getSet().add(set);
try (CalSvcI svci = getSvci(getNotifierId())) {
final BwCalendar col = svci.getCalendarsHandler().get(href);
if (col == null) {
return "No such collection";
}
svci.getSharingHandler().share(col, share);
}
svci.endTransaction();
return "ok";
} catch (final Throwable t) {
error(t);
return t.getLocalizedMessage();
}
}
Aggregations