X-Git-Url: http://git.argeo.org/?p=gpl%2Fargeo-suite.git;a=blobdiff_plain;f=org.argeo.suite.e4.rap%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fe4%2Frap%2FArgeoSuiteLoginLifecycle.java;fp=org.argeo.suite.e4.rap%2Fsrc%2Forg%2Fargeo%2Fsuite%2Fe4%2Frap%2FArgeoSuiteLoginLifecycle.java;h=0000000000000000000000000000000000000000;hp=91837d8cc82fe08ba0c68ab42c12aff1b769c7a0;hb=30f7e4a5a1bdb27156511eb9ea88d2ec492d7e01;hpb=a55bb0dc7e9fbcefb645d34ce24b326d1506a623 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 deleted file mode 100644 index 91837d8..0000000 --- a/org.argeo.suite.e4.rap/src/org/argeo/suite/e4/rap/ArgeoSuiteLoginLifecycle.java +++ /dev/null @@ -1,87 +0,0 @@ -package org.argeo.suite.e4.rap; - -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; - -import javax.inject.Inject; -import javax.jcr.Node; -import javax.jcr.Repository; -import javax.jcr.RepositoryException; -import javax.jcr.Session; -import javax.security.auth.Subject; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; -import org.argeo.cms.e4.rap.CmsLoginLifecycle; -import org.argeo.connect.ui.SystemWorkbenchService; -import org.argeo.jcr.JcrUtils; - -/** Extends the CMS login lifecycle by managing the state of the current context. */ -public class ArgeoSuiteLoginLifecycle extends CmsLoginLifecycle { - private final static Log log = LogFactory.getLog(ArgeoSuiteLoginLifecycle.class); - @Inject - SystemWorkbenchService systemWorkbenchService; - - @Inject - Repository repository; - - @Override - protected void startupComplete() { - loadState(); - } - - @Override - protected void stateChanged() { - loadState(); - } - - private void loadState() { - String state = getState(); - // 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(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); - getBrowserNavigation().pushState("~", null); - } finally { - JcrUtils.logoutQuietly(session); - } - } -}