@Override public Session findSessionById(long id, org.hibernate.Session hibernateSession) { for (final P provider : read) { final Session session = provider.findSessionById(id, hibernateSession); if (session != null) { return session; } } return null; }
@Override public void executeCloseSession(String uuid) { /* working through all readers because we want a failure exception if the session exists as read-only */ for (final P provider : read) { if (provider.findSessionIdByUuid(uuid) != null) { provider.executeCloseSession(uuid); } } }
@Override public Session executeInternalSession(String uuid, Session session) { return write.get(0).executeInternalSession(uuid, session); }
@Override public Session executeUpdate(ServiceFactory sf, Session session, String uuid, long userId, Long sudoerId) { /* working through all readers because we want a failure exception if the session exists as read-only */ for (final P provider : read) { if (provider.findSessionIdByUuid(uuid, sf) != null) { return provider.executeUpdate(sf, session, uuid, userId, sudoerId); } } /* creating a new session */ return write.get(0).executeUpdate(sf, session, uuid, userId, sudoerId); }
public Object step(int step) throws Cancel { helper.assertStep(step); contexts = manager.getSessionData(); if (contexts.isEmpty()) { return Collections.emptyList(); } final ServiceFactory sf = helper.getServiceFactory(); final List<ome.model.meta.Session> sessions = new ArrayList<>(contexts.size()); for (final String uuid : contexts.keySet()) { final Long sessionId = provider.findSessionIdByUuid(uuid, sf); if (sessionId != null) { final ome.model.meta.Session session = provider.findSessionById(sessionId, sf); if (session != null) { sessions.add(session); } } } return sessions; }
@Override public Long findSessionIdByUuid(String uuid, ServiceFactory sf) { for (final P provider : read) { final Long sessionId = provider.findSessionIdByUuid(uuid, sf); if (sessionId != null) { return sessionId; } } return null; }
@Transactional(readOnly = false) public Object doWork(org.hibernate.Session __s, ServiceFactory sf) { Principal p = validateSessionInputs(sf, req); oldsession.setDefaultEventType(p.getEventType()); long userId = executeLookupUser(sf, p); final Session s = sessionProvider.executeUpdate(sf, oldsession, internal_uuid, userId, req.sudoer); return executeSessionContextLookup(sf, p, s); }
@Override public long executeNextSessionId() { return write.get(0).executeNextSessionId(); }
/** */ public void onApplicationEvent(ApplicationEvent event) { if (event instanceof UserGroupUpdateEvent) { cache.updateEvent((UserGroupUpdateEvent) event); } else if (event instanceof DestroySessionMessage) { sessionProvider.executeCloseSession(((DestroySessionMessage) event).getSessionId()); } }
@Transactional(readOnly = true) public Object doWork(Session session, ServiceFactory sf) { final Long sessionId = sessionProvider.findSessionIdByUuid(userId, sf); final ome.model.meta.Session s = sessionId == null ? null : sessionProvider.findSessionById(sessionId, sf); IQuery q = sf.getQueryService(); Experimenter e = null; if (s != null) { e = s.getOwner(); if (!e.isLoaded()) { e = q.get(Experimenter.class, e.getId()); } data.add(String.format("user=%s", e.getOmeName())); } else { e = q.findByString(Experimenter.class, "omeName", userId); if (e != null) { data.add(String.format("id=%s", e.getId())); } } if (s != null) { data.add(String.format("created=%s", s.getStarted())); data.add(String.format("closed=%s", s.getClosed())); } return null; } });
@Override public Long findSessionIdByUuid(String uuid) { for (final P provider : read) { final Long sessionId = provider.findSessionIdByUuid(uuid); if (sessionId != null) { return sessionId; } } return null; } }
@Transactional(readOnly = true) public Object doWork(org.hibernate.Session __s, ServiceFactory sf) { Principal p = validateSessionInputs(sf, req); oldsession.setDefaultEventType(p.getEventType()); final long userId = executeLookupUser(sf, p); // Here, we hope that the implementation has been updated // to match read-only status. Note: this code block matches // the one below, but the annotation is a compile-time rather // than run-time concern. final Session s = sessionProvider.executeUpdate(sf, oldsession, internal_uuid, userId, req.sudoer); return executeSessionContextLookup(sf, p, s); } });
@Override public Session findSessionById(long id, ServiceFactory sf) { for (final P provider : read) { final Session session = provider.findSessionById(id, sf); if (session != null) { return session; } } return null; }
@Transactional(readOnly = false) public Object doWork(org.hibernate.Session __s, ServiceFactory sf) { final Long sudoerId; if (orig.getSudoer() == null) { sudoerId = null; } else { sudoerId = orig.getSudoer().getId(); } return sessionProvider.executeUpdate(sf, copy, internal_uuid, newctx.getCurrentUserId(), sudoerId); } });
/** * Initialization method called by the Spring run-time to acquire an initial * {@link Session}. */ public void init() { try { asroot = new Principal(internal_uuid, "system", "Sessions"); // Create a basic session Session session = new Session(); define(session, internal_uuid, "Session Manager internal", System.currentTimeMillis(), Long.MAX_VALUE, 0L, "Sessions", "Internal", null); session = sessionProvider.executeInternalSession(internal_uuid, session); internalSession = new InternalSessionContext(session, LightAdminPrivileges.getAllPrivileges(), roles); cache.putSession(internal_uuid, internalSession); } catch (UncategorizedSQLException uncat) { log.warn("Assuming that this is read-only"); } catch (DataAccessException dataAccess) { throw new RuntimeException( " " + "=====================================================\n" + "Data access exception: Did you create your database? \n" + "=====================================================\n", dataAccess); } }
final List<Long> leaderOfGroupsIds = admin.getLeaderOfGroupIds(exp); final List<String> userRoles = admin.getUserRoles(exp); final Session reloaded = sessionProvider.findSessionById(session.getId(), sf); final Experimenter sudoer = reloaded.getSudoer(); boolean hasAdminPrivileges = memberOfGroupsIds.contains(roles.getSystemGroupId());
final ome.model.meta.Session currentSession = sessionProvider.findSessionById(ec.getCurrentSessionId(), session); Experimenter sessionOwnerCurrent = currentSession.getSudoer(); if (sessionOwnerCurrent == null) { sessionOwnerCurrent = currentSession.getOwner(); final ome.model.meta.Session queriedSession = sessionProvider.findSessionById(id, session); Experimenter sessionOwnerQueried = queriedSession.getSudoer(); if (sessionOwnerQueried == null) {
sess = new ome.model.meta.Session(sessionId, false); } else { sess = sessionProvider.findSessionById(sessionId, sf);