X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2Finternal%2Fhttp%2FCmsSessionProvider.java;h=f21f72441c0c549f349bf98ef838b0452789ef28;hb=3779305ca2c08e66d9ba2061c76eb79e278860fb;hp=943decaf8a61e19376c7b32d8df04fa887e08d47;hpb=6a62c05a487ba34946b1924a039603e68b1d54e6;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/internal/http/CmsSessionProvider.java b/org.argeo.cms/src/org/argeo/cms/internal/http/CmsSessionProvider.java index 943decaf8..f21f72441 100644 --- a/org.argeo.cms/src/org/argeo/cms/internal/http/CmsSessionProvider.java +++ b/org.argeo.cms/src/org/argeo/cms/internal/http/CmsSessionProvider.java @@ -35,41 +35,23 @@ public class CmsSessionProvider implements SessionProvider, Serializable { public Session getSession(HttpServletRequest request, Repository rep, String workspace) throws javax.jcr.LoginException, ServletException, RepositoryException { + // a client is scanning parent URLs. +// if (workspace == null) +// return null; + CmsSessionImpl cmsSession = WebCmsSessionImpl.getCmsSession(request); - // if (cmsSession == null) - // return anonymousSession(request, rep, workspace); if (log.isTraceEnabled()) { - log.debug("Get JCR session from " + cmsSession); + log.trace("Get JCR session from " + cmsSession); } + if (cmsSession == null) + throw new IllegalStateException("Cannot find a session for request " + request.getRequestURI()); Session session = cmsSession.getDataSession(alias, workspace, rep); cmsSessions.put(session, cmsSession); return session; } - // private synchronized Session anonymousSession(HttpServletRequest request, - // Repository repository, String workspace) { - // // TODO rather log in here as anonymous? - // LoginContext lc = (LoginContext) - // request.getAttribute(NodeConstants.LOGIN_CONTEXT_ANONYMOUS); - // if (lc == null) - // throw new CmsException("No login context available"); - // // optimize - // Session session; - // try { - // session = Subject.doAs(lc.getSubject(), new - // PrivilegedExceptionAction() { - // @Override - // public Session run() throws Exception { - // return repository.login(workspace); - // } - // }); - // } catch (Exception e) { - // throw new CmsException("Cannot log in to JCR", e); - // } - // return session; - // } - - public synchronized void releaseSession(Session session) { + public void releaseSession(Session session) { +// JcrUtils.logoutQuietly(session); if (cmsSessions.containsKey(session)) { CmsSessionImpl cmsSession = cmsSessions.get(session); cmsSession.releaseDataSession(alias, session);