Skip to content
Snippets Groups Projects
Commit 07f8d2fe authored by srosse's avatar srosse
Browse files

OO-5302: cache and share resource root across WebDAV user's sessions

parent 1088af99
No related branches found
No related tags found
No related merge requests found
......@@ -77,8 +77,10 @@ public class WebDAVManagerImpl implements WebDAVManager, InitializingBean {
private static boolean enabled = true;
public static final String BASIC_AUTH_REALM = "OLAT WebDAV Access";
private static final String DIR_CONTEXT = "_DIRCTX";
private CoordinatorManager coordinatorManager;
private CacheWrapper<Long,VFSResourceRoot> resourceCache;
private CacheWrapper<CacheKey,UserSession> timedSessionCache;
@Autowired
......@@ -97,7 +99,10 @@ public class WebDAVManagerImpl implements WebDAVManager, InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
timedSessionCache = coordinatorManager.getCoordinator().getCacher().getCache(WebDAVManager.class.getSimpleName(), "webdav");
resourceCache = coordinatorManager.getCoordinator().getCacher()
.getCache(WebDAVManager.class.getSimpleName(), "resources");
timedSessionCache = coordinatorManager.getCoordinator().getCacher()
.getCache(WebDAVManager.class.getSimpleName(), "webdav");
}
@Override
......@@ -108,21 +113,23 @@ public class WebDAVManagerImpl implements WebDAVManager, InitializingBean {
}
usess.getSessionInfo().setLastClickTime();
VFSResourceRoot fdc = (VFSResourceRoot)usess.getEntry("_DIRCTX");
VFSResourceRoot fdc = (VFSResourceRoot)usess.getEntry(DIR_CONTEXT);
if (fdc != null) {
return fdc;
}
IdentityEnvironment identityEnv = usess.getIdentityEnvironment();
VFSContainer webdavContainer = getMountableRoot(identityEnv);
//create the / folder
VirtualContainer rootContainer = new VirtualContainer("");
rootContainer.addItem(webdavContainer);
rootContainer.setLocalSecurityCallback(new ReadOnlyCallback());
fdc = new VFSResourceRoot(identityEnv.getIdentity(), rootContainer);
usess.putEntry("_DIRCTX", fdc);
final IdentityEnvironment identityEnv = usess.getIdentityEnvironment();
final Identity identity = identityEnv.getIdentity();
fdc = resourceCache.computeIfAbsent(identity.getKey(), key -> {
VFSContainer webdavContainer = getMountableRoot(identityEnv);
//create the / folder
VirtualContainer rootContainer = new VirtualContainer("");
rootContainer.addItem(webdavContainer);
rootContainer.setLocalSecurityCallback(new ReadOnlyCallback());
return new VFSResourceRoot(identity, rootContainer);
});
usess.putEntry(DIR_CONTEXT, fdc);
return fdc;
}
......
......@@ -92,6 +92,14 @@
<!-- max-idle same as session time out for WebDAV session in UserSessionManager -->
</local-cache>
<local-cache name="WebDAVManager@resources" simple-cache="true" statistics="true" statistics-available="true">
<locking isolation="READ_COMMITTED" concurrency-level="1000" acquire-timeout="15000" striping="false" />
<transaction mode="NONE" auto-commit="true" />
<memory max-count="10000" when-full="REMOVE" />
<expiration max-idle="900000" interval="5000" />
<!-- max-idle same as session time out for WebDAV session in UserSessionManager -->
</local-cache>
<local-cache name="UserManager@username" simple-cache="true" statistics="true" statistics-available="true">
<locking isolation="READ_COMMITTED" concurrency-level="1000" acquire-timeout="15000" striping="false" />
<transaction mode="NONE" auto-commit="true" />
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment