You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jetspeed-dev@portals.apache.org by we...@apache.org on 2005/12/06 22:21:23 UTC
svn commit: r354565 - in
/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed:
decoration/ decoration/caches/ decoration/validators/ velocity/
Author: weaver
Date: Tue Dec 6 13:21:17 2005
New Revision: 354565
URL: http://svn.apache.org/viewcvs?rev=354565&view=rev
Log:
http://issues.apache.org/jira/browse/JS2-398:
-Decorations moved to where they are accessible via normal requests.
- removed decorations for WEB-INF
Added:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java (with props)
Modified:
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/BaseDecoration.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/LayoutDecorationImpl.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/PageTheme.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/PortletDecorationImpl.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/caches/SessionPathResolverCache.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/validators/WebApplicationResourceValidator.java
portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/BaseDecoration.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/BaseDecoration.java?rev=354565&r1=354564&r2=354565&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/BaseDecoration.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/BaseDecoration.java Tue Dec 6 13:21:17 2005
@@ -15,14 +15,23 @@
*/
package org.apache.jetspeed.decoration;
+import java.util.Collections;
+import java.util.List;
import java.util.Properties;
import org.apache.jetspeed.util.Path;
/**
+ * Base class implementing the most common methods shared between
+ * LayoutDecorations and PortletDecorations.
+ *
*
* @author <href a="mailto:weaver@apache.org">Scott T. Weaver</a>
*
+ * @see org.apache.jetspeed.decoration.Decoration
+ * @see org.apache.jetspeed.decoration.LayoutDecoration
+ * @see org.apache.jetspeed.decoration.PortletDecoration
+ *
*/
public class BaseDecoration implements Decoration
{
@@ -33,12 +42,15 @@
private final Path basePath;
private final PathResolverCache cache;
private final String styleSheet;
+ private List actions;
/**
*
- * @param config
- * @param validator
- * @param basePath
+ * @param config <code>java.util.Properties</code> object containing configuration infomation
+ * for this Decoration.
+ * @param validator The ResourceValidator to be used in looking up fully-qualified resource pathes
+ * @param basePath The "root" of the decroation hierarchy.
+ *
* @throws InvalidDecorationConfigurationException
*/
public BaseDecoration(Properties config, ResourceValidator validator, Path basePath, PathResolverCache cache)
@@ -70,14 +82,32 @@
String locatedPath = getResource((Path)basePath.clone(), new Path(path));
if(!locatedPath.startsWith(NO_SUCH_RESOURCE))
{
+ if(!path.startsWith("/"))
+ {
+ locatedPath = locatedPath.substring(1);
+ }
+
cache.addPath(workingPath.toString(), locatedPath);
}
+
+
return locatedPath;
}
}
+ /**
+ * Recursively tries to locate a resource.
+ *
+ * @param rootPath initial path to start looking for the <code>searchPath.</code>
+ * The "pruning" of the rootPath of subsequest recursive calls follows the logic
+ * detailed in the {@link Decoration#getResource(String)} method.
+ * @param searchPath relative path to the resource we wish to locate.
+ * @return
+ *
+ * @see Decoration
+ */
protected String getResource(Path rootPath, Path searchPath)
{
String pathString = rootPath.getChild(searchPath).toString();
@@ -99,6 +129,33 @@
public String getStyleSheet()
{
return getResource(styleSheet);
+ }
+
+ public List getActions()
+ {
+ if(actions != null)
+ {
+ return actions;
+ }
+ else
+ {
+ return Collections.EMPTY_LIST;
+ }
+ }
+
+ public void setActions(List actions)
+ {
+ this.actions = actions;
+ }
+
+ public String getProperty(String name)
+ {
+ return config.getProperty(name);
+ }
+
+ public String getBaseCSSClass()
+ {
+ return config.getProperty(Decoration.BASE_CSS_CLASS_PROP, getName());
}
}
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java?rev=354565&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java Tue Dec 6 13:21:17 2005
@@ -0,0 +1,443 @@
+/*
+ * Copyright 2000-2001,2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.jetspeed.decoration;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.JetspeedActions;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.components.portletentity.PortletEntityNotStoredException;
+import org.apache.jetspeed.container.state.NavigationalState;
+import org.apache.jetspeed.container.url.PortalURL;
+import org.apache.jetspeed.container.window.FailedToRetrievePortletWindow;
+import org.apache.jetspeed.container.window.PortletWindowAccessor;
+import org.apache.jetspeed.om.common.portlet.PortletDefinitionComposite;
+import org.apache.jetspeed.om.page.ContentFragment;
+import org.apache.jetspeed.om.page.ContentPage;
+import org.apache.jetspeed.om.page.Page;
+import org.apache.jetspeed.pipeline.PipelineException;
+import org.apache.jetspeed.pipeline.valve.AbstractValve;
+import org.apache.jetspeed.pipeline.valve.Valve;
+import org.apache.jetspeed.pipeline.valve.ValveContext;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.velocity.DecoratorAction;
+import org.apache.jetspeed.velocity.JetspeedPowerToolImpl;
+import org.apache.jetspeed.velocity.PageActionAccess;
+import org.apache.pluto.om.entity.PortletEntity;
+import org.apache.pluto.om.portlet.ContentTypeSet;
+import org.apache.pluto.om.window.PortletWindow;
+
+/**
+ * Assigns decorations and page actions to all of the portlet Fragments within
+ * the current request.
+ *
+ * @see org.apache.jetspeed.om.page.Fragment
+ * @see org.apache.jetspeed.om.page.Page
+ * @see org.apache.jetspeed.decoration.Decoration
+ * @see org.apache.jetspeed.decoration.LayoutDecoration
+ * @see org.apache.jetspeed.decoration.PortletDecoration
+ * @see org.apache.jetspeed.decoration.Theme
+ *
+ * @author <href a="mailto:weaver@apache.org">Scott T. Weaver</a>
+ *
+ */
+public class DecorationValve extends AbstractValve implements Valve
+{
+ public static final String ACTION_IMAGE_EXTENSION_ATTR = "actionImageExtension";
+
+ protected final static Log log = LogFactory.getLog(DecorationValve.class);
+
+ private final DecorationFactory decorationFactory;
+
+ private final PortletWindowAccessor windowAccessor;
+
+ public DecorationValve(DecorationFactory decorationFactory, PortletWindowAccessor windowAccessor)
+ {
+ this.decorationFactory = decorationFactory;
+ this.windowAccessor = windowAccessor;
+ }
+
+
+ public void invoke(RequestContext requestContext, ValveContext context) throws PipelineException
+ {
+ if (requestContext.getRequest().getParameter("clearThemeCache") != null)
+ {
+ decorationFactory.clearCache(requestContext);
+ }
+ ContentPage page = requestContext.getPage();
+ Theme theme = decorationFactory.getTheme(page, requestContext);
+ requestContext.setAttribute(PortalReservedParameters.PAGE_THEME_ATTRIBUTE, theme);
+
+ PageActionAccess pageActionAccess = getPageActionAccess(requestContext, page);
+
+ ContentFragment rootFragment = page.getRootContentFragment();
+
+ initFragment(requestContext, theme, rootFragment, pageActionAccess);
+
+ context.invokeNext(requestContext);
+ }
+
+ public String toString()
+ {
+ return "DecorationValve";
+ }
+
+ /**
+ * Returns a <code>PageActionAccess</code> for the current user request.
+ *
+ * @see PageActionAccess
+ * @param requestContext RequestContext of the current portal request.
+ * @param page
+ * @return PageActionAccess for the current user request.
+ */
+ protected PageActionAccess getPageActionAccess(RequestContext requestContext, Page page)
+ {
+ String key = page.getId();
+ boolean loggedOn = isLoggedOn(requestContext);
+ boolean anonymous = !loggedOn;
+ PageActionAccess pageActionAccess = null;
+
+
+ Map sessionActions = (Map) requestContext.getSessionAttribute(JetspeedPowerToolImpl.POWER_TOOL_SESSION_ACTIONS);
+ if (sessionActions == null)
+ {
+ sessionActions = new HashMap();
+ requestContext.setSessionAttribute(JetspeedPowerToolImpl.POWER_TOOL_SESSION_ACTIONS, sessionActions);
+ }
+ else
+ {
+ pageActionAccess = (PageActionAccess) sessionActions.get(key);
+ }
+ if (pageActionAccess == null)
+ {
+ pageActionAccess = new PageActionAccess(anonymous, page);
+ sessionActions.put(key, pageActionAccess);
+ }
+ else
+ {
+ pageActionAccess.checkReset(loggedOn, page);
+ }
+
+
+ return pageActionAccess;
+ }
+
+ /**
+ * Indicates if the user of the current request has been authenticated.
+ *
+ * @param requestContext RequestContext of the current portal request.
+ * @return <code>true</code> if the user is currently authenticated, otherwise returns
+ * <code>false</code>.
+ */
+ protected boolean isLoggedOn(RequestContext requestContext)
+ {
+ Principal principal = requestContext.getRequest().getUserPrincipal();
+ return (principal != null);
+ }
+
+ /**
+ * Returns the current <code>PortletMode</code> for the target
+ * <code>Fragment</code> in the current portal request.
+ *
+ * @param requestContext RequestContext of the current portal request.
+ * @param fragment Fragment for which the PortletMode has been requested.
+ * @return <code>PortletMode</code> for the target
+ * <code>Fragment</code> in the current portal request.
+ *
+ * @throws FailedToRetrievePortletWindow
+ * @throws PortletEntityNotStoredException
+ */
+ protected PortletMode getPortletMode(RequestContext requestContext, ContentFragment fragment)
+ throws FailedToRetrievePortletWindow, PortletEntityNotStoredException
+ {
+ NavigationalState nav = requestContext.getPortalURL().getNavigationalState();
+ return nav.getMode(windowAccessor.getPortletWindow(fragment));
+ }
+
+ /**
+ * Gets the window state for the current portlet window (fragment)
+ *
+ * @return The window state for the current window
+ * @throws PortletEntityNotStoredException
+ * @throws FailedToRetrievePortletWindow
+ * @throws Exception
+ */
+ protected WindowState getWindowState(RequestContext requestContext, ContentFragment fragment) throws FailedToRetrievePortletWindow, PortletEntityNotStoredException
+ {
+ NavigationalState nav = requestContext.getPortalURL().getNavigationalState();
+ return nav.getState(windowAccessor.getPortletWindow(fragment));
+ }
+
+ /**
+ * Builds and assigns a list of available portlet modes and window states for
+ * the target <code>Fragment</code>.
+ *
+ * @param requestContext RequestContext of the current portal request.
+ * @param fragment Fragment to initialize modes and states for.
+ * @return
+ * @throws PortletEntityNotStoredException
+ * @throws FailedToRetrievePortletWindow
+ */
+ protected void initActionsForFragment(RequestContext requestContext, ContentFragment fragment, PageActionAccess pageActionAccess, Decoration decoration) throws FailedToRetrievePortletWindow, PortletEntityNotStoredException
+ {
+ PortletEntity portletEntity = windowAccessor.getPortletWindow(fragment).getPortletEntity();
+ PortletDefinitionComposite portlet = (PortletDefinitionComposite) portletEntity.getPortletDefinition();
+ Page page = requestContext.getPage();
+
+ if (null == portlet)
+ {
+ return; // allow nothing
+ }
+
+ List actions = new ArrayList();
+
+ PortletMode mode = getPortletMode(requestContext, fragment);
+ WindowState state = getWindowState(requestContext, fragment);
+
+ ContentTypeSet content = portlet.getContentTypeSet();
+
+ String fragmentId = fragment.getId();
+ String portletName = portlet.getUniqueName();
+ PortletWindow window = windowAccessor.getPortletWindow(fragment);
+
+ boolean isRootLayout = fragment.equals(page.getRootFragment());
+
+ if (!isRootLayout || pageActionAccess.isEditAllowed())
+ {
+ List portletModeActions = getPortletModes(requestContext, pageActionAccess, mode, content, portletName, window, fragment);
+ actions.addAll(portletModeActions);
+ }
+
+ if(!isRootLayout)
+ {
+ List stateActions = getWindowStates(requestContext, pageActionAccess, state, portletName, window, fragment);
+ actions.addAll(stateActions);
+ }
+
+ decoration.setActions(actions);
+ }
+
+ /**
+ * Builds a list of portlet modes that can be executed on the current
+ * <code>fragment</code> excluding the portlet's current mode.
+ *
+ * @param requestContext RequestContext of the current portal request.
+ * @param pageActionAccess
+ * @param mode
+ * @param content
+ * @param portletName
+ * @param window
+ * @param fragment
+ * @return <code>java.util.List</code> of modes excluding the current one.
+ */
+ protected List getPortletModes(RequestContext requestContext, PageActionAccess pageActionAccess, PortletMode mode, ContentTypeSet content, String portletName, PortletWindow window, ContentFragment fragment)
+ {
+ String fragmentId = fragment.getId();
+ Decoration decoration = fragment.getDecoration();
+ List portletModes = new ArrayList();
+
+ if (mode.equals(PortletMode.VIEW))
+ {
+ if (content.supportsPortletMode(PortletMode.EDIT) && pageActionAccess.isEditAllowed()
+ && pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.EDIT))
+ {
+ portletModes.add(createPortletModeAction(window, JetspeedActions.EDIT, PortletMode.EDIT, requestContext, decoration));
+ }
+ if (content.supportsPortletMode(PortletMode.HELP)
+ && pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.HELP))
+ {
+ portletModes.add(createPortletModeAction(window, JetspeedActions.HELP, PortletMode.HELP, requestContext, decoration));
+ }
+ }
+ else if (mode.equals(PortletMode.EDIT))
+ {
+ if (pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.VIEW))
+ {
+ portletModes.add(createPortletModeAction(window, JetspeedActions.VIEW, PortletMode.VIEW, requestContext, decoration));
+ }
+ if (content.supportsPortletMode(PortletMode.HELP)
+ && pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.HELP))
+ {
+ portletModes.add(createPortletModeAction(window, JetspeedActions.HELP, PortletMode.HELP, requestContext, decoration));
+ }
+ }
+ else
+ // help
+ {
+ if (pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.VIEW))
+ {
+ portletModes.add(createPortletModeAction(window, JetspeedActions.VIEW, PortletMode.VIEW, requestContext, decoration));
+ }
+ if (content.supportsPortletMode(PortletMode.EDIT) && pageActionAccess.isEditAllowed()
+ && pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.EDIT))
+ {
+ portletModes.add(createPortletModeAction(window, JetspeedActions.EDIT, PortletMode.EDIT, requestContext, decoration));
+ }
+ }
+
+ return portletModes;
+ }
+
+
+ /**
+ * Builds a list of window states that can be executed on the current
+ * <code>fragment</code> excluding the portlet's current window state.
+ *
+ * @param requestContext RequestContext of the current portal request.
+ * @param pageActionAccess
+ * @param state
+ * @param portletName
+ * @param window
+ * @param fragment
+ * @return <code>java.util.List</code> of window states excluding the current one.
+ */
+ protected List getWindowStates(RequestContext requestContext, PageActionAccess pageActionAccess, WindowState state, String portletName, PortletWindow window, ContentFragment fragment)
+ {
+ String fragmentId = fragment.getId();
+ Decoration decoration = fragment.getDecoration();
+ ArrayList actions = new ArrayList();
+
+ if (state.equals(WindowState.NORMAL))
+ {
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MINIMIZED))
+ {
+ actions.add(createWindowStateAction(window, JetspeedActions.MINIMIZE, WindowState.MINIMIZED,
+ requestContext, decoration));
+ }
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MAXIMIZED))
+ {
+ actions.add(createWindowStateAction(window, JetspeedActions.MAXIMIZE, WindowState.MAXIMIZED,
+ requestContext, decoration));
+ }
+ }
+ else if (state.equals(WindowState.MAXIMIZED))
+ {
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MINIMIZED))
+ {
+ actions.add(createWindowStateAction(window, JetspeedActions.MINIMIZE, WindowState.MINIMIZED,
+ requestContext, decoration));
+ }
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, JetspeedActions.RESTORED))
+ {
+ actions.add(createWindowStateAction(window, JetspeedActions.RESTORE, WindowState.NORMAL,
+ requestContext, decoration));
+ }
+ }
+ else
+ // minimized
+ {
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MAXIMIZED))
+ {
+ actions.add(createWindowStateAction(window, JetspeedActions.MAXIMIZE, WindowState.MAXIMIZED,
+ requestContext, decoration));
+ }
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, JetspeedActions.RESTORED))
+ {
+ actions.add(createWindowStateAction(window, JetspeedActions.RESTORE, WindowState.NORMAL,
+ requestContext, decoration));
+ }
+ }
+
+ return actions;
+ }
+
+ /**
+ * Creates a Decorator PortletMode Action to be added to the list of actions
+ * decorating a portlet.
+ */
+ protected DecoratorAction createPortletModeAction(PortletWindow window, String actionName, PortletMode mode,
+ RequestContext requestContext, Decoration decoration)
+ {
+ DecoratorAction action = createDecoratorAction(actionName, decoration);
+
+ PortalURL portalURL = requestContext.getPortalURL();
+ action.setAction(portalURL.createPortletURL(window, mode, null, portalURL.isSecure())
+ .toString());
+ return action;
+ }
+
+ protected DecoratorAction createDecoratorAction(String actionName, Decoration decoration)
+ {
+ String imageExt = ".gif";
+ if (imageExt == null)
+ {
+ imageExt = ".gif";
+ }
+ String link = decoration.getResource("images/" + actionName + ".gif");
+ return new DecoratorAction(actionName, actionName, link);
+ }
+
+ /**
+ * Creates a Decorator WindowState Action to be added to the list of actions
+ * decorating a portlet.
+ */
+ protected DecoratorAction createWindowStateAction(PortletWindow window, String actionName, WindowState state,
+ RequestContext requestContext, Decoration decoration)
+ {
+ DecoratorAction action = createDecoratorAction(actionName, decoration);
+ PortalURL portalURL = requestContext.getPortalURL();
+ action.setAction(portalURL.createPortletURL(window, null, state, portalURL.isSecure())
+ .toString());
+ return action;
+ }
+
+ /**
+ * Intializes all fragments with there decorations and portlet modes
+ * and winodw states.
+ *
+ *
+ * @param requestContext RequestContext of the current portal request.
+ * @param theme
+ * @param fragment
+ * @param pageActionAccess
+ */
+ protected void initFragment(RequestContext requestContext, Theme theme, ContentFragment fragment, PageActionAccess pageActionAccess)
+ {
+ final List contentFragments = fragment.getContentFragments();
+
+ if(contentFragments != null && contentFragments.size() > 0)
+ {
+ Iterator itr = contentFragments.iterator();
+ while(itr.hasNext())
+ {
+ ContentFragment aFragment = (ContentFragment) itr.next();
+ initFragment(requestContext, theme, aFragment, pageActionAccess);
+ }
+ }
+
+ try
+ {
+ fragment.setDecoration(theme.getDecoration(fragment));
+ initActionsForFragment(requestContext, fragment, pageActionAccess, theme.getDecoration(fragment));
+ }
+ catch (Exception e)
+ {
+ log.warn("Unable to initalize actions for fragment "+fragment.getId());
+ }
+
+ }
+
+}
Propchange: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/DecorationValve.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/LayoutDecorationImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/LayoutDecorationImpl.java?rev=354565&r1=354564&r2=354565&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/LayoutDecorationImpl.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/LayoutDecorationImpl.java Tue Dec 6 13:21:17 2005
@@ -20,8 +20,11 @@
import org.apache.jetspeed.util.Path;
/**
+ * Default implementation of <code>org.apache.jetspeed.decoration.LayoutDecoration</code>
*
* @author <href a="mailto:weaver@apache.org">Scott T. Weaver</a>
+ *
+ * @see org.apache.jetspeed.decoration.LayoutDecoration
*
*/
public class LayoutDecorationImpl extends BaseDecoration implements LayoutDecoration
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/PageTheme.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/PageTheme.java?rev=354565&r1=354564&r2=354565&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/PageTheme.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/PageTheme.java Tue Dec 6 13:21:17 2005
@@ -26,9 +26,11 @@
import org.apache.jetspeed.request.RequestContext;
/**
+ * Default implementation of <code>org.apache.jetspeed.decoration.Theme</code>
*
* @author <href a="mailto:weaver@apache.org">Scott T. Weaver</a>
*
+ * @see org.apache.jetspeed.decoration.Theme
*/
public class PageTheme implements Theme
{
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/PortletDecorationImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/PortletDecorationImpl.java?rev=354565&r1=354564&r2=354565&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/PortletDecorationImpl.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/PortletDecorationImpl.java Tue Dec 6 13:21:17 2005
@@ -20,13 +20,13 @@
import org.apache.jetspeed.util.Path;
/**
+ * Default implementation of <code>org.apache.jetspeed.decoration.PortletDecoration</code>
*
* @author <href a="mailto:weaver@apache.org">Scott T. Weaver</a>
- *
+ * @see org.apache.jetspeed.decoration.PortletDecoration
*/
public class PortletDecorationImpl extends BaseDecoration implements PortletDecoration
{
-
public PortletDecorationImpl(Properties config, ResourceValidator validator, Path basePath, PathResolverCache cache)
{
super(config, validator, basePath, cache);
@@ -34,7 +34,7 @@
public String getTemplate()
{
- return null;
+ return getResource("decorator.vm");
}
}
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/caches/SessionPathResolverCache.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/caches/SessionPathResolverCache.java?rev=354565&r1=354564&r2=354565&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/caches/SessionPathResolverCache.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/caches/SessionPathResolverCache.java Tue Dec 6 13:21:17 2005
@@ -44,4 +44,9 @@
session.setAttribute(PortalReservedParameters.RESOVLER_CACHE_ATTR, cache);
}
}
+
+ public void clear()
+ {
+ cache.clear();
+ }
}
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/validators/WebApplicationResourceValidator.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/validators/WebApplicationResourceValidator.java?rev=354565&r1=354564&r2=354565&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/validators/WebApplicationResourceValidator.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/decoration/validators/WebApplicationResourceValidator.java Tue Dec 6 13:21:17 2005
@@ -20,6 +20,7 @@
import javax.servlet.ServletContext;
import org.apache.jetspeed.decoration.ResourceValidator;
+import org.springframework.web.context.ServletContextAware;
/**
* This implementation uses <code>ServletContext.getResource()</code>
@@ -28,14 +29,10 @@
* @author <href a="mailto:weaver@apache.org">Scott T. Weaver</a>
*
*/
-public class WebApplicationResourceValidator implements ResourceValidator
+public class WebApplicationResourceValidator implements ResourceValidator, ServletContextAware
{
private ServletContext servletContext;
- public void setServletContext(ServletContext servletContext)
- {
- this.servletContext = servletContext;
- }
public boolean resourceExists(String path)
{
@@ -49,6 +46,13 @@
iae.initCause(e);
throw iae;
}
+ }
+
+
+ public void setServletContext(ServletContext servletContext)
+ {
+ this.servletContext = servletContext;
+
}
}
Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java?rev=354565&r1=354564&r2=354565&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java (original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/velocity/JetspeedPowerToolImpl.java Tue Dec 6 13:21:17 2005
@@ -84,17 +84,23 @@
*
* @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
* @version $Id$
- *
+ *
*/
public class JetspeedPowerToolImpl implements JetspeedPowerTool
{
-
+
private static final String DECORATOR_ID_ATTR = "decoratorId";
+
private static final String ACTION_IMAGE_EXTENSION_ATTR = "actionImageExtension";
+
protected static final String PORTLET_CONFIG_ATTR = "javax.portlet.config";
+
protected static final String RENDER_RESPONSE_ATTR = "javax.portlet.response";
+
protected static final String RENDER_REQUEST_ATTR = "javax.portlet.request";
+
protected static final String COLUMNS_ATTR = "columns";
+
protected static final String COLUMN_SIZES = "columnSizes";
protected RenderRequest renderRequest;
@@ -105,24 +111,33 @@
protected Writer templateWriter;
- protected static final String POWER_TOOL_SESSION_ACTIONS = "org.apache.jetspeed.powertool.actions";
+ public static final String POWER_TOOL_SESSION_ACTIONS = "org.apache.jetspeed.powertool.actions";
protected static final Log log = LogFactory.getLog(JetspeedPowerToolImpl.class);
protected CapabilityMap capabilityMap;
+
protected Locale locale;
+
protected LocatorDescriptor templateLocatorDescriptor;
+
protected TemplateLocator templateLocator;
+
protected PortletEntityAccessComponent entityAccess;
+
protected TemplateLocator decorationLocator;
+
protected LocatorDescriptor decorationLocatorDescriptor;
+
protected PortletWindowAccessor windowAccess;
protected RequestContext requestContext;
+
protected Context velocityContext;
+
private DynamicTitleService titleService;
-
- public JetspeedPowerToolImpl( RequestContext requestContext, DynamicTitleService titleService ) throws Exception
+
+ public JetspeedPowerToolImpl(RequestContext requestContext, DynamicTitleService titleService) throws Exception
{
HttpServletRequest request = requestContext.getRequest();
this.requestContext = requestContext;
@@ -132,7 +147,7 @@
renderRequest = (RenderRequest) request.getAttribute(RENDER_REQUEST_ATTR);
renderResponse = (RenderResponse) request.getAttribute(RENDER_RESPONSE_ATTR);
portletConfig = (PortletConfig) request.getAttribute(PORTLET_CONFIG_ATTR);
-
+
templateLocator = (TemplateLocator) getComponent("TemplateLocator");
decorationLocator = (TemplateLocator) getComponent("DecorationLocator");
// By using null, we create a re-useable locator
@@ -150,7 +165,6 @@
decorationLocatorDescriptor.setLanguage(locale.getLanguage());
}
-
/**
* <p>
* getRequestContext
@@ -163,7 +177,6 @@
return requestContext;
}
-
/**
* Gets the window state for the current portlet window (fragment)
*
@@ -211,19 +224,19 @@
*/
public ContentFragment getCurrentFragment()
{
- checkState();
- return (ContentFragment) renderRequest.getAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE);
+ checkState();
+ return (ContentFragment) renderRequest.getAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE);
}
/**
*
* @param f
*/
- public void setCurrentFragment( ContentFragment f )
+ public void setCurrentFragment(ContentFragment f)
{
checkState();
setAttribute(PortalReservedParameters.FRAGMENT_ATTRIBUTE, f);
-
+
}
public void setCurrentLayout()
@@ -231,7 +244,7 @@
checkState();
ContentFragment f = (ContentFragment) getRequestContext().getRequest().getAttribute(LAYOUT_ATTR);
- setAttribute(LAYOUT_ATTR, f);
+ setAttribute(LAYOUT_ATTR, f);
}
/**
@@ -251,7 +264,8 @@
public Page getPage()
{
checkState();
- // return (Page) renderRequest.getAttribute(PortalReservedParameters.PAGE_ATTRIBUTE_KEY);
+ // return (Page)
+ // renderRequest.getAttribute(PortalReservedParameters.PAGE_ATTRIBUTE_KEY);
return requestContext.getPage();
}
@@ -273,7 +287,7 @@
return null;
return (List) renderRequest.getAttribute(COLUMN_SIZES);
}
-
+
/**
*
* @return
@@ -296,12 +310,12 @@
/**
*
* @param f
- * Fragment whose <code>PortletEntity</code> we want to
- * retreive.
+ * Fragment whose <code>PortletEntity</code> we want to
+ * retreive.
* @return The PortletEntity represented by the current fragment.
* @throws Exception
*/
- public PortletEntity getPortletEntity( ContentFragment f ) throws Exception
+ public PortletEntity getPortletEntity(ContentFragment f) throws Exception
{
PortletEntity portletEntity = entityAccess.getPortletEntityForFragment(f);
if (portletEntity == null)
@@ -332,11 +346,11 @@
* RenderReqeust.
*
* @param f
- * Fragment
+ * Fragment
* @return whether or not the Fragment in question should be considered
- * visible during rendering.
+ * visible during rendering.
*/
- public boolean isHidden( ContentFragment f )
+ public boolean isHidden(ContentFragment f)
{
checkState();
if (f == null)
@@ -353,23 +367,23 @@
*
*
* @param path
- * Expected to the template. This may actually be changed by the
- * TL service based the capability and localization information
- * provided by the client.
+ * Expected to the template. This may actually be changed by the
+ * TL service based the capability and localization information
+ * provided by the client.
* @param templateType
- * Type off template we are interested in.
+ * Type off template we are interested in.
* @return Template object containng the pertinent information required to
- * inlcude the request template path in the current response
+ * inlcude the request template path in the current response
* @throws TemplateLocatorException
- * if the <code>path</code> does not exist.
+ * if the <code>path</code> does not exist.
*/
- public TemplateDescriptor getTemplate( String path, String templateType ) throws TemplateLocatorException
+ public TemplateDescriptor getTemplate(String path, String templateType) throws TemplateLocatorException
{
checkState();
return getTemplate(path, templateType, templateLocator, templateLocatorDescriptor);
}
- public Configuration getTypeConfiguration( String type, String name, String location ) throws Exception
+ public Configuration getTypeConfiguration(String type, String name, String location) throws Exception
{
ArgUtil.assertNotNull(String.class, type, this, "getTypeConfiguration(String type, String name)");
ArgUtil.assertNotNull(String.class, name, this, "getTypeConfiguration(String type, String name)");
@@ -398,13 +412,13 @@
}
}
- public TemplateDescriptor getDecoration( String path, String templateType ) throws TemplateLocatorException
+ public TemplateDescriptor getDecoration(String path, String templateType) throws TemplateLocatorException
{
checkState();
return getTemplate(path, templateType, decorationLocator, decorationLocatorDescriptor);
}
- public String includeTemplate( String template, String templateType ) throws IOException
+ public String includeTemplate(String template, String templateType) throws IOException
{
checkState();
try
@@ -422,12 +436,12 @@
}
}
- public String includeDecoration( String template, String templateType ) throws IOException
+ public String includeDecoration(String template, String templateType) throws IOException
{
checkState();
try
{
- return getDecoration(template, templateType).getAppRelativePath();
+ return getDecoration(template, templateType).getAppRelativePath();
}
catch (Exception e)
{
@@ -439,31 +453,29 @@
}
}
-
-
/**
* <p>
* Decorate and include fragment content.
* </p>
*
* @param f
- * Fragment to include and decorate
+ * Fragment to include and decorate
* @throws Exception
* @return String path to the decorator.
*/
- public String decorateAndInclude( ContentFragment f ) throws Exception
+ public String decorateAndInclude(ContentFragment f) throws Exception
{
// makes sure that any previous content has been written to
// preserve natural HTML rendering order
- setCurrentFragment(f);
- setCurrentLayout();
+ setCurrentFragment(f);
+ setCurrentLayout();
// include decorated layout or portlet fragment
try
{
String fragmentType = f.getType();
- return decorateAndIncludePortlet(f);
+ return decorateAndIncludePortlet(f);
}
catch (Exception e)
{
@@ -472,7 +484,7 @@
}
}
-
+
/**
* <p>
* The decorator template itself is responsible for including the content of
@@ -489,21 +501,21 @@
*
* <pre>
* <code>
- *
- * <%
- * JetspeedPowerTool jetspeed = new JetspeedPowerTool(renderRequest, renderResponse, portletConfig);
- * jetspeed.include(jetspeed.getCurrentFragment());
- * %>
*
+ * <%
+ * JetspeedPowerTool jetspeed = new JetspeedPowerTool(renderRequest, renderResponse, portletConfig);
+ * jetspeed.include(jetspeed.getCurrentFragment());
+ * %>
+ *
* </code>
* </pre>
*
*
* @param f
- * Portlet fragment to "decorate"
+ * Portlet fragment to "decorate"
* @throws Exception
*/
- protected String decorateAndIncludePortlet( ContentFragment f ) throws Exception
+ protected String decorateAndIncludePortlet(ContentFragment f) throws Exception
{
// make sure that any previous content has been written to
// preserve natural HTML rendering order
@@ -544,21 +556,19 @@
template = getDecoration(parent + "/" + DECORATOR_TYPE + ext, fragmentType);
}
}
-
- setAttribute(DECORATOR_ID_ATTR, decoConf.getString("id"));
+
+ setAttribute(DECORATOR_ID_ATTR, decoConf.getString("id"));
setAttribute(ACTION_IMAGE_EXTENSION_ATTR, decoConf.getString("action.image.extension", ".gif"));
- return template.getAppRelativePath();
- }
-
-
+ return template.getAppRelativePath();
+ }
/**
*
*
* @throws java.lang.IllegalStateException
- * if the <code>PortletConfig</code>,
- * <code>RenderRequest</code> or <code>RenderReponse</code>
- * is null.
+ * if the <code>PortletConfig</code>,
+ * <code>RenderRequest</code> or <code>RenderReponse</code>
+ * is null.
*/
protected void checkState()
{
@@ -570,8 +580,8 @@
}
}
- protected TemplateDescriptor getTemplate( String path, String templateType, TemplateLocator locator,
- LocatorDescriptor descriptor ) throws TemplateLocatorException
+ protected TemplateDescriptor getTemplate(String path, String templateType, TemplateLocator locator,
+ LocatorDescriptor descriptor) throws TemplateLocatorException
{
checkState();
if (templateType == null)
@@ -586,10 +596,10 @@
TemplateDescriptor template = locator.locateTemplate(descriptor);
// Check for defaults above the currently specified root
- if(template == null)
+ if (template == null)
{
Path pathObject = new Path(path);
- if(pathObject.length() > 1)
+ if (pathObject.length() > 1)
{
template = getTemplate(pathObject.getSegment(1).toString(), templateType, locator, descriptor);
}
@@ -612,7 +622,7 @@
* @param e
* @param msg
*/
- protected void handleError( Exception e, String msg, ContentFragment fragment )
+ protected void handleError(Exception e, String msg, ContentFragment fragment)
{
log.error(msg, e);
@@ -631,7 +641,7 @@
* page) has its own collection of actionAccess flags associated with it.
*
* @return A list of actions available to the current window, filtered by
- * securty access and current state.
+ * securty access and current state.
* @throws Exception
*/
public List getDecoratorActions()
@@ -644,7 +654,7 @@
* page has its own collection of actionAccess flags associated with it.
*
* @return A list of actions available to the current window, filtered by
- * securty access and current state.
+ * securty access and current state.
* @throws Exception
*/
public List getPageDecoratorActions() throws Exception
@@ -658,21 +668,21 @@
{
String key = getPage().getId();
boolean anonymous = !getLoggedOn();
- PageActionAccess pageActionAccess = null;
-
+ PageActionAccess pageActionAccess = null;
+
synchronized (getRequestContext().getRequest().getSession())
{
Map sessionActions = (Map) getRequestContext().getSessionAttribute(POWER_TOOL_SESSION_ACTIONS);
- if ( sessionActions == null )
+ if (sessionActions == null)
{
sessionActions = new HashMap();
getRequestContext().setSessionAttribute(POWER_TOOL_SESSION_ACTIONS, sessionActions);
}
else
{
- pageActionAccess = (PageActionAccess)sessionActions.get(key);
+ pageActionAccess = (PageActionAccess) sessionActions.get(key);
}
- if ( pageActionAccess == null )
+ if (pageActionAccess == null)
{
pageActionAccess = new PageActionAccess(anonymous, getPage());
sessionActions.put(key, pageActionAccess);
@@ -682,7 +692,7 @@
pageActionAccess.checkReset(getLoggedOn(), getPage());
}
}
-
+
PortletDefinitionComposite portlet = (PortletDefinitionComposite) getCurrentPortletEntity()
.getPortletDefinition();
if (null == portlet)
@@ -694,7 +704,7 @@
PortletMode mode = getPortletMode();
WindowState state = getWindowState();
-
+
ContentTypeSet content = portlet.getContentTypeSet();
ContentFragment fragment = getCurrentFragment();
String fragmentId = fragment.getId();
@@ -702,31 +712,35 @@
PortletWindow window = windowAccess.getPortletWindow(fragment);
String resourceBase = getPageBasePath();
- if ( !layout || pageActionAccess.isEditAllowed() )
+ if (!layout || pageActionAccess.isEditAllowed())
{
if (mode.equals(PortletMode.VIEW))
{
- if (content.supportsPortletMode(PortletMode.EDIT) && pageActionAccess.isEditAllowed() &&
- pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.EDIT))
+ if (content.supportsPortletMode(PortletMode.EDIT) && pageActionAccess.isEditAllowed()
+ && pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.EDIT))
{
- actions.add(createPortletModeAction(window, JetspeedActions.EDIT, PortletMode.EDIT, resourceBase));
+ actions.add(createPortletModeAction(window, JetspeedActions.EDIT, PortletMode.EDIT,
+ resourceBase));
}
- if (content.supportsPortletMode(PortletMode.HELP) &&
- pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.HELP))
+ if (content.supportsPortletMode(PortletMode.HELP)
+ && pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.HELP))
{
- actions.add(createPortletModeAction(window, JetspeedActions.HELP, PortletMode.HELP, resourceBase));
+ actions.add(createPortletModeAction(window, JetspeedActions.HELP, PortletMode.HELP,
+ resourceBase));
}
}
else if (mode.equals(PortletMode.EDIT))
{
if (pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.VIEW))
{
- actions.add(createPortletModeAction(window, JetspeedActions.VIEW, PortletMode.VIEW, resourceBase));
+ actions.add(createPortletModeAction(window, JetspeedActions.VIEW, PortletMode.VIEW,
+ resourceBase));
}
- if (content.supportsPortletMode(PortletMode.HELP) &&
- pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.HELP))
+ if (content.supportsPortletMode(PortletMode.HELP)
+ && pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.HELP))
{
- actions.add(createPortletModeAction(window, JetspeedActions.HELP, PortletMode.HELP, resourceBase));
+ actions.add(createPortletModeAction(window, JetspeedActions.HELP, PortletMode.HELP,
+ resourceBase));
}
}
else
@@ -734,55 +748,61 @@
{
if (pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.VIEW))
{
- actions.add(createPortletModeAction(window, JetspeedActions.VIEW, PortletMode.VIEW, resourceBase));
+ actions.add(createPortletModeAction(window, JetspeedActions.VIEW, PortletMode.VIEW,
+ resourceBase));
}
- if (content.supportsPortletMode(PortletMode.EDIT) && pageActionAccess.isEditAllowed() &&
- pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.EDIT))
+ if (content.supportsPortletMode(PortletMode.EDIT) && pageActionAccess.isEditAllowed()
+ && pageActionAccess.checkPortletMode(fragmentId, portletName, PortletMode.EDIT))
{
- actions.add(createPortletModeAction(window, JetspeedActions.EDIT, PortletMode.EDIT, resourceBase));
+ actions.add(createPortletModeAction(window, JetspeedActions.EDIT, PortletMode.EDIT,
+ resourceBase));
}
}
}
-
- if ( !layout )
+ if (!layout)
{
if (state.equals(WindowState.NORMAL))
{
- if ( pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MINIMIZED))
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MINIMIZED))
{
- actions.add(createWindowStateAction(window, JetspeedActions.MINIMIZE, WindowState.MINIMIZED, resourceBase));
+ actions.add(createWindowStateAction(window, JetspeedActions.MINIMIZE, WindowState.MINIMIZED,
+ resourceBase));
}
- if ( pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MAXIMIZED))
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MAXIMIZED))
{
- actions.add(createWindowStateAction(window, JetspeedActions.MAXIMIZE, WindowState.MAXIMIZED, resourceBase));
+ actions.add(createWindowStateAction(window, JetspeedActions.MAXIMIZE, WindowState.MAXIMIZED,
+ resourceBase));
}
}
else if (state.equals(WindowState.MAXIMIZED))
{
- if ( pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MINIMIZED))
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MINIMIZED))
{
- actions.add(createWindowStateAction(window, JetspeedActions.MINIMIZE, WindowState.MINIMIZED, resourceBase));
+ actions.add(createWindowStateAction(window, JetspeedActions.MINIMIZE, WindowState.MINIMIZED,
+ resourceBase));
}
- if ( pageActionAccess.checkWindowState(fragmentId, portletName, JetspeedActions.RESTORED))
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, JetspeedActions.RESTORED))
{
- actions.add(createWindowStateAction(window, JetspeedActions.RESTORE, WindowState.NORMAL, resourceBase));
+ actions.add(createWindowStateAction(window, JetspeedActions.RESTORE, WindowState.NORMAL,
+ resourceBase));
}
}
else
// minimized
{
- if ( pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MAXIMIZED))
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, WindowState.MAXIMIZED))
{
- actions.add(createWindowStateAction(window, JetspeedActions.MAXIMIZE, WindowState.MAXIMIZED, resourceBase));
+ actions.add(createWindowStateAction(window, JetspeedActions.MAXIMIZE, WindowState.MAXIMIZED,
+ resourceBase));
}
- if ( pageActionAccess.checkWindowState(fragmentId, portletName, JetspeedActions.RESTORED))
+ if (pageActionAccess.checkWindowState(fragmentId, portletName, JetspeedActions.RESTORED))
{
- actions.add(createWindowStateAction(window, JetspeedActions.RESTORE, WindowState.NORMAL, resourceBase));
+ actions.add(createWindowStateAction(window, JetspeedActions.RESTORE, WindowState.NORMAL,
+ resourceBase));
}
}
}
-
return actions;
}
@@ -793,26 +813,28 @@
}
}
- protected DecoratorAction createDecoratorAction( String resourceBase, String actionName )
+ protected DecoratorAction createDecoratorAction(String resourceBase, String actionName)
{
String imageExt = (String) renderRequest.getAttribute(ACTION_IMAGE_EXTENSION_ATTR);
- if(imageExt == null)
+ if (imageExt == null)
{
imageExt = ".gif";
}
- String link = renderResponse.encodeURL(resourceBase+"/content/images/"+actionName+".gif");
- return new DecoratorAction(actionName, actionName, link);
+ String link = renderResponse.encodeURL(resourceBase + "/content/images/" + actionName + ".gif");
+ return new DecoratorAction(actionName, actionName, link);
}
-
+
/**
* Creates a Decorator PortletMode Action to be added to the list of actions
* decorating a portlet.
*/
- protected DecoratorAction createPortletModeAction( PortletWindow window, String actionName, PortletMode mode, String resourceBase )
+ protected DecoratorAction createPortletModeAction(PortletWindow window, String actionName, PortletMode mode,
+ String resourceBase)
{
DecoratorAction action = createDecoratorAction(resourceBase, actionName);
- PortalURL portalURL = getRequestContext().getPortalURL();
- action.setAction(renderResponse.encodeURL(portalURL.createPortletURL(window, mode, null, portalURL.isSecure()).toString()));
+ PortalURL portalURL = getRequestContext().getPortalURL();
+ action.setAction(renderResponse.encodeURL(portalURL.createPortletURL(window, mode, null, portalURL.isSecure())
+ .toString()));
return action;
}
@@ -820,11 +842,13 @@
* Creates a Decorator WindowState Action to be added to the list of actions
* decorating a portlet.
*/
- protected DecoratorAction createWindowStateAction( PortletWindow window, String actionName, WindowState state, String resourceBase )
+ protected DecoratorAction createWindowStateAction(PortletWindow window, String actionName, WindowState state,
+ String resourceBase)
{
DecoratorAction action = createDecoratorAction(resourceBase, actionName);
- PortalURL portalURL = getRequestContext().getPortalURL();
- action.setAction(renderResponse.encodeURL(portalURL.createPortletURL(window, null, state, portalURL.isSecure()).toString()));
+ PortalURL portalURL = getRequestContext().getPortalURL();
+ action.setAction(renderResponse.encodeURL(portalURL.createPortletURL(window, null, state, portalURL.isSecure())
+ .toString()));
return action;
}
@@ -838,7 +862,7 @@
* @param entity
* @return
*/
- public String getTitle( PortletEntity entity, ContentFragment f )
+ public String getTitle(PortletEntity entity, ContentFragment f)
{
String title = null;
@@ -847,9 +871,18 @@
title = f.getTitle();
}
- if(title == null)
+ if (title == null)
{
- title = getTitle(entity);
+ try
+ {
+
+ return titleService.getDynamicTitle(windowAccess.getPortletWindow(f), getRequestContext().getRequest());
+ }
+ catch (Exception e)
+ {
+ log.error("Unable to reteive portlet title: " + e.getMessage(), e);
+ return "Title Error: " + e.getMessage();
+ }
}
return title;
@@ -865,35 +898,36 @@
* @param entity
* @return
*/
- public String getTitle( PortletEntity entity )
- {
+ public String getTitle(PortletEntity entity)
+ {
try
{
- return titleService.getDynamicTitle(windowAccess.getPortletWindow(getCurrentFragment()), getRequestContext().getRequest());
+ return titleService.getDynamicTitle(windowAccess.getPortletWindow(getCurrentFragment()),
+ getRequestContext().getRequest());
}
catch (Exception e)
{
- log.error("Unable to reteive portlet title: "+e.getMessage(), e);
- return "Title Error: "+e.getMessage();
+ log.error("Unable to reteive portlet title: " + e.getMessage(), e);
+ return "Title Error: " + e.getMessage();
}
-
+
}
- public Object getComponent( String name )
+ public Object getComponent(String name)
{
return Jetspeed.getComponentManager().getComponent(name);
}
- public String getAbsoluteUrl( String relativePath )
+ public String getAbsoluteUrl(String relativePath)
{
// only rewrite a non-absolute url
- if ( relativePath != null && relativePath.indexOf("://") == -1)
+ if (relativePath != null && relativePath.indexOf("://") == -1)
{
- HttpServletRequest request = getRequestContext().getRequest();
- StringBuffer path = new StringBuffer();
- return renderResponse.encodeURL(path.append(request.getScheme()).append("://").append(request.getServerName()).append(":").append(
- request.getServerPort()).append(request.getContextPath()).append(request.getServletPath()).append(
- relativePath).toString());
+ HttpServletRequest request = getRequestContext().getRequest();
+ StringBuffer path = new StringBuffer();
+ return renderResponse.encodeURL(path.append(request.getScheme()).append("://").append(
+ request.getServerName()).append(":").append(request.getServerPort()).append(
+ request.getContextPath()).append(request.getServletPath()).append(relativePath).toString());
}
else
{
@@ -905,45 +939,46 @@
{
return requestContext.getSubject();
}
-
+
public boolean getLoggedOn()
{
Principal principal = requestContext.getRequest().getUserPrincipal();
return (principal != null);
}
-
+
public String getBasePath()
{
return getRequestContext().getPortalURL().getBasePath();
}
-
+
public String getPageBasePath()
{
return getRequestContext().getPortalURL().getPageBasePath();
}
-
public void setVelocityContext(Context velocityContext)
{
this.velocityContext = velocityContext;
}
-
+
/**
- * Sets an attribute for use within your layout and decoration templates. The value is always stored
- * within the current <code>javax.portlet.Renderrequest</code> and is also stored within the current
- * <code>org.apache.velocity.Context</code> if it is available.
- *
- * @param name to store the attribute under.
- * @param obj object to set.
+ * Sets an attribute for use within your layout and decoration templates.
+ * The value is always stored within the current
+ * <code>javax.portlet.Renderrequest</code> and is also stored within the
+ * current <code>org.apache.velocity.Context</code> if it is available.
+ *
+ * @param name
+ * to store the attribute under.
+ * @param obj
+ * object to set.
*/
protected void setAttribute(String name, Object object)
{
renderRequest.setAttribute(name, object);
- if(velocityContext != null)
+ if (velocityContext != null)
{
velocityContext.put(name, object);
}
}
-
-
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org