Author: julien(a)jboss.com
Date: 2007-03-15 09:39:19 -0400 (Thu, 15 Mar 2007)
New Revision: 6686
Added:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
Removed:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/InstanceManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortletManagerBean.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
trunk/faces/src/main/org/jboss/portal/faces/el/DelegatingPropertyResolver.java
trunk/faces/src/main/org/jboss/portal/test/faces/el/DelegatingPropertyResolverTestCase.java
Log:
- made the DelegatingPropertyResolver configuration not static
- now have a subclass of DelegatingPropertyResolver to configure it and registered as the
application property resolver
- simplified the security domain configurator bean wiring with other beans
Copied:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java (from
rev 6671, trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java)
===================================================================
--- trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java
(rev 0)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/AdminPropertyResolver.java 2007-03-15
13:39:19 UTC (rev 6686)
@@ -0,0 +1,327 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated by the @authors tag. See the *
+ * copyright.txt in the distribution for a full listing of *
+ * individual contributors. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.portal.core.admin.ui;
+
+import org.jboss.portal.faces.el.decorator.SimpleBeanDecorator;
+import org.jboss.portal.faces.el.decorator.AbstractPropertyDecorator;
+import org.jboss.portal.faces.el.decorator.AbstractBeanDecorator;
+import org.jboss.portal.faces.el.decorator.PropertyDecorator;
+import org.jboss.portal.faces.el.DelegatingPropertyResolver;
+import org.jboss.portal.identity.RoleModule;
+import org.jboss.portal.identity.IdentityException;
+import org.jboss.portal.common.util.LocalizedString;
+import org.jboss.portal.common.util.IteratorStatus;
+import org.jboss.portal.portlet.Portlet;
+import org.jboss.portal.portlet.PortletInvokerException;
+import org.jboss.portal.portlet.info.MetaInfo;
+import org.jboss.portal.portlet.info.PortletInfo;
+import org.jboss.portal.core.model.instance.Instance;
+import org.jboss.portal.core.model.portal.PortalObject;
+import org.jboss.portal.core.model.portal.PortalObjectId;
+import org.jboss.portal.core.model.content.ContentType;
+import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
+import org.jboss.portal.security.AuthorizationDomainRegistry;
+import org.jboss.portal.security.spi.provider.AuthorizationDomain;
+import org.jboss.portal.theme.LayoutService;
+import org.jboss.portal.theme.PortalLayout;
+import org.jboss.portal.theme.ThemeService;
+import org.jboss.portal.theme.PortalTheme;
+
+import javax.faces.context.FacesContext;
+import javax.faces.model.SelectItem;
+import javax.faces.el.PropertyResolver;
+import java.util.Set;
+import java.util.Locale;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Collection;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class AdminPropertyResolver extends DelegatingPropertyResolver
+{
+
+ public AdminPropertyResolver()
+ {
+ init();
+ }
+
+ public AdminPropertyResolver(PropertyResolver delegate)
+ {
+ super(delegate);
+
+ //
+ init();
+ }
+
+ private void init()
+ {
+ SimpleBeanDecorator roleModuleDecorator = new SimpleBeanDecorator();
+ roleModuleDecorator.setProperty("roles", new
AbstractPropertyDecorator(Set.class)
+ {
+ public Object getValue(Object bean)
+ {
+ try
+ {
+ RoleModule module = (RoleModule)bean;
+ return module.findRoles();
+ }
+ catch (IdentityException e)
+ {
+ e.printStackTrace();
+ return null;
+ }
+ }
+ });
+ registerDecorator(RoleModule.class, roleModuleDecorator);
+
+ //
+ SimpleBeanDecorator localizedStringDecorator = new SimpleBeanDecorator();
+ localizedStringDecorator.setProperty("value", new
AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean)
+ {
+ LocalizedString string = (LocalizedString)bean;
+ FacesContext ctx = FacesContext.getCurrentInstance();
+ Locale locale = ctx.getExternalContext().getRequestLocale();
+ return string.getString(locale, true);
+ }
+ });
+ registerDecorator(LocalizedString.class, localizedStringDecorator);
+
+ //
+ SimpleBeanDecorator portletDecorator = new SimpleBeanDecorator();
+ portletDecorator.setProperty("name", new
AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ Portlet portlet = (Portlet)bean;
+ return portlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
+ }
+ });
+ portletDecorator.setProperty("description", new
AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ Portlet portlet = (Portlet)bean;
+ return portlet.getInfo().getMeta().getMetaValue(MetaInfo.DESCRIPTION);
+ }
+ });
+ portletDecorator.setProperty("keywords", new
AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ Portlet portlet = (Portlet)bean;
+ return portlet.getInfo().getMeta().getMetaValue(MetaInfo.KEYWORDS);
+ }
+ });
+ portletDecorator.setProperty("title", new
AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ Portlet portlet = (Portlet)bean;
+ return portlet.getInfo().getMeta().getMetaValue(MetaInfo.TITLE);
+ }
+ });
+ portletDecorator.setProperty("remotable", new
AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ Portlet portlet = (Portlet)bean;
+ PortletInfo info = portlet.getInfo();
+ return info.isRemotable();
+ }
+ });
+ portletDecorator.setProperty("modes", new
AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ Portlet portlet = (Portlet)bean;
+ return portlet.getInfo().getCapabilities().getModes("text/html");
+ }
+ });
+ portletDecorator.setProperty("windowStates", new
AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ Portlet portlet = (Portlet)bean;
+ return
portlet.getInfo().getCapabilities().getWindowStates("text/html");
+ }
+ });
+ portletDecorator.setProperty("locales", new
AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ Portlet portlet = (Portlet)bean;
+ return new ArrayList(portlet.getInfo().getCapabilities().getAllLocales());
+ }
+ });
+ registerDecorator(Portlet.class, portletDecorator);
+
+ //
+ SimpleBeanDecorator instanceDecorator = new SimpleBeanDecorator();
+ instanceDecorator.setProperty("portlet", new
AbstractPropertyDecorator(Portlet.class)
+ {
+ public Object getValue(Object bean)
+ {
+ Instance instance = (Instance)bean;
+ try
+ {
+ return instance.getPortlet();
+ }
+ catch (PortletInvokerException e)
+ {
+ // If the portlet is not available we want to avoid the stack trace and
rather return null
+ return null;
+ }
+ }
+ });
+ registerDecorator(Instance.class, instanceDecorator);
+
+ //
+ SimpleBeanDecorator portalObjectDecorator = new SimpleBeanDecorator()
+ {
+ private List getChildren(PortalObject object, int mask)
+ {
+ return new ArrayList(object.getChildren(mask));
+ }
+ {
+ setProperty("portals", new
AbstractPropertyDecorator(PortalObject.class)
+ {
+ public Object getValue(Object bean)
+ {
+ PortalObject object = (PortalObject)bean;
+ return getChildren(object, PortalObject.PORTAL_MASK);
+ }
+ });
+ setProperty("pages", new
AbstractPropertyDecorator(PortalObject.class)
+ {
+ public Object getValue(Object bean)
+ {
+ PortalObject object = (PortalObject)bean;
+ return getChildren(object, PortalObject.PAGE_MASK);
+ }
+ });
+ setProperty("windows", new
AbstractPropertyDecorator(PortalObject.class)
+ {
+ public Object getValue(Object bean)
+ {
+ PortalObject object = (PortalObject)bean;
+ return getChildren(object, PortalObject.WINDOW_MASK);
+ }
+ });
+ }
+ };
+ portalObjectDecorator.setProperty("id", new
AbstractPropertyDecorator(PortalObject.class)
+ {
+ public Object getValue(Object bean)
+ {
+ PortalObject object = (PortalObject)bean;
+ PortalObjectId id = object.getId();
+ return id.toString(PortalObjectId.LEGACY_BASE64_FORMAT);
+ }
+ });
+ registerDecorator(PortalObject.class, portalObjectDecorator);
+
+ //
+ registerDecorator(ContentEditorRegistry.class, new AbstractBeanDecorator()
+ {
+ protected PropertyDecorator getProperty(Object propertyName)
+ {
+ ContentType contentType = ContentType.create((String)propertyName);
+ final String instanceName =
ContentEditorRegistry.getInstance().getEditor(contentType);
+ return instanceName == null ? null : new
AbstractPropertyDecorator(String.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ return instanceName;
+ }
+ };
+ }
+ });
+
+ //
+ registerDecorator(AuthorizationDomainRegistry.class, new AbstractBeanDecorator()
+ {
+ protected PropertyDecorator getProperty(final Object propertyName)
+ {
+ return new AbstractPropertyDecorator(AuthorizationDomain.class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ return
((AuthorizationDomainRegistry)bean).getDomain((String)propertyName);
+ }
+ };
+ }
+ });
+
+ //
+ SimpleBeanDecorator layoutServiceDecorator = new SimpleBeanDecorator();
+ layoutServiceDecorator.setProperty("layoutItems", new
AbstractPropertyDecorator(SelectItem[].class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ LayoutService layoutService = (LayoutService)bean;
+ Collection layouts = layoutService.getLayouts();
+ SelectItem[] items = new SelectItem[layouts.size()];
+ for (IteratorStatus i = new IteratorStatus(layouts.iterator());i.hasNext();)
+ {
+ PortalLayout layout = (PortalLayout)i.next();
+ SelectItem item = new SelectItem();
+ String layoutName = layout.getLayoutInfo().getName();
+ item.setValue(layoutName);
+ item.setLabel(layoutName);
+ items[i.getElementIndex()] = item;
+ }
+ return items;
+ }
+ });
+ registerDecorator(LayoutService.class, layoutServiceDecorator);
+
+ //
+ SimpleBeanDecorator themeServiceDecorator = new SimpleBeanDecorator();
+ themeServiceDecorator.setProperty("themeItems", new
AbstractPropertyDecorator(SelectItem[].class)
+ {
+ public Object getValue(Object bean) throws IllegalArgumentException
+ {
+ ThemeService layoutService = (ThemeService)bean;
+ Collection themes = layoutService.getThemes();
+ SelectItem[] items = new SelectItem[themes.size()];
+ for (IteratorStatus i = new IteratorStatus(themes.iterator());i.hasNext();)
+ {
+ PortalTheme name = (PortalTheme)i.next();
+ SelectItem item = new SelectItem();
+ String themeName = name.getThemeInfo().getName();
+ item.setValue(themeName);
+ item.setLabel(themeName);
+ items[i.getElementIndex()] = item;
+ }
+ return items;
+ }
+ });
+ registerDecorator(ThemeService.class, themeServiceDecorator);
+ }
+
+}
Deleted: trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java 2007-03-15
13:15:51 UTC (rev 6685)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/BeanDecorators.java 2007-03-15
13:39:19 UTC (rev 6686)
@@ -1,313 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
- * contributors as indicated by the @authors tag. See the *
- * copyright.txt in the distribution for a full listing of *
- * individual contributors. *
- * *
- * This is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU Lesser General Public License as *
- * published by the Free Software Foundation; either version 2.1 of *
- * the License, or (at your option) any later version. *
- * *
- * This software is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
- * Lesser General Public License for more details. *
- * *
- * You should have received a copy of the GNU Lesser General Public *
- * License along with this software; if not, write to the Free *
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org. *
- ******************************************************************************/
-package org.jboss.portal.core.admin.ui;
-
-import org.jboss.portal.faces.el.decorator.SimpleBeanDecorator;
-import org.jboss.portal.faces.el.decorator.AbstractPropertyDecorator;
-import org.jboss.portal.faces.el.decorator.AbstractBeanDecorator;
-import org.jboss.portal.faces.el.decorator.PropertyDecorator;
-import org.jboss.portal.faces.el.DelegatingPropertyResolver;
-import org.jboss.portal.identity.RoleModule;
-import org.jboss.portal.identity.IdentityException;
-import org.jboss.portal.common.util.LocalizedString;
-import org.jboss.portal.common.util.IteratorStatus;
-import org.jboss.portal.portlet.Portlet;
-import org.jboss.portal.portlet.PortletInvokerException;
-import org.jboss.portal.portlet.info.MetaInfo;
-import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.core.model.instance.Instance;
-import org.jboss.portal.core.model.portal.PortalObject;
-import org.jboss.portal.core.model.portal.PortalObjectId;
-import org.jboss.portal.core.model.content.ContentType;
-import org.jboss.portal.core.impl.model.content.ContentEditorRegistry;
-import org.jboss.portal.security.AuthorizationDomainRegistry;
-import org.jboss.portal.security.spi.provider.AuthorizationDomain;
-import org.jboss.portal.theme.LayoutService;
-import org.jboss.portal.theme.PortalLayout;
-import org.jboss.portal.theme.ThemeService;
-import org.jboss.portal.theme.PortalTheme;
-
-import javax.faces.context.FacesContext;
-import javax.faces.model.SelectItem;
-import java.util.Set;
-import java.util.Locale;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
- * @version $Revision: 1.1 $
- */
-public class BeanDecorators
-{
-
- static
- {
- SimpleBeanDecorator roleModuleDecorator = new SimpleBeanDecorator();
- roleModuleDecorator.setProperty("roles", new
AbstractPropertyDecorator(Set.class)
- {
- public Object getValue(Object bean)
- {
- try
- {
- RoleModule module = (RoleModule)bean;
- return module.findRoles();
- }
- catch (IdentityException e)
- {
- e.printStackTrace();
- return null;
- }
- }
- });
- DelegatingPropertyResolver.registerDecorator(RoleModule.class,
roleModuleDecorator);
-
- //
- SimpleBeanDecorator localizedStringDecorator = new SimpleBeanDecorator();
- localizedStringDecorator.setProperty("value", new
AbstractPropertyDecorator(String.class)
- {
- public Object getValue(Object bean)
- {
- LocalizedString string = (LocalizedString)bean;
- FacesContext ctx = FacesContext.getCurrentInstance();
- Locale locale = ctx.getExternalContext().getRequestLocale();
- return string.getString(locale, true);
- }
- });
- DelegatingPropertyResolver.registerDecorator(LocalizedString.class,
localizedStringDecorator);
-
- //
- SimpleBeanDecorator portletDecorator = new SimpleBeanDecorator();
- portletDecorator.setProperty("name", new
AbstractPropertyDecorator(String.class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- Portlet portlet = (Portlet)bean;
- return portlet.getInfo().getMeta().getMetaValue(MetaInfo.DISPLAY_NAME);
- }
- });
- portletDecorator.setProperty("description", new
AbstractPropertyDecorator(String.class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- Portlet portlet = (Portlet)bean;
- return portlet.getInfo().getMeta().getMetaValue(MetaInfo.DESCRIPTION);
- }
- });
- portletDecorator.setProperty("keywords", new
AbstractPropertyDecorator(String.class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- Portlet portlet = (Portlet)bean;
- return portlet.getInfo().getMeta().getMetaValue(MetaInfo.KEYWORDS);
- }
- });
- portletDecorator.setProperty("title", new
AbstractPropertyDecorator(String.class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- Portlet portlet = (Portlet)bean;
- return portlet.getInfo().getMeta().getMetaValue(MetaInfo.TITLE);
- }
- });
- portletDecorator.setProperty("remotable", new
AbstractPropertyDecorator(String.class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- Portlet portlet = (Portlet)bean;
- PortletInfo info = portlet.getInfo();
- return info.isRemotable();
- }
- });
- portletDecorator.setProperty("modes", new
AbstractPropertyDecorator(String.class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- Portlet portlet = (Portlet)bean;
- return portlet.getInfo().getCapabilities().getModes("text/html");
- }
- });
- portletDecorator.setProperty("windowStates", new
AbstractPropertyDecorator(String.class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- Portlet portlet = (Portlet)bean;
- return
portlet.getInfo().getCapabilities().getWindowStates("text/html");
- }
- });
- portletDecorator.setProperty("locales", new
AbstractPropertyDecorator(String.class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- Portlet portlet = (Portlet)bean;
- return new ArrayList(portlet.getInfo().getCapabilities().getAllLocales());
- }
- });
- DelegatingPropertyResolver.registerDecorator(Portlet.class, portletDecorator);
-
- //
- SimpleBeanDecorator instanceDecorator = new SimpleBeanDecorator();
- instanceDecorator.setProperty("portlet", new
AbstractPropertyDecorator(Portlet.class)
- {
- public Object getValue(Object bean)
- {
- Instance instance = (Instance)bean;
- try
- {
- return instance.getPortlet();
- }
- catch (PortletInvokerException e)
- {
- // If the portlet is not available we want to avoid the stack trace and
rather return null
- return null;
- }
- }
- });
- DelegatingPropertyResolver.registerDecorator(Instance.class, instanceDecorator);
-
- //
- SimpleBeanDecorator portalObjectDecorator = new SimpleBeanDecorator()
- {
- private List getChildren(PortalObject object, int mask)
- {
- return new ArrayList(object.getChildren(mask));
- }
- {
- setProperty("portals", new
AbstractPropertyDecorator(PortalObject.class)
- {
- public Object getValue(Object bean)
- {
- PortalObject object = (PortalObject)bean;
- return getChildren(object, PortalObject.PORTAL_MASK);
- }
- });
- setProperty("pages", new
AbstractPropertyDecorator(PortalObject.class)
- {
- public Object getValue(Object bean)
- {
- PortalObject object = (PortalObject)bean;
- return getChildren(object, PortalObject.PAGE_MASK);
- }
- });
- setProperty("windows", new
AbstractPropertyDecorator(PortalObject.class)
- {
- public Object getValue(Object bean)
- {
- PortalObject object = (PortalObject)bean;
- return getChildren(object, PortalObject.WINDOW_MASK);
- }
- });
- }
- };
- portalObjectDecorator.setProperty("id", new
AbstractPropertyDecorator(PortalObject.class)
- {
- public Object getValue(Object bean)
- {
- PortalObject object = (PortalObject)bean;
- PortalObjectId id = object.getId();
- return id.toString(PortalObjectId.LEGACY_BASE64_FORMAT);
- }
- });
- DelegatingPropertyResolver.registerDecorator(PortalObject.class,
portalObjectDecorator);
-
- //
- DelegatingPropertyResolver.registerDecorator(ContentEditorRegistry.class, new
AbstractBeanDecorator()
- {
- protected PropertyDecorator getProperty(Object propertyName)
- {
- ContentType contentType = ContentType.create((String)propertyName);
- final String instanceName =
ContentEditorRegistry.getInstance().getEditor(contentType);
- return instanceName == null ? null : new
AbstractPropertyDecorator(String.class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- return instanceName;
- }
- };
- }
- });
-
- //
- DelegatingPropertyResolver.registerDecorator(AuthorizationDomainRegistry.class, new
AbstractBeanDecorator()
- {
- protected PropertyDecorator getProperty(final Object propertyName)
- {
- return new AbstractPropertyDecorator(AuthorizationDomain.class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- return
((AuthorizationDomainRegistry)bean).getDomain((String)propertyName);
- }
- };
- }
- });
-
- //
- SimpleBeanDecorator layoutServiceDecorator = new SimpleBeanDecorator();
- layoutServiceDecorator.setProperty("layoutItems", new
AbstractPropertyDecorator(SelectItem[].class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- LayoutService layoutService = (LayoutService)bean;
- Collection layouts = layoutService.getLayouts();
- SelectItem[] items = new SelectItem[layouts.size()];
- for (IteratorStatus i = new IteratorStatus(layouts.iterator());i.hasNext();)
- {
- PortalLayout layout = (PortalLayout)i.next();
- SelectItem item = new SelectItem();
- String layoutName = layout.getLayoutInfo().getName();
- item.setValue(layoutName);
- item.setLabel(layoutName);
- items[i.getElementIndex()] = item;
- }
- return items;
- }
- });
- DelegatingPropertyResolver.registerDecorator(LayoutService.class,
layoutServiceDecorator);
-
- //
- SimpleBeanDecorator themeServiceDecorator = new SimpleBeanDecorator();
- themeServiceDecorator.setProperty("themeItems", new
AbstractPropertyDecorator(SelectItem[].class)
- {
- public Object getValue(Object bean) throws IllegalArgumentException
- {
- ThemeService layoutService = (ThemeService)bean;
- Collection themes = layoutService.getThemes();
- SelectItem[] items = new SelectItem[themes.size()];
- for (IteratorStatus i = new IteratorStatus(themes.iterator());i.hasNext();)
- {
- PortalTheme name = (PortalTheme)i.next();
- SelectItem item = new SelectItem();
- String themeName = name.getThemeInfo().getName();
- item.setValue(themeName);
- item.setLabel(themeName);
- items[i.getElementIndex()] = item;
- }
- return items;
- }
- });
- DelegatingPropertyResolver.registerDecorator(ThemeService.class,
themeServiceDecorator);
- }
-}
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/InstanceManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/InstanceManagerBean.java 2007-03-15
13:15:51 UTC (rev 6685)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/InstanceManagerBean.java 2007-03-15
13:39:19 UTC (rev 6686)
@@ -67,10 +67,10 @@
private InstanceContainer instanceContainer;
/** . */
- private AuthorizationDomainRegistry authorizationDomainRegistry;
+ private RoleModule roleModule;
/** . */
- private RoleModule roleModule;
+ private DomainConfigurator domainConfigurator;
// Navigational state of the user
@@ -105,16 +105,6 @@
// Services accessors
- public AuthorizationDomainRegistry getAuthorizationDomainRegistry()
- {
- return authorizationDomainRegistry;
- }
-
- public void setAuthorizationDomainRegistry(AuthorizationDomainRegistry
authorizationDomainRegistry)
- {
- this.authorizationDomainRegistry = authorizationDomainRegistry;
- }
-
public RoleModule getRoleModule()
{
return roleModule;
@@ -135,6 +125,16 @@
this.instanceContainer = instanceContainer;
}
+ public DomainConfigurator getDomainConfigurator()
+ {
+ return domainConfigurator;
+ }
+
+ public void setDomainConfigurator(DomainConfigurator domainConfigurator)
+ {
+ this.domainConfigurator = domainConfigurator;
+ }
+
// Navigational state accessor
public int getPaginationSize()
@@ -184,11 +184,6 @@
// Runtime fields
- public DomainConfigurator getDomainConfigurator()
- {
- return
authorizationDomainRegistry.getDomain("instance").getConfigurator();
- }
-
public Instance getSelectedInstance()
{
if (selectedInstance == null && selectedId != null)
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-15
13:15:51 UTC (rev 6685)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortalObjectManagerBean.java 2007-03-15
13:39:19 UTC (rev 6686)
@@ -92,12 +92,9 @@
private ThemeService themeService;
/** . */
- private AuthorizationDomainRegistry authorizationDomainRegistry;
+ private DomainConfigurator domainConfigurator;
/** . */
- private PortalAuthorizationManagerFactory portalAuthorizationManagerFactory;
-
- /** . */
private RoleModule roleModule;
// Navigational state
@@ -186,16 +183,6 @@
return null;
}
- public PortalAuthorizationManagerFactory getPortalAuthorizationManagerFactory()
- {
- return portalAuthorizationManagerFactory;
- }
-
- public void setPortalAuthorizationManagerFactory(PortalAuthorizationManagerFactory
portalAuthorizationManagerFactory)
- {
- this.portalAuthorizationManagerFactory = portalAuthorizationManagerFactory;
- }
-
public RoleModule getRoleModule()
{
return roleModule;
@@ -247,16 +234,6 @@
this.themeService = themeService;
}
- public AuthorizationDomainRegistry getAuthorizationDomainRegistry()
- {
- return authorizationDomainRegistry;
- }
-
- public void setAuthorizationDomainRegistry(AuthorizationDomainRegistry
authorizationDomainRegistry)
- {
- this.authorizationDomainRegistry = authorizationDomainRegistry;
- }
-
public ContentType getSelectedContentType()
{
return selectedContentType;
@@ -307,6 +284,16 @@
this.selectedContentParameters = selectedContentParameters;
}
+ public DomainConfigurator getDomainConfigurator()
+ {
+ return domainConfigurator;
+ }
+
+ public void setDomainConfigurator(DomainConfigurator domainConfigurator)
+ {
+ this.domainConfigurator = domainConfigurator;
+ }
+
// Runtime state
public PortletInvoker getPortletDefinitionInvoker()
@@ -324,11 +311,6 @@
return themes;
}
- public DomainConfigurator getDomainConfigurator()
- {
- return
authorizationDomainRegistry.getDomain("portalobject").getConfigurator();
- }
-
public SelectItem[] getInstanceItems()
{
return instanceItems;
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortletManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortletManagerBean.java 2007-03-15
13:15:51 UTC (rev 6685)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/PortletManagerBean.java 2007-03-15
13:39:19 UTC (rev 6686)
@@ -62,7 +62,7 @@
static
{
// For the loading of the class that will load the decorators
- Class clazz = BeanDecorators.class;
+ Class clazz = AdminPropertyResolver.class;
log.debug("Loaded bean decorator class " + clazz.getName());
}
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-15
13:15:51 UTC (rev 6685)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/faces-config.xml 2007-03-15
13:39:19 UTC (rev 6686)
@@ -28,7 +28,7 @@
<faces-config>
<application>
-
<property-resolver>org.jboss.portal.faces.el.DelegatingPropertyResolver</property-resolver>
+
<property-resolver>org.jboss.portal.core.admin.ui.AdminPropertyResolver</property-resolver>
<view-handler>com.sun.facelets.FaceletPortletViewHandler</view-handler>
</application>
@@ -68,13 +68,9 @@
<value>#{applicationScope.ThemeService}</value>
</managed-property>
<managed-property>
- <property-name>authorizationDomainRegistry</property-name>
- <value>#{applicationScope.AuthorizationDomainRegistry}</value>
+ <property-name>domainConfigurator</property-name>
+
<value>#{applicationScope.AuthorizationDomainRegistry.portalobject.configurator}</value>
</managed-property>
- <managed-property>
- <property-name>portalAuthorizationManagerFactory</property-name>
-
<value>#{applicationScope.PortalAuthorizationManagerFactory}</value>
- </managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>portalAction</managed-bean-name>
@@ -135,8 +131,8 @@
<value>#{applicationScope.InstanceContainer}</value>
</managed-property>
<managed-property>
- <property-name>authorizationDomainRegistry</property-name>
- <value>#{applicationScope.AuthorizationDomainRegistry}</value>
+ <property-name>domainConfigurator</property-name>
+
<value>#{applicationScope.AuthorizationDomainRegistry.instance.configurator}</value>
</managed-property>
</managed-bean>
Modified: trunk/faces/src/main/org/jboss/portal/faces/el/DelegatingPropertyResolver.java
===================================================================
---
trunk/faces/src/main/org/jboss/portal/faces/el/DelegatingPropertyResolver.java 2007-03-15
13:15:51 UTC (rev 6685)
+++
trunk/faces/src/main/org/jboss/portal/faces/el/DelegatingPropertyResolver.java 2007-03-15
13:39:19 UTC (rev 6686)
@@ -50,24 +50,8 @@
private final PropertyResolver delegate;
/** . */
- private static volatile Map decoratorMap = new HashMap();
+ private volatile Map decoratorMap = new HashMap();
- public static synchronized void registerDecorator(Class clazz, BeanDecorator
decorator)
- {
- if (clazz == null)
- {
- throw new IllegalArgumentException();
- }
- if (decorator == null)
- {
- throw new IllegalArgumentException();
- }
- Map copy = new HashMap(decoratorMap);
- copy.put(clazz.getName(), decorator);
- decoratorMap = copy;
- log.debug("Added bean decorator " + clazz.getName() + " in resolver
map");
- }
-
public DelegatingPropertyResolver(PropertyResolver delegate)
{
this.delegate = delegate;
@@ -284,6 +268,22 @@
throw createPNFE(base, index);
}
+ public final synchronized void registerDecorator(Class clazz, BeanDecorator
decorator)
+ {
+ if (clazz == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ if (decorator == null)
+ {
+ throw new IllegalArgumentException();
+ }
+ Map copy = new HashMap(decoratorMap);
+ copy.put(clazz.getName(), decorator);
+ decoratorMap = copy;
+ log.debug("Added bean decorator " + clazz.getName() + " in resolver
map");
+ }
+
private static interface BeanAction
{
boolean execute(BeanDecorator decorator);
@@ -390,5 +390,4 @@
{
return new PropertyNotFoundException("Property " + propertyName + "
on object " + base + " was not found");
}
-
}
Modified:
trunk/faces/src/main/org/jboss/portal/test/faces/el/DelegatingPropertyResolverTestCase.java
===================================================================
---
trunk/faces/src/main/org/jboss/portal/test/faces/el/DelegatingPropertyResolverTestCase.java 2007-03-15
13:15:51 UTC (rev 6685)
+++
trunk/faces/src/main/org/jboss/portal/test/faces/el/DelegatingPropertyResolverTestCase.java 2007-03-15
13:39:19 UTC (rev 6686)
@@ -66,9 +66,14 @@
testBeanDecorator = new TestBeanDecorator(testBean.property);
testBeanInterfaceDecorator = new TestBeanDecorator(testBean.interfaceProperty);
testBeanInterfaceSuperInterfaceDecorator = new
TestBeanDecorator(testBean.interfaceSuperInterfaceProperty);
- DelegatingPropertyResolver.registerDecorator(TestBean.class, testBeanDecorator);
- DelegatingPropertyResolver.registerDecorator(TestBeanInterface.class,
testBeanInterfaceDecorator);
- DelegatingPropertyResolver.registerDecorator(TestBeanInterfaceSuperInterface.class,
testBeanInterfaceSuperInterfaceDecorator);
+ resolver = new DelegatingPropertyResolver()
+ {
+ {
+ registerDecorator(TestBean.class, testBeanDecorator);
+ registerDecorator(TestBeanInterface.class, testBeanInterfaceDecorator);
+ registerDecorator(TestBeanInterfaceSuperInterface.class,
testBeanInterfaceSuperInterfaceDecorator);
+ }
+ };
testDynamicBean = new TestDynamicBean();
resolver = new DelegatingPropertyResolver();
}