X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=org.argeo.suite.e4.rap%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fe4%2Frap%2FArgeoSuiteLoginLifecycle.java;h=aab4eefe63cd93a3571b0919847e0fc4e2ce78da;hb=8ecb2805db64a6ce7d4e210617ef8f2e06594a5b;hp=32623110eae8006d672cfc07e5988758057a594a;hpb=91ba500dcfe75cde313a513e341b7f9f57d64d75;p=gpl%2Fargeo-suite.git diff --git a/org.argeo.suite.e4.rap/src/org/argeo/suite/e4/rap/ArgeoSuiteLoginLifecycle.java b/org.argeo.suite.e4.rap/src/org/argeo/suite/e4/rap/ArgeoSuiteLoginLifecycle.java index 3262311..aab4eef 100644 --- a/org.argeo.suite.e4.rap/src/org/argeo/suite/e4/rap/ArgeoSuiteLoginLifecycle.java +++ b/org.argeo.suite.e4.rap/src/org/argeo/suite/e4/rap/ArgeoSuiteLoginLifecycle.java @@ -36,31 +36,51 @@ public class ArgeoSuiteLoginLifecycle extends CmsLoginLifecycle { private void loadState() { String state = getState(); - if (state != null && state.startsWith("/")) { - Session session = null; - try { + // for the time being we systematically open a session, in order to make sure + // that home is initialised + Session session = null; + try { + if (state != null && state.startsWith("/")) { + String path = state.substring(1); + String workspace; + if (path.equals("")) { + workspace = null; + path = "/"; + } else { + int index = path.indexOf('/'); + if (index == 0) { + log.error("Cannot interpret // " + state); + getBrowserNavigation().pushState("~", null); + return; + } else if (index > 0) { + workspace = path.substring(0, index); + path = path.substring(index); + } else {// index<0, assuming root node + workspace = path; + path = "/"; + } + } Subject subject = getSubject(); session = Subject.doAs(subject, new PrivilegedExceptionAction() { @Override public Session run() throws PrivilegedActionException { try { - return repository.login(); + return repository.login(workspace); } catch (RepositoryException e) { throw new PrivilegedActionException(e); } } }); - if (state.startsWith("/")) { - Node node = session.getNode(state); - systemWorkbenchService.openEntityEditor(node); - } - } catch (RepositoryException | PrivilegedActionException e) { - log.error("Cannot load state " + state, e); - } finally { - JcrUtils.logoutQuietly(session); + Node node = session.getNode(path); + systemWorkbenchService.openEntityEditor(node); } + } catch (RepositoryException | PrivilegedActionException e) { + log.error("Cannot load state " + state, e); + getBrowserNavigation().pushState("~", null); + } finally { + JcrUtils.logoutQuietly(session); } } }