/** * @param resource * @return JCR session */ private static Session getRepositorySession(ObservationResource resource) throws DavException { return JcrDavSession.getRepositorySession(resource.getSession()); }
/** * Remove the event listener defined by the specified subscription from * the repository's observation manager and clean up the references present * on the <code>DavSession</code>. * * @param subscription * @param resource * @throws DavException */ private void unregisterSubscription(SubscriptionImpl subscription, ObservationResource resource) throws DavException { try { Session session = getRepositorySession(resource); session.getWorkspace().getObservationManager().removeEventListener(subscription); String sId = subscription.getSubscriptionId(); // clean up any references subscriptions.remove(sId); resource.getSession().removeReference(sId); } catch (RepositoryException e) { log.error("Unable to remove eventlistener: "+e.getMessage()); throw new JcrDavException(e); } }
/** * Create a new <code>Subscription</code> with the given {@link SubscriptionInfo} * and {@link org.apache.jackrabbit.webdav.observation.ObservationResource resource}. * * @param info * @param resource * @throws DavException if resource is not based on a JCR repository or * the repository does not support observation. */ public SubscriptionImpl(SubscriptionInfo info, ObservationResource resource) throws DavException { setInfo(info); locator = resource.getLocator(); session = JcrDavSession.getRepositorySession(resource.getSession()); try { obsMgr = session.getWorkspace().getObservationManager(); } catch (RepositoryException e) { throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR, e); } }
resource.getSession().addReference(newSubs.getSubscriptionId()); subscription = newSubs; } else {