Class SessionService
java.lang.Object
io.skipcheck.tm1.client.service.security.SessionService
Server sessions: every session logged in to the server (
/Sessions), this one's
(ActiveSession), their users and threads, and closing another session.
To close this client's own session, close the Tm1Session or Tm1Client:
it sends ActiveSession/tm1.Close, and knows not to log in again. A closed
session stays listed in Sessions for a few seconds (5 to 9 in TM1 11.8).
List who's logged in, expanding each session's user:
// Every session on the server, with its user's name and its label
return tm1.sessions()
.list(ODataQuery.none()
.select(Session.ID, Session.CONTEXT)
.expand(Session.USER, user -> user.select(User.NAME)))
.map(session -> session.id() + " " + session.user().name() + " " + session.context());
Close other clients' sessions by their label, sparing this one:
// Close the sessions labelled "Nightly load", except this client's own
return tm1.sessions()
.activeSession(ODataQuery.none().select(Session.ID))
.map(Session::id)
.flatMapMany(own -> tm1.sessions()
.list(ODataQuery.none().select(Session.ID).filter(Session.CONTEXT.eq("Nightly load")))
.filter(session -> !own.equals(session.id())))
.flatMap(session -> tm1.sessions().close(session.id()))
.then();
-
Constructor Summary
ConstructorsConstructorDescriptionSessionService(Tm1Session session) A service sending its requests throughsession. -
Method Summary
Modifier and TypeMethodDescriptionreactor.core.publisher.Mono<Session> activeSession(ODataQuery query) GET ActiveSession: this client's own session on the server.reactor.core.publisher.Mono<Void> close(long id) tm1.Close: ends another session; its client must log in again.reactor.core.publisher.Mono<Session> get(long id, ODataQuery query) GET Sessions(id).reactor.core.publisher.Flux<Session> list(ODataQuery query) GET Sessions, streamed: every session on the server, for an admin.reactor.core.publisher.Flux<Thread> threads(long id, ODataQuery query) GET Sessions(id)/Threads, streamed: what the session is running now.reactor.core.publisher.Mono<User> user(long id, ODataQuery query) GET Sessions(id)/User.
-
Constructor Details
-
SessionService
A service sending its requests throughsession.- Parameters:
session- the session
-
-
Method Details
-
list
@Tm1Endpoint("EntitySet Sessions") public reactor.core.publisher.Flux<Session> list(ODataQuery query) GET Sessions, streamed: every session on the server, for an admin.- Parameters:
query- what to select, expand (User,Threads), filter and order- Returns:
- the sessions
-
get
@Tm1Endpoint("EntitySet Sessions") public reactor.core.publisher.Mono<Session> get(long id, ODataQuery query) GET Sessions(id).- Parameters:
id- the session's IDquery- what to select and expand- Returns:
- the session, or a
Tm1NotFoundExceptionif there's none
-
activeSession
@Tm1Endpoint("Singleton ActiveSession") public reactor.core.publisher.Mono<Session> activeSession(ODataQuery query) GET ActiveSession: this client's own session on the server.- Parameters:
query- what to select and expand- Returns:
- the session
-
user
@Tm1Endpoint("Navigation Session/User") public reactor.core.publisher.Mono<User> user(long id, ODataQuery query) GET Sessions(id)/User.- Parameters:
id- the session's IDquery- what to select- Returns:
- the session's user
-
threads
@Tm1Endpoint("Navigation Session/Threads") public reactor.core.publisher.Flux<Thread> threads(long id, ODataQuery query) GET Sessions(id)/Threads, streamed: what the session is running now.- Parameters:
id- the session's IDquery- what to select, filter and order- Returns:
- the session's threads
-
close
tm1.Close: ends another session; its client must log in again. Needs schema 10.2.2.5.- Parameters:
id- the session's ID- Returns:
- completes when it's closed
-