From 8ecb2805db64a6ce7d4e210617ef8f2e06594a5b Mon Sep 17 00:00:00 2001 From: Mathieu Baudier Date: Thu, 11 Jun 2020 11:33:06 +0200 Subject: [PATCH] Include workspace in the browser's state interpretation. --- .../e4/rap/ArgeoSuiteLoginLifecycle.java | 48 ++++++++++++------- 1 file changed, 32 insertions(+), 16 deletions(-) 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 6b4197c..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 @@ -12,7 +12,6 @@ import javax.security.auth.Subject; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; -import org.argeo.api.NodeConstants; import org.argeo.cms.e4.rap.CmsLoginLifecycle; import org.argeo.connect.ui.SystemWorkbenchService; import org.argeo.jcr.JcrUtils; @@ -41,24 +40,41 @@ public class ArgeoSuiteLoginLifecycle extends CmsLoginLifecycle { // that home is initialised Session session = null; try { - Subject subject = getSubject(); - session = Subject.doAs(subject, new PrivilegedExceptionAction() { - - @Override - public Session run() throws PrivilegedActionException { - try { - return repository.login(NodeConstants.HOME_WORKSPACE); - } catch (RepositoryException e) { - throw new PrivilegedActionException(e); + 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() { - }); - if (state != null && state.startsWith("/")) { - if (state.startsWith("/")) { - Node node = session.getNode(state); - systemWorkbenchService.openEntityEditor(node); - } + @Override + public Session run() throws PrivilegedActionException { + try { + return repository.login(workspace); + } catch (RepositoryException e) { + throw new PrivilegedActionException(e); + } + } + + }); + Node node = session.getNode(path); + systemWorkbenchService.openEntityEditor(node); } } catch (RepositoryException | PrivilegedActionException e) { log.error("Cannot load state " + state, e); -- 2.30.2