use of org.bedework.caldav.util.sharing.UserType 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);
}
}
use of org.bedework.caldav.util.sharing.UserType in project bw-calendar-engine by Bedework.
the class Sharing method updateSharingStatus.
/* ====================================================================
* Private methods
* ==================================================================== */
/* This requires updating the shared calendar to reflect the accept/decline
* status
*/
private boolean updateSharingStatus(final String sharerHref, final String path, final InviteReplyType reply, final Holder<AccessType> access) throws CalFacadeException {
pushPrincipal(sharerHref);
try {
final BwCalendar col = getCols().get(path);
if (col == null) {
// Bad hosturl?
throw new CalFacadeForbidden(CalFacadeException.shareTargetNotFound);
}
/* See if we have an outstanding invite for this user */
final QName qn = new QName(AppleServerTags.inviteNotification.getNamespaceURI(), AppleServerTags.inviteNotification.getLocalPart() + reply.getInReplyTo());
final String pname = NamespaceAbbrevs.prefixed(qn);
final String xmlInvite = col.getProperty(pname);
if (xmlInvite == null) {
// No invite
if (debug) {
trace("No invite notification on collection with name: " + pname);
}
throw new CalFacadeForbidden(CalFacadeException.noInvite);
}
/* Remove the invite */
col.setProperty(pname, null);
/* Get the invite property and locate and update this sharee */
final InviteType invite = getInviteStatus(col);
UserType uentry = null;
final String invitee = getSvc().getDirectories().normalizeCua(reply.getHref());
if (invite != null) {
uentry = invite.finduser(invitee);
}
if (uentry == null) {
if (debug) {
trace("Cannot find invitee: " + invitee);
}
throw new CalFacadeForbidden(CalFacadeException.noInviteeInUsers);
}
if (reply.testAccepted()) {
uentry.setInviteStatus(AppleServerTags.inviteAccepted);
} else {
uentry.setInviteStatus(AppleServerTags.inviteDeclined);
}
access.value = uentry.getAccess();
col.setProperty(NamespaceAbbrevs.prefixed(AppleServerTags.invite), invite.toXml());
getCols().update(col);
/* Now send the sharer the reply as a notification */
final NotificationType note = new NotificationType();
note.setDtstamp(new DtStamp(new DateTime(true)).getValue());
final InviteReplyType irt = (InviteReplyType) reply.clone();
note.setNotification(irt);
/* Fill in the summary (the sharer's summary) on the reply. */
irt.setSummary(reply.getSummary());
getSvc().getNotificationsHandler().add(note);
return irt.testAccepted();
} catch (final CalFacadeException cfe) {
throw cfe;
} catch (final Throwable t) {
throw new CalFacadeException(t);
} finally {
popPrincipal();
}
}
Aggregations