001: /******************************************************************************
002: * JBoss, a division of Red Hat *
003: * Copyright 2006, Red Hat Middleware, LLC, and individual *
004: * contributors as indicated by the @authors tag. See the *
005: * copyright.txt in the distribution for a full listing of *
006: * individual contributors. *
007: * *
008: * This is free software; you can redistribute it and/or modify it *
009: * under the terms of the GNU Lesser General Public License as *
010: * published by the Free Software Foundation; either version 2.1 of *
011: * the License, or (at your option) any later version. *
012: * *
013: * This software is distributed in the hope that it will be useful, *
014: * but WITHOUT ANY WARRANTY; without even the implied warranty of *
015: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
016: * Lesser General Public License for more details. *
017: * *
018: * You should have received a copy of the GNU Lesser General Public *
019: * License along with this software; if not, write to the Free *
020: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
021: * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
022: ******************************************************************************/package org.jboss.portlet;
023:
024: import org.jboss.portal.api.node.PortalNode;
025: import org.jboss.portal.core.aspects.controller.node.Navigation;
026: import org.jboss.portal.core.controller.ControllerContext;
027: import org.jboss.portal.core.controller.portlet.ControllerUserContext;
028: import org.jboss.portal.identity.User;
029: import org.jboss.portal.portlet.impl.jsr168.api.RenderRequestImpl;
030: import org.jboss.portal.portlet.invocation.PortletInvocation;
031: import org.jboss.portal.portlet.invocation.RenderInvocation;
032: import org.jboss.portlet.util.Parameters;
033:
034: import javax.portlet.PortletPreferences;
035: import java.util.Map;
036:
037: /**
038: * @author <a href="mailto:julien@jboss.org">Julien Viet </a>
039: * @version $Revision: 8786 $
040: */
041: public class JBossRenderRequest extends RenderRequestImpl {
042:
043: /** The parameters. */
044: private Parameters blah;
045:
046: /** . */
047: private ControllerContext controllerContext;
048:
049: public JBossRenderRequest(RenderInvocation invocation) {
050: super (invocation);
051:
052: //
053: this .controllerContext = (ControllerContext) invocation
054: .getAttribute(PortletInvocation.INVOCATION_SCOPE,
055: "controller_context");
056: }
057:
058: public ControllerContext getControllerContext() {
059: if (controllerContext == null) {
060: throw new IllegalStateException("No controller context");
061: }
062: return controllerContext;
063: }
064:
065: // protected PortletPreferences createPreferences()
066: // {
067: // CorePortletContainer container = (CorePortletContainer) portletInstance.getPortletContainer();
068: // PreferencesValidator validator = container.getPreferencesValidator();
069: // ProxyInfo proxyCtor = container.getPreferenceProxyConstructor();
070: // return new JBossPortletPreferences(propertySets, validator, PortletPreferencesImpl.RENDER, proxyCtor);
071: // }
072:
073: public PortalNode getPortalNode() {
074: return Navigation.getCurrentNode();
075: }
076:
077: /** Returns a modifiable map of user informations or null if the user is not authenticated. */
078: public Map getInformations() {
079: return userContext.getInformations();
080: }
081:
082: /** Returns the current authenticated user or null if the user is not authenticated */
083: public User getUser() {
084: if (userContext instanceof ControllerUserContext) {
085: return ((ControllerUserContext) userContext).getUser();
086: } else {
087: return null;
088: }
089: }
090:
091: public Parameters getParameters() {
092: if (blah == null) {
093: blah = new Parameters(getParameterMap());
094: }
095: return blah;
096: }
097:
098: protected PortletPreferences createPreferences() {
099: // Component container = instance.getComponent();
100: // ProxyPreferenceSetPlugin plugin = (ProxyPreferenceSetPlugin)container.getPlugin("PROXY");
101: // if (plugin != null)
102: // {
103: // PreferencesValidator validator = container.getPreferencesValidator();
104: // ProxyInfo proxyCtor = container.getPreferenceProxyConstructor();
105: // return new JBossPortletPreferences(
106: // propertySets,
107: // validator,
108: // PortletPreferencesImpl.RENDER,
109: // proxyCtor);
110: // }
111: return null;
112: }
113:
114: // public PortalTheme getTheme()
115: // {
116: // return (PortalTheme)invocation.getDispatchedRequest().getAttribute(ThemeConstants.ATTR_THEME);
117: // }
118: }
|