01: /******************************************************************************
02: * JBoss, a division of Red Hat *
03: * Copyright 2006, Red Hat Middleware, LLC, and individual *
04: * contributors as indicated by the @authors tag. See the *
05: * copyright.txt in the distribution for a full listing of *
06: * individual contributors. *
07: * *
08: * This is free software; you can redistribute it and/or modify it *
09: * under the terms of the GNU Lesser General Public License as *
10: * published by the Free Software Foundation; either version 2.1 of *
11: * the License, or (at your option) any later version. *
12: * *
13: * This software is distributed in the hope that it will be useful, *
14: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16: * Lesser General Public License for more details. *
17: * *
18: * You should have received a copy of the GNU Lesser General Public *
19: * License along with this software; if not, write to the Free *
20: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
21: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
22: ******************************************************************************/package org.jboss.portal.core.identity.ui.common;
23:
24: import java.util.Map;
25:
26: import javax.faces.context.ExternalContext;
27: import javax.faces.context.FacesContext;
28:
29: import org.jboss.portal.core.identity.services.metadata.IdentityUIConfiguration;
30: import org.jboss.portal.core.identity.services.metadata.UIComponentConfiguration;
31: import org.jboss.portal.faces.el.PropertyValue;
32: import org.jboss.portal.faces.el.dynamic.DynamicBean;
33: import org.jboss.portal.server.ServerInvocationContext;
34: import org.jboss.portlet.JBossRenderRequest;
35:
36: /**
37: * @author <a href="mailto:emuckenh@redhat.com">Emanuel Muckenhuber</a>
38: * @version $Revision$
39: */
40: public class MetaDataServiceBean implements DynamicBean {
41: /** The map */
42: Map map = null;
43:
44: public MetaDataServiceBean() {
45: FacesContext ctx = FacesContext.getCurrentInstance();
46: ConfigurationBean cfb = (ConfigurationBean) ctx
47: .getApplication().createValueBinding(
48: ("#{configurationbean}")).getValue(ctx);
49: IdentityUIConfiguration cf = cfb.getConfiguration();
50: this .map = cf.getUiComponents();
51: }
52:
53: public Class getType(Object propertyName)
54: throws IllegalArgumentException {
55: return UIComponentConfiguration.class;
56: }
57:
58: public PropertyValue getValue(Object propertyName)
59: throws IllegalArgumentException {
60: UIComponentConfiguration uiComponent = (UIComponentConfiguration) map
61: .get((String) propertyName);
62: return uiComponent != null ? new PropertyValue(uiComponent)
63: : null;
64: }
65:
66: public boolean setValue(Object propertyName, Object value)
67: throws IllegalArgumentException {
68: return true;
69: }
70:
71: /** used for building the url after validating email */
72: public String getPortalContextPath() {
73: ExternalContext ectx = FacesContext.getCurrentInstance()
74: .getExternalContext();
75: JBossRenderRequest request = (JBossRenderRequest) ectx
76: .getRequest();
77: ServerInvocationContext invocationContext = request
78: .getControllerContext().getServerInvocation()
79: .getServerContext();
80: return invocationContext.getPortalContextPath();
81: }
82: }
|