- private Session getCurrentSessionWithoutCreation(ToadletContext toadletContenxt) {
- return getSessionManager().useSession(toadletContenxt);
- }
-
- private Session getOrCreateCurrentSession(ToadletContext toadletContenxt) {
- Session session = getCurrentSessionWithoutCreation(toadletContenxt);
- if (session == null) {
- session = getSessionManager().createSession(UUID.randomUUID().toString(), toadletContenxt);
- }
- return session;
- }
-
- public Sone getCurrentSoneCreatingSession(ToadletContext toadletContext) {
- Collection<Sone> localSones = getCore().getLocalSones();
- if (localSones.size() == 1) {
- return localSones.iterator().next();
- }
- return getCurrentSone(getOrCreateCurrentSession(toadletContext));
- }
-
- public Sone getCurrentSoneWithoutCreatingSession(ToadletContext toadletContext) {
- Collection<Sone> localSones = getCore().getLocalSones();
- if (localSones.size() == 1) {
- return localSones.iterator().next();
- }
- return getCurrentSone(getCurrentSessionWithoutCreation(toadletContext));
- }
-
- /**
- * Returns the currently logged in Sone.
- *
- * @param session
- * The session
- * @return The currently logged in Sone, or {@code null} if no Sone is
- * currently logged in
- */
- private Sone getCurrentSone(Session session) {
- if (session == null) {
- return null;
- }
- String soneId = (String) session.getAttribute("Sone.CurrentSone");
- if (soneId == null) {
- return null;
- }
- return getCore().getLocalSone(soneId);
- }
-
- @Override