/** * Register the session in cache in order to clean the session folders in case of user * disconnection during an upload. * * @param uploadSession */ @SuppressWarnings("unchecked") private static void removeSessionFromCache(UploadSession uploadSession) { Set<String> sessionIds = CacheServiceProvider.getSessionCacheService().get(SESSION_CACHE_KEY, Set.class); if (sessionIds != null) { sessionIds.remove(uploadSession.getId()); CacheServiceProvider.getSessionCacheService() .remove(UPLOAD_SESSION_CACHE_KEY_PREFIX + uploadSession.getId()); } }
/** * Register the session in cache in order to clean the session folders in case of user * disconnection during an upload. * * @param uploadSession */ @SuppressWarnings("unchecked") private static void registerSessionInCache(UploadSession uploadSession) { Set<String> sessionIds = CacheServiceProvider.getSessionCacheService().get(SESSION_CACHE_KEY, Set.class); if (sessionIds == null) { sessionIds = new HashSet<String>(); CacheServiceProvider.getSessionCacheService().put(SESSION_CACHE_KEY, sessionIds); } sessionIds.add(uploadSession.uploadSessionId); CacheServiceProvider.getSessionCacheService() .put(UPLOAD_SESSION_CACHE_KEY_PREFIX + uploadSession.getId(), uploadSession); }
/** * Clears the upload sessions still attached to a user session. * * @param sessionInfo the session of a user. */ @SuppressWarnings("unchecked") public static void clearFrom(SessionInfo sessionInfo) { Set<String> sessionIds = sessionInfo.getCache().get(SESSION_CACHE_KEY, Set.class); if (sessionIds != null) { for (String uploadSessionId : new ArrayList<String>(sessionIds)) { try { UploadSession.from(uploadSessionId).clear(); } catch (Exception ignore) { } } sessionInfo.getCache().remove(SESSION_CACHE_KEY); } }