@Override public ServantHolder call() { return new ServantHolder(s.getUuid(), servantsPerSession); } });
@Override public void executeCloseSession(String uuid) { Session session = openSessions.get(uuid); if (session == null) { if (closedSessions.containsKey(uuid)) { log.debug("attempt to close session {} but is already closed", uuid); } else { log.warn("attempt to close session {} but is no longer cached", uuid); } } else { session.setClosed(new Timestamp(System.currentTimeMillis())); closedSessions.put(session.getUuid(), session); openSessions.remove(session.getUuid()); log.debug("closed session {}", uuid); } }
protected String idToUuid(long shareId) { Session s = iQuery.get(Session.class, shareId); return s.getUuid(); }
public Integer call() throws Exception { return mgr.close(session.getUuid()); }}); return ex.get(future);
public String getCurrentSessionUuid() { return getSession().getUuid(); }
@SuppressWarnings({ "unchecked", "rawtypes" }) public SessionContextImpl(Session session, Set<AdminPrivilege> adminPrivileges, List<Long> lGroups, List<Long> mGroups, List<String> roles, SessionStats stats, Roles _roles, SessionContext previous) { this._roles = _roles; this.stats = stats; this.session = session; if (previous != null) { this.count = previous.count(); this.shareId = previous.getCurrentShareId(); } else { this.count = new SessionContext.Count(session.getUuid()); } this.adminPrivileges = ImmutableSet.copyOf(adminPrivileges); this.leaderOfGroups = Collections.unmodifiableList(new ArrayList( lGroups)); this.memberOfGroups = Collections.unmodifiableList(new ArrayList( mGroups)); this.roles = Collections.unmodifiableList(new ArrayList(roles)); // Force NPE getCurrentGroupPermissions(); }
@Override public Session executeUpdate(ServiceFactory sf, Session session, String uuid, long userId, Long sudoerId) { Node node = nodeProvider.getManagerByUuid(uuid, sf); if (node == null) { node = new Node(0L, false); // Using default node. } if (session.getId() == null) { session.setId(executeNextSessionId()); } session.setNode(node); session.setOwner(new Experimenter(userId, false)); if (sudoerId == null) { session.setSudoer(null); } else { session.setSudoer(new Experimenter(sudoerId, false)); } /* put before remove so that the session is never missing altogether */ if (session.getClosed() == null) { openSessions.put(session.getUuid(), session); closedSessions.remove(session.getUuid()); } else { closedSessions.put(session.getUuid(), session); openSessions.remove(session.getUuid()); } log.debug("Registered Session:{} ({})", session.getId(), session.getUuid()); return session; }
public Principal createPrincipal() { getSession(); Principal sessionPrincipal = new Principal(this.session.getUuid(), this.principal.getGroup(), this.principal.getEventType()); return sessionPrincipal; }
private void checkIfShare(SessionContext sessionContext) { if (sessionContext.getSession() instanceof Share) { final Long id = sessionContext.getSession().getId(); final String uuid = sessionContext.getSession().getUuid(); final String prefix = String.format("Share:%s (%s)", id, uuid); List<Object[]> rv = executeProjection( "select s.active, s.timeToLive, s.started from Share s where s.id = :id", new Parameters().addId(sessionContext.getSession().getId())); if (rv.size() != 1) { throw new RuntimeException(prefix + " could not be found!"); } Object[] items = rv.get(0); Boolean active = (Boolean) items[0]; Long timeToLive = (Long) items[1]; Timestamp started = (Timestamp) items[2]; if (Boolean.FALSE.equals(active)) { throw new SecurityViolation(prefix + " is inactive"); } else if ((System.currentTimeMillis() - started.getTime()) > timeToLive) { String msg = String.format("%s has expired: %s, timeToLive=%s", prefix, started, timeToLive); throw new SecurityViolation(msg); } } }
public RMap getResults(ProcessPrx proc, Current __current) throws ServerError { rwl.writeLock().lock(); try { finishedOrThrow(); // Gather output omero.RMap output = rmap(new HashMap<String, omero.RType>()); Map<String, Object> env = mgr.outputEnvironment(session.getUuid()); IceMapper mapper = new IceMapper(); for (String key : env.keySet()) { RType rt = mapper.toRType(env.get(key)); output.put(key, rt); } optionallyLoadFile(output.getValue(), "stdout", __current); optionallyLoadFile(output.getValue(), "stderr", __current); currentProcess = null; obtainResults = false; return output; } finally { rwl.writeLock().unlock(); } }
/** * Will be called in a synchronized block by {@link SessionCache} in order * to allow for an update. */ @SuppressWarnings({"rawtypes" }) public SessionContext reload(final SessionContext ctx) { List list = (List) executor.execute(asroot, new Executor.SimpleWork( this, "reload", ctx.getSession().getUuid()) { @Transactional(readOnly = true) public Object doWork(org.hibernate.Session session, ServiceFactory sf) { /* user and group names may change while the session is open */ final LocalAdmin admin = (LocalAdmin) sf.getAdminService(); final Experimenter exp = admin.userProxy(ctx.getCurrentUserId()); final ExperimenterGroup grp = admin.groupProxy(ctx.getCurrentGroupId()); final Principal p = new Principal(exp.getOmeName(), grp.getName(), ctx.getCurrentEventType()); return executeSessionContextLookup(sf, p, exp, grp, ctx.getSession()); } }); if (list == null) { return null; } return createSessionContext(list, ctx); }
params.put("start", session.getStarted()); params.put("type", session.getDefaultEventType()); params.put("uuid", session.getUuid()); params.put("node", nodeId); params.put("owner", roles.getRootId()); throw new InternalException( "Failed to insert new session: " + session.getUuid()); Long id = sql.sessionId(session.getUuid()); session.setNode(new Node(nodeId, false)); session.setOwner(new Experimenter(roles.getRootId(), false));
if (job instanceof ParseJob) { setLauncher(__current); params = prx.parseJob(session.getUuid(), job, __current.ctx); if (params == null) { StringBuilder sb = new StringBuilder();
for (ome.model.meta.Session obj : rv) { if (obj.isLoaded()) { objects.put(obj.getUuid(), (Session) mapper.map(obj));
@Override public Session executeInternalSession(final String uuid, Session session) { Node node = (Node) executor.executeSql(new Executor.SimpleSqlWork(this, "executeInternalSession") { @Transactional(readOnly = true) public Object doWork(SqlAction sql) { final Long nodeId = nodeProvider.getManagerIdByUuid(uuid, sql); return nodeId == null ? null : new Node(nodeId, false); } }); session.setId(executeNextSessionId()); log.debug("Created session: {}", session); log.debug("Setting node: {}", node); session.setNode(node); session.setOwner(new Experimenter(roles.getRootId(), false)); openSessions.put(session.getUuid(), session); return session; }
return getNode(); } else if (field.equals(UUID)) { return getUuid(); } else if (field.equals(OWNER)) { return getOwner();
protected final void sessionInit() { if (sessionPrincipal != null) { try { this.manager.getEventContext(sessionPrincipal); } catch (SessionException e) { sessionPrincipal = null; } } if (sessionPrincipal == null) { session = this.manager.createWithAgent(principal, "ExecutionThread", null); sessionPrincipal = new Principal(session.getUuid(), principal .getGroup(), principal.getEventType()); } }
target.setTimeToLive(source.getTimeToLive()); target.setUserAgent(source.getUserAgent()); target.setUuid(source.getUuid());