/** * Determine the light administrator privileges associated with a session. * If the session originates via <q>sudo</q>, takes that into account. * Does <em>not</em> take account of if the relevant user is a member of <tt>system</tt>: * calculates assuming that the user is an administrator. * @param session an OMERO session * @param isCache if newly fetched privileges should be cached for future lookups * @return the light administrator privileges associated with the session */ private ImmutableSet<AdminPrivilege> getSessionPrivileges(Session session, boolean isCache) { final SessionEqualById wrappedSession = new SessionEqualById(session); try { if (isCache) { return PRIVILEGE_CACHE.get(wrappedSession); } else { final ImmutableSet<AdminPrivilege> privileges = PRIVILEGE_CACHE.getIfPresent(wrappedSession); if (privileges != null) { return privileges; } else { return getPrivileges(session); } } } catch (ExecutionException ee) { LOGGER.warn("failed to check privileges for session " + session.getId(), ee.getCause()); return ImmutableSet.of(); } }