X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;ds=sidebyside;f=org.argeo.cms%2Fsrc%2Forg%2Fargeo%2Fcms%2FCmsApplication.java;h=9c7b5b3447ac707863a53047587ea36407f8fa85;hb=85ced0e58ded00f296948b6dff51f84994855080;hp=90df56a61a967d65c2c46ab4ba1ee8bb8252b608;hpb=04dade003a08c5915280ae653639b0af7cddeb0c;p=lgpl%2Fargeo-commons.git diff --git a/org.argeo.cms/src/org/argeo/cms/CmsApplication.java b/org.argeo.cms/src/org/argeo/cms/CmsApplication.java index 90df56a61..9c7b5b344 100644 --- a/org.argeo.cms/src/org/argeo/cms/CmsApplication.java +++ b/org.argeo.cms/src/org/argeo/cms/CmsApplication.java @@ -21,7 +21,10 @@ import javax.jcr.version.VersionManager; import org.apache.commons.io.IOUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.argeo.cms.auth.LoginRequiredException; import org.argeo.cms.internal.ImageManagerImpl; +import org.argeo.cms.util.BundleResourceLoader; +import org.argeo.cms.util.CmsUtils; import org.argeo.jcr.JcrUtils; import org.eclipse.gemini.blueprint.context.BundleContextAware; import org.eclipse.rap.rwt.RWT; @@ -45,16 +48,13 @@ import org.osgi.framework.BundleContext; /** Configures an Argeo CMS RWT application. */ public class CmsApplication implements CmsConstants, ApplicationConfiguration, BundleContextAware { - final static Log log = LogFactory.getLog(CmsApplication.class); + private final static Log log = LogFactory.getLog(CmsApplication.class); - // private Map entryPoints = new HashMap(); private Map> branding = new HashMap>(); private Map> styleSheets = new HashMap>(); private List resources = new ArrayList(); - // private Bundle clientScriptingBundle; private BundleContext bundleContext; private Repository repository; @@ -63,8 +63,6 @@ public class CmsApplication implements CmsConstants, ApplicationConfiguration, private List roPrincipals = Arrays.asList("anonymous", "everyone"); private List rwPrincipals = Arrays.asList("everyone"); - private CmsLogin cmsLogin; - private CmsUiProvider header; private Map pages = new LinkedHashMap(); @@ -147,13 +145,6 @@ public class CmsApplication implements CmsConstants, ApplicationConfiguration, } public void init() throws RepositoryException { - if (workspace == null) - throw new CmsException( - "Workspace must be set when calling initialization." - + " Please make sure that read-only and read-write roles" - + " have been properly configured:" - + " the defaults are open."); - Session session = null; try { session = JcrUtils.loginOrCreateWorkspace(repository, workspace); @@ -209,8 +200,10 @@ public class CmsApplication implements CmsConstants, ApplicationConfiguration, this.workspace = workspace; } - public void setCmsLogin(CmsLogin cmsLogin) { - this.cmsLogin = cmsLogin; + public void setCmsLogin(@SuppressWarnings("deprecation") CmsLogin cmsLogin) { + // this.cmsLogin = cmsLogin; + log.warn("cmsLogin" + + " is deprecated and will be removed soon. Adapt your configuration ASAP."); } public void setHeader(CmsUiProvider header) { @@ -237,11 +230,6 @@ public class CmsApplication implements CmsConstants, ApplicationConfiguration, this.headerHeight = headerHeight; } - // public void setEntryPoints( - // Map entryPointFactories) { - // this.entryPoints = entryPointFactories; - // } - public void setBranding(Map> branding) { this.branding = branding; } @@ -317,7 +305,9 @@ public class CmsApplication implements CmsConstants, ApplicationConfiguration, bodyArea.setData(RWT.CUSTOM_VARIANT, CmsStyles.CMS_BODY); bodyArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - bodyArea.setBackgroundMode(SWT.INHERIT_DEFAULT); + // Should not be set here: it then prevent all children + // composite to define a background color via CSS + // bodyArea.setBackgroundMode(SWT.INHERIT_DEFAULT); bodyArea.setLayout(CmsUtils.noSpaceGridLayout()); refreshBody(); } catch (Exception e) { @@ -373,20 +363,6 @@ public class CmsApplication implements CmsConstants, ApplicationConfiguration, if (state == null) throw new CmsException("State cannot be null"); uiProvider.createUi(bodyArea, getNode()); - // if (page == null) - // throw new CmsException("Page cannot be null"); - // // else if (state.length() == 0) - // // log.debug("empty state"); - // else if (pages.containsKey(page)) - // pages.get(page).createUi(bodyArea, getNode()); - // else { - // // try { - // // RWT.getResponse().sendError(404); - // // } catch (IOException e) { - // // log.error("Cannot send 404 code", e); - // // } - // throw new CmsException("Unsupported state " + state); - // } } catch (RepositoryException e) { throw new CmsException("Cannot refresh body", e); } @@ -394,17 +370,12 @@ public class CmsApplication implements CmsConstants, ApplicationConfiguration, bodyArea.layout(true, true); } - @Override - protected void logAsAnonymous() { - cmsLogin.logInAsAnonymous(); - } - @Override protected Node getDefaultNode(Session session) throws RepositoryException { if (!session.hasPermission(basePath, "read")) { if (session.getUserID().equals("anonymous")) - throw new CmsLoginRequiredException(); + throw new LoginRequiredException(); else throw new CmsException("Unauthorized"); }