X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2FAbstractCmsEntryPoint.java;h=0a988a63e99d6087ea70490f977984b3aa1fe407;hb=77319330a8dec1f521e78a2df381f66c1b43100d;hp=883d84df4450e710c6ef44aad792a8e1e6c624ca;hpb=91fcd647244c5d87f8f434f261a0768bea84c528;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/AbstractCmsEntryPoint.java b/org.argeo.cms/src/org/argeo/cms/AbstractCmsEntryPoint.java index 883d84df4..0a988a63e 100644 --- a/org.argeo.cms/src/org/argeo/cms/AbstractCmsEntryPoint.java +++ b/org.argeo.cms/src/org/argeo/cms/AbstractCmsEntryPoint.java @@ -5,7 +5,7 @@ import java.util.HashMap; import java.util.Map; import javax.jcr.Node; -import javax.jcr.NodeIterator; +import javax.jcr.PathNotFoundException; import javax.jcr.Property; import javax.jcr.Repository; import javax.jcr.RepositoryException; @@ -22,7 +22,6 @@ import org.apache.commons.logging.LogFactory; import org.argeo.ArgeoException; import org.argeo.cms.auth.AuthConstants; import org.argeo.cms.auth.HttpRequestCallbackHandler; -import org.argeo.cms.util.CmsUtils; import org.argeo.eclipse.ui.specific.UiContext; import org.argeo.jcr.JcrUtils; import org.eclipse.rap.rwt.RWT; @@ -52,6 +51,7 @@ public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint // Current state private Session session; private Node node; + private String nodePath;// useful when changing auth private String state; private String page; private Throwable exception; @@ -161,12 +161,12 @@ public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint } @Override - public Subject getSubject() { + public synchronized Subject getSubject() { return subject; } @Override - public void logout() { + public synchronized void logout() { if (loginContext == null) throw new CmsException("Login context should not be null"); try { @@ -181,27 +181,23 @@ public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint } @Override - public void authChange(LoginContext loginContext) { + public synchronized void authChange(LoginContext loginContext) { if (loginContext == null) throw new CmsException("Login context cannot be null"); this.loginContext = loginContext; - Subject.doAs(subject, new PrivilegedAction() { + Subject.doAs(loginContext.getSubject(), new PrivilegedAction() { @Override public Void run() { try { - String currentPath = null; - if (node != null) - currentPath = node.getPath(); JcrUtils.logoutQuietly(session); - session = repository.login(workspace); - if (currentPath != null) + if (nodePath != null) try { - node = session.getNode(currentPath); - } catch (Exception e) { - logout(); - session = repository.login(workspace); + node = session.getNode(nodePath); + } catch (PathNotFoundException e) { + // logout(); + // session = repository.login(workspace); navigateTo("~"); throw e; } @@ -225,7 +221,7 @@ public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint doRefresh(); } - protected void doRefresh() { + protected synchronized void doRefresh() { Subject.doAs(subject, new PrivilegedAction() { @Override public Void run() { @@ -239,7 +235,7 @@ public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint protected synchronized String setState(String newState) { String previousState = this.state; - node = null; + Node node = null; page = null; this.state = newState; if (newState.equals("~")) @@ -265,47 +261,12 @@ public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint node = getDefaultNode(session); page = state; } - - // Title - String title; - if (node.isNodeType(NodeType.MIX_TITLE) - && node.hasProperty(Property.JCR_TITLE)) - title = node.getProperty(Property.JCR_TITLE).getString() - + " - " + getBaseTitle(); - else - title = getBaseTitle(); - - HttpServletRequest request = RWT.getRequest(); - String url = CmsUtils.getCanonicalUrl(node, request); - String imgUrl = null; - for (NodeIterator it = node.getNodes(); it.hasNext();) { - Node child = it.nextNode(); - if (child.isNodeType(CmsTypes.CMS_IMAGE)) - imgUrl = CmsUtils.getDataUrl(child, request); - } - - StringBuilder js = new StringBuilder(); - js.append("document.title = '" + title + "';"); - js.append("var metas = document.getElementsByTagName('meta');"); - js.append("for (var i=0; i