log4j.logger.org.argeo=DEBUG
#log4j.logger.org.apache.jackrabbit.core.RepositoryImpl=DEBUG
#log4j.logger.argeo.stats=DEBUG
+#log4j.logger.org.eclipse.jetty.server.Server=DEBUG
## Appenders
log4j.appender.console=org.apache.log4j.ConsoleAppender
/** Manages history and navigation */
public abstract class AbstractCmsEntryPoint extends AbstractEntryPoint
- implements CmsSession {
+ implements CmsView {
private final Log log = LogFactory.getLog(AbstractCmsEntryPoint.class);
private final Subject subject;
@Override
protected final void createContents(final Composite parent) {
- getShell().getDisplay().setData(CmsSession.KEY, this);
+ getShell().getDisplay().setData(CmsView.KEY, this);
Subject.doAs(subject, new PrivilegedAction<Void>() {
@Override
public Void run() {
});
}
- @Override
- public Object local(Msg msg) {
- String key = msg.getId();
- int lastDot = key.lastIndexOf('.');
- String className = key.substring(0, lastDot);
- String fieldName = key.substring(lastDot + 1);
- Locale locale = RWT.getLocale();
- ResourceBundle rb = ResourceBundle.getBundle(className, locale,
- msg.getClassLoader());
- return rb.getString(fieldName);
- }
+// @Override
+// public Object local(Msg msg) {
+// String key = msg.getId();
+// int lastDot = key.lastIndexOf('.');
+// String className = key.substring(0, lastDot);
+// String fieldName = key.substring(lastDot + 1);
+// Locale locale = RWT.getLocale();
+// ResourceBundle rb = ResourceBundle.getBundle(className, locale,
+// msg.getClassLoader());
+// return rb.getString(fieldName);
+// }
/** Sets the state of the entry point and retrieve the related JCR node. */
protected synchronized String setState(String newState) {
+++ /dev/null
-package org.argeo.cms;
-
-import javax.security.auth.Subject;
-
-import org.argeo.cms.i18n.Msg;
-
-/** Provides interaction with the CMS system. UNSTABLE API at this stage. */
-public interface CmsSession {
- public final static String KEY = "org.argeo.connect.web.cmsSession";
-
- final ThreadLocal<CmsSession> current = new ThreadLocal<CmsSession>();
-
- // NAVIGATION
- public void navigateTo(String state);
-
- // SECURITY
- public void authChange();
-
- public Subject getSubject();
-
- // SERVICES
- public void exception(Throwable e);
-
- public Object local(Msg msg);
-
- public CmsImageManager getImageManager();
-}
--- /dev/null
+package org.argeo.cms;
+
+import javax.security.auth.Subject;
+
+/** Provides interaction with the CMS system. UNSTABLE API at this stage. */
+public interface CmsView {
+ public final static String KEY = "org.argeo.cms.view";
+
+ // NAVIGATION
+ public void navigateTo(String state);
+
+ // SECURITY
+ public void authChange();
+
+ public Subject getSubject();
+
+ // SERVICES
+ public void exception(Throwable e);
+
+ public CmsImageManager getImageManager();
+}
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.util.Locale;
+import java.util.ResourceBundle;
import org.argeo.cms.CmsException;
-import org.argeo.cms.CmsSession;
import org.eclipse.rap.rwt.RWT;
/** A single message to be internationalised. */
}
public Object local() {
- CmsSession cmSession = CmsSession.current.get();
- Object local = cmSession.local(this);
+ Object local = local(this);
if (local == null)
local = getDefault();
if (local == null)
return local;
}
+ private static Object local(Msg msg) {
+ String key = msg.getId();
+ int lastDot = key.lastIndexOf('.');
+ String className = key.substring(0, lastDot);
+ String fieldName = key.substring(lastDot + 1);
+ Locale locale = RWT.getLocale();
+ ResourceBundle rb = ResourceBundle.getBundle(className, locale,
+ msg.getClassLoader());
+ return rb.getString(fieldName);
+ }
+
public static void init(Class<?> clss) {
final Field[] fieldArray = clss.getDeclaredFields();
ClassLoader loader = clss.getClassLoader();
import org.argeo.cms.CmsException;
import org.argeo.cms.CmsImageManager;
import org.argeo.cms.CmsNames;
-import org.argeo.cms.CmsSession;
import org.argeo.cms.CmsTypes;
import org.argeo.cms.text.Img;
import org.argeo.cms.text.Paragraph;
private final Section mainSection;
private TextInterpreter textInterpreter = new TextInterpreterImpl();
- private CmsImageManager imageManager = CmsSession.current.get()
+ private CmsImageManager imageManager = CmsUtils.getCmsView()
.getImageManager();
private FileUploadListener fileUploadListener;
import org.argeo.cms.CmsException;
import org.argeo.cms.CmsImageManager;
-import org.argeo.cms.CmsSession;
import org.argeo.cms.internal.JcrFileUploadReceiver;
import org.argeo.cms.util.CmsUtils;
import org.argeo.cms.viewers.NodePart;
Point preferredImageSize) throws RepositoryException {
super(parent, swtStyle, imgNode, false, preferredImageSize);
this.section = section;
- imageManager = CmsSession.current.get().getImageManager();
+ imageManager = CmsUtils.getCmsView().getImageManager();
CmsUtils.style(this, TextStyles.TEXT_IMG);
}
// FileDialog fileDialog = new FileDialog(getShell());
// fileDialog.open();
// String fileName = fileDialog.getFileName();
- CmsImageManager imageManager = CmsSession.current.get()
- .getImageManager();
+ CmsImageManager imageManager = CmsUtils.getCmsView().getImageManager();
Node node = getNode();
JcrFileUploadReceiver receiver = new JcrFileUploadReceiver(
node.getParent(), node.getName() + '[' + node.getIndex() + ']',
import org.apache.commons.io.IOUtils;
import org.argeo.cms.CmsConstants;
import org.argeo.cms.CmsException;
+import org.argeo.cms.CmsView;
import org.argeo.jcr.JcrUtils;
import org.eclipse.rap.rwt.RWT;
import org.eclipse.rap.rwt.service.ResourceManager;
/** Static utilities for the CMS framework. */
public class CmsUtils implements CmsConstants {
+ /** The CMS view related to this display. */
+ public static CmsView getCmsView() {
+ Display display = Display.getCurrent();
+ if (display == null)
+ throw new CmsException("No display available");
+ CmsView cmsView = (CmsView) display.getData(CmsView.KEY);
+ if (cmsView == null)
+ throw new CmsException("No CMS view available");
+ return cmsView;
+ }
+
/** @deprecated Use rowData16px() instead. GridData should not be reused. */
@Deprecated
public static RowData ROW_DATA_16px = new RowData(16, 16);
import javax.security.auth.x500.X500Principal;
import org.argeo.ArgeoException;
-import org.argeo.cms.CmsSession;
/**
* Retrieves information about the current user. Not an API, can change without
public final static Subject getSubject() {
Subject subject = Subject.getSubject(AccessController.getContext());
if (subject == null) {
- subject = CmsSession.current.get().getSubject();
+ subject = CmsUtils.getCmsView().getSubject();
if (subject == null)
throw new ArgeoException("Not authenticated.");
}
import org.apache.commons.logging.LogFactory;
import org.argeo.cms.CmsConstants;
import org.argeo.cms.CmsException;
-import org.argeo.cms.CmsSession;
import org.argeo.cms.CmsUiProvider;
import org.argeo.cms.LifeCycleUiProvider;
import org.argeo.jcr.JcrUtils;
public void configure(Application application) {
try {
application.setOperationMode(OperationMode.SWT_COMPATIBILITY);
+ // application.setOperationMode(OperationMode.JEE_COMPATIBILITY);
+
application.setExceptionHandler(new CmsExceptionHandler());
// loading animated gif
@Override
public void handleException(Throwable throwable) {
- CmsSession.current.get().exception(throwable);
+ CmsUtils.getCmsView().exception(throwable);
}
}
// entryPoint.setState("");
entryPoint.setHeader(header);
entryPoint.setHeaderHeight(headerHeight);
- CmsSession.current.set(entryPoint);
+ // CmsSession.current.set(entryPoint);
return entryPoint;
}
import org.argeo.cms.CmsException;
import org.argeo.cms.CmsMsg;
-import org.argeo.cms.CmsSession;
+import org.argeo.cms.CmsView;
import org.argeo.cms.CmsStyles;
import org.argeo.cms.KernelHeader;
import org.argeo.cms.auth.ArgeoLoginContext;
}
protected void login() {
- CmsSession cmsSession = (CmsSession) getDisplay().getData(
- CmsSession.KEY);
+ CmsView cmsSession = (CmsView) getDisplay().getData(
+ CmsView.KEY);
Subject subject = cmsSession.getSubject();
try {
//
}
protected void logout() {
- final CmsSession cmsSession = (CmsSession) getDisplay().getData(
- CmsSession.KEY);
+ final CmsView cmsSession = (CmsView) getDisplay().getData(
+ CmsView.KEY);
Subject subject = cmsSession.getSubject();
try {
//
.getPrincipals(X500Principal.class);
if (userPrincipal.isEmpty())
return super.getUserID(subject, workspaceName);
- if (userPrincipal.size() > 1)
- throw new RuntimeException("Multiple user principals "
- + userPrincipal);
+ if (userPrincipal.size() > 1) {
+ StringBuilder buf = new StringBuilder();
+ for (X500Principal principal : userPrincipal)
+ buf.append(' ').append('\"').append(principal).append('\"');
+ throw new RuntimeException("Multiple user principals:" + buf);
+ }
return userPrincipal.iterator().next().getName();
// Authentication authentication = SecurityContextHolder.getContext()
// .getAuthentication();