Better script support in CMS.
[lgpl/argeo-commons.git] / org.argeo.cms.e4.rap / src / org / argeo / cms / e4 / rap / CmsE4EntryPointFactory.java
index e3490002dd3976cabe1e4bc0e67075e9856630a1..a5a32348e43896837bd0908730af7a4aa4fc0dba 100644 (file)
@@ -11,11 +11,25 @@ import org.eclipse.rap.rwt.application.EntryPoint;
 import org.eclipse.rap.rwt.client.service.JavaScriptExecutor;
 
 public class CmsE4EntryPointFactory extends E4EntryPointFactory {
+       public final static String DEFAULT_LIFECYCLE_URI = "bundleclass://org.argeo.cms.e4.rap/org.argeo.cms.e4.rap.CmsLoginLifecycle";
 
        public CmsE4EntryPointFactory(E4ApplicationConfig config) {
                super(config);
        }
 
+       public CmsE4EntryPointFactory(String e4Xmi, String lifeCycleUri) {
+               super(defaultConfig(e4Xmi, lifeCycleUri));
+       }
+
+       public CmsE4EntryPointFactory(String e4Xmi) {
+               this(e4Xmi, DEFAULT_LIFECYCLE_URI);
+       }
+
+       public static E4ApplicationConfig defaultConfig(String e4Xmi, String lifeCycleUri) {
+               E4ApplicationConfig config = new E4ApplicationConfig(e4Xmi, lifeCycleUri, null, null, false, true, true);
+               return config;
+       }
+
        @Override
        public EntryPoint create() {
                EntryPoint ep = createEntryPoint();
@@ -59,98 +73,4 @@ public class CmsE4EntryPointFactory extends E4EntryPointFactory {
        protected EntryPoint createEntryPoint() {
                return super.create();
        }
-
-       // private boolean login(Subject subject) {
-       // Display display = new Display();
-       // CmsView cmsView = new E4CmsView(subject);
-       // CmsLoginShell loginShell = new CmsLoginShell(cmsView);
-       // loginShell.setSubject(subject);
-       // try {
-       // // try pre-auth
-       // LoginContext loginContext = new
-       // LoginContext(NodeConstants.LOGIN_CONTEXT_USER, subject, loginShell);
-       // loginContext.login();
-       // } catch (LoginException e) {
-       // loginShell.createUi();
-       // loginShell.open();
-       //
-       // while (!loginShell.getShell().isDisposed()) {
-       // if (!display.readAndDispatch())
-       // display.sleep();
-       // }
-       // } finally {
-       // display.dispose();
-       // }
-       // if (CurrentUser.getUsername(subject) == null)
-       // return false;
-       // return true;
-       // }
-       //
-       // private class E4CmsView implements CmsView {
-       // private LoginContext loginContext;
-       // private UxContext uxContext;
-       // private Subject subject;
-       //
-       // public E4CmsView(Subject subject) {
-       // this.subject = subject;
-       // uxContext = new SimpleUxContext();
-       // }
-       //
-       // @Override
-       // public UxContext getUxContext() {
-       // return uxContext;
-       // }
-       //
-       // @Override
-       // public void navigateTo(String state) {
-       // // TODO Auto-generated method stub
-       //
-       // }
-       //
-       // @Override
-       // public void authChange(LoginContext loginContext) {
-       // if (loginContext == null)
-       // throw new CmsException("Login context cannot be null");
-       // // logout previous login context
-       // // if (this.loginContext != null)
-       // // try {
-       // // this.loginContext.logout();
-       // // } catch (LoginException e1) {
-       // // System.err.println("Could not log out: " + e1);
-       // // }
-       // this.loginContext = loginContext;
-       // }
-       //
-       // @Override
-       // public void logout() {
-       // if (loginContext == null)
-       // throw new CmsException("Login context should not bet null");
-       // try {
-       // CurrentUser.logoutCmsSession(loginContext.getSubject());
-       // loginContext.logout();
-       // } catch (LoginException e) {
-       // throw new CmsException("Cannot log out", e);
-       // }
-       // }
-       //
-       // @Override
-       // public void exception(Throwable e) {
-       // log.error("Unexpected exception in Eclipse 4 RAP", e);
-       // }
-       //
-       // @Override
-       // public CmsImageManager getImageManager() {
-       // // TODO Auto-generated method stub
-       // return null;
-       // }
-       //
-       // protected Subject getSubject() {
-       // return subject;
-       // }
-       //
-       // @Override
-       // public boolean isAnonymous() {
-       // return CurrentUser.isAnonymous(getSubject());
-       // }
-       // }
 }