org.apache.jetspeed.velocity
Class JetspeedPowerToolImpl

java.lang.Object
  extended by org.apache.jetspeed.velocity.JetspeedPowerToolImpl
All Implemented Interfaces:
org.apache.jetspeed.layout.JetspeedPowerTool, JetspeedVelocityPowerTool

public class JetspeedPowerToolImpl
extends Object
implements JetspeedVelocityPowerTool

JetspeedPowerTool

The JetspeedPowerTool is meant to be used by template designers to build templates for internal Jetspeed portlet applications. It hides the implementation details of the more common template actions so that future changes to said implementation have minimal effect on template.

Where applicable, methods have been marked with a BEST PRATICES meaning that this method should be used instead the synonymous code listed within the method docuementation.

Version:
$Id: JetspeedPowerToolImpl.java 589933 2007-10-30 01:51:50Z woonsan $
Author:
Scott T. Weaver

Field Summary
private static String ACTION_IMAGE_EXTENSION_ATTR
           
private  org.apache.jetspeed.container.url.BasePortalURL baseUrlAccess
           
protected  org.apache.jetspeed.capabilities.CapabilityMap capabilityMap
           
protected static String COLUMN_SIZES
           
protected static String COLUMNS_ATTR
           
protected  org.apache.jetspeed.locator.TemplateLocator decorationLocator
           
protected  org.apache.jetspeed.locator.LocatorDescriptor decorationLocatorDescriptor
           
private static String DECORATOR_ID_ATTR
           
protected  org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent entityAccess
           
protected  Locale locale
           
protected static org.apache.commons.logging.Log log
           
protected static String PORTLET_CONFIG_ATTR
           
protected  javax.portlet.PortletConfig portletConfig
           
protected static String RENDER_REQUEST_ATTR
           
protected static String RENDER_RESPONSE_ATTR
           
private  org.apache.jetspeed.aggregator.PortletRenderer renderer
           
protected  javax.portlet.RenderRequest renderRequest
           
protected  javax.portlet.RenderResponse renderResponse
           
protected  org.apache.jetspeed.request.RequestContext requestContext
           
protected  org.apache.jetspeed.locator.TemplateLocator templateLocator
           
protected  org.apache.jetspeed.locator.LocatorDescriptor templateLocatorDescriptor
           
protected  Writer templateWriter
           
private  DynamicTitleService titleService
           
protected  org.apache.velocity.context.Context velocityContext
           
protected  org.apache.jetspeed.container.window.PortletWindowAccessor windowAccess
           
 
Fields inherited from interface org.apache.jetspeed.layout.JetspeedPowerTool
DECORATOR_TYPE, FRAGMENT_ATTR, FRAGMENT_PROCESSING_ERROR_PREFIX, GENERIC_TEMPLATE_TYPE, HIDDEN, LAYOUT_ATTR, LAYOUT_TEMPLATE_TYPE
 
Constructor Summary
JetspeedPowerToolImpl(org.apache.jetspeed.request.RequestContext requestContext, DynamicTitleService titleService, org.apache.jetspeed.aggregator.PortletRenderer renderer)
           
 
Method Summary
protected  void checkState()
           
 String decorateAndInclude(org.apache.jetspeed.om.page.ContentFragment f)
           Decorate and include fragment content.
protected  String decorateAndIncludePortlet(org.apache.jetspeed.om.page.ContentFragment f)
           The decorator template itself is responsible for including the content of the target Fragment which is easily acheived like so:
in Velocity:
 String getAbsoluteUrl(String relativePath)
           
 String getBasePath()
           
 List[] getColumns()
           
 List getColumnSizes()
           
 Object getComponent(String name)
           
 org.apache.jetspeed.om.page.ContentFragment getCurrentFragment()
           
 org.apache.jetspeed.om.page.ContentFragment getCurrentLayout()
           
 org.apache.pluto.om.entity.PortletEntity getCurrentPortletEntity()
           
 org.apache.jetspeed.locator.TemplateDescriptor getDecoration(String path, String templateType)
           
 List getDecoratorActions()
          Deprecated.  
 boolean getLoggedOn()
           
 javax.portlet.PortletMode getMappedPortletMode()
          Gets the internal (portal) portlet mode for a current portlet window (fragment)
 javax.portlet.WindowState getMappedWindowState()
          Gets the internal (portal) window state for the current portlet window (fragment)
 org.apache.jetspeed.om.page.Page getPage()
           
 String getPageBasePath()
           
 List getPageDecoratorActions()
          Deprecated.  
 org.apache.pluto.om.entity.PortletEntity getPortletEntity(org.apache.jetspeed.om.page.ContentFragment f)
           
 javax.portlet.PortletMode getPortletMode()
          Gets the portlet mode for a current portlet window (fragment)
protected  org.apache.jetspeed.request.RequestContext getRequestContext()
           getRequestContext
 Subject getSubject()
           
 org.apache.jetspeed.locator.TemplateDescriptor getTemplate(String path, String templateType)
          Retreives a template using Jetspeed's
protected  org.apache.jetspeed.locator.TemplateDescriptor getTemplate(String path, String templateType, org.apache.jetspeed.locator.TemplateLocator locator, org.apache.jetspeed.locator.LocatorDescriptor descriptor)
           
 String getTitle(org.apache.pluto.om.entity.PortletEntity entity)
           getTitle
 String getTitle(org.apache.pluto.om.entity.PortletEntity entity, org.apache.jetspeed.om.page.ContentFragment f)
           getTitle
 org.apache.commons.configuration.Configuration getTypeConfiguration(String type, String name, String location)
           
 javax.portlet.WindowState getWindowState()
          Gets the window state for the current portlet window (fragment)
protected  void handleError(Exception e, String msg, org.apache.jetspeed.om.page.ContentFragment fragment)
           handleError
 String includeDecoration(String template, String templateType)
           
 String includeTemplate(String template, String templateType)
           
 boolean isHidden(org.apache.jetspeed.om.page.ContentFragment f)
          Checks the the visibilty of this fragment with respect to the current RenderReqeust.
 String renderPortletEntity(String entityId, String portletId)
           
protected  void setAttribute(String name, Object object)
          Sets an attribute for use within your layout and decoration templates.
 void setCurrentFragment(org.apache.jetspeed.om.page.ContentFragment f)
           
 void setCurrentLayout()
           
 void setVelocityContext(org.apache.velocity.context.Context velocityContext)
          Sets the Velocity Context object for this powertool instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DECORATOR_ID_ATTR

private static final String DECORATOR_ID_ATTR
See Also:
Constant Field Values

ACTION_IMAGE_EXTENSION_ATTR

private static final String ACTION_IMAGE_EXTENSION_ATTR
See Also:
Constant Field Values

PORTLET_CONFIG_ATTR

protected static final String PORTLET_CONFIG_ATTR
See Also:
Constant Field Values

RENDER_RESPONSE_ATTR

protected static final String RENDER_RESPONSE_ATTR
See Also:
Constant Field Values

RENDER_REQUEST_ATTR

protected static final String RENDER_REQUEST_ATTR
See Also:
Constant Field Values

COLUMNS_ATTR

protected static final String COLUMNS_ATTR
See Also:
Constant Field Values

COLUMN_SIZES

protected static final String COLUMN_SIZES
See Also:
Constant Field Values

renderRequest

protected javax.portlet.RenderRequest renderRequest

renderResponse

protected javax.portlet.RenderResponse renderResponse

portletConfig

protected javax.portlet.PortletConfig portletConfig

templateWriter

protected Writer templateWriter

log

protected static final org.apache.commons.logging.Log log

capabilityMap

protected org.apache.jetspeed.capabilities.CapabilityMap capabilityMap

locale

protected Locale locale

templateLocatorDescriptor

protected org.apache.jetspeed.locator.LocatorDescriptor templateLocatorDescriptor

templateLocator

protected org.apache.jetspeed.locator.TemplateLocator templateLocator

entityAccess

protected org.apache.jetspeed.components.portletentity.PortletEntityAccessComponent entityAccess

decorationLocator

protected org.apache.jetspeed.locator.TemplateLocator decorationLocator

decorationLocatorDescriptor

protected org.apache.jetspeed.locator.LocatorDescriptor decorationLocatorDescriptor

windowAccess

protected org.apache.jetspeed.container.window.PortletWindowAccessor windowAccess

requestContext

protected org.apache.jetspeed.request.RequestContext requestContext

velocityContext

protected org.apache.velocity.context.Context velocityContext

titleService

private DynamicTitleService titleService

baseUrlAccess

private org.apache.jetspeed.container.url.BasePortalURL baseUrlAccess

renderer

private org.apache.jetspeed.aggregator.PortletRenderer renderer
Constructor Detail

JetspeedPowerToolImpl

public JetspeedPowerToolImpl(org.apache.jetspeed.request.RequestContext requestContext,
                             DynamicTitleService titleService,
                             org.apache.jetspeed.aggregator.PortletRenderer renderer)
                      throws Exception
Throws:
Exception
Method Detail

getRequestContext

protected final org.apache.jetspeed.request.RequestContext getRequestContext()

getRequestContext

Returns:

getWindowState

public javax.portlet.WindowState getWindowState()
                                         throws Exception
Gets the window state for the current portlet window (fragment)

Specified by:
getWindowState in interface org.apache.jetspeed.layout.JetspeedPowerTool
Returns:
The window state for the current window
Throws:
Exception

getMappedWindowState

public javax.portlet.WindowState getMappedWindowState()
                                               throws Exception
Gets the internal (portal) window state for the current portlet window (fragment)

Specified by:
getMappedWindowState in interface org.apache.jetspeed.layout.JetspeedPowerTool
Returns:
The window state for the current window
Throws:
Exception

getPortletMode

public javax.portlet.PortletMode getPortletMode()
                                         throws Exception
Gets the portlet mode for a current portlet window (fragment)

Specified by:
getPortletMode in interface org.apache.jetspeed.layout.JetspeedPowerTool
Returns:
The portlet mode of the current window
Throws:
Exception

getMappedPortletMode

public javax.portlet.PortletMode getMappedPortletMode()
                                               throws Exception
Gets the internal (portal) portlet mode for a current portlet window (fragment)

Specified by:
getMappedPortletMode in interface org.apache.jetspeed.layout.JetspeedPowerTool
Returns:
The portlet mode of the current window
Throws:
Exception

getCurrentFragment

public org.apache.jetspeed.om.page.ContentFragment getCurrentFragment()
Specified by:
getCurrentFragment in interface org.apache.jetspeed.layout.JetspeedPowerTool
Returns:

setCurrentFragment

public void setCurrentFragment(org.apache.jetspeed.om.page.ContentFragment f)
Specified by:
setCurrentFragment in interface org.apache.jetspeed.layout.JetspeedPowerTool
Parameters:
f -

setCurrentLayout

public void setCurrentLayout()
Specified by:
setCurrentLayout in interface org.apache.jetspeed.layout.JetspeedPowerTool

getCurrentLayout

public org.apache.jetspeed.om.page.ContentFragment getCurrentLayout()
Specified by:
getCurrentLayout in interface org.apache.jetspeed.layout.JetspeedPowerTool
Returns:

getPage

public org.apache.jetspeed.om.page.Page getPage()
Specified by:
getPage in interface org.apache.jetspeed.layout.JetspeedPowerTool
Returns:

getColumns

public List[] getColumns()
Specified by:
getColumns in interface org.apache.jetspeed.layout.JetspeedPowerTool
Returns:

getColumnSizes

public List getColumnSizes()
Specified by:
getColumnSizes in interface org.apache.jetspeed.layout.JetspeedPowerTool

getCurrentPortletEntity

public org.apache.pluto.om.entity.PortletEntity getCurrentPortletEntity()
                                                                 throws Exception
Specified by:
getCurrentPortletEntity in interface org.apache.jetspeed.layout.JetspeedPowerTool
Returns:
Throws:
Exception

getPortletEntity

public org.apache.pluto.om.entity.PortletEntity getPortletEntity(org.apache.jetspeed.om.page.ContentFragment f)
                                                          throws Exception
Specified by:
getPortletEntity in interface org.apache.jetspeed.layout.JetspeedPowerTool
Parameters:
f - Fragment whose PortletEntity we want to retreive.
Returns:
The PortletEntity represented by the current fragment.
Throws:
Exception

isHidden

public boolean isHidden(org.apache.jetspeed.om.page.ContentFragment f)
Checks the the visibilty of this fragment with respect to the current RenderReqeust.

Specified by:
isHidden in interface org.apache.jetspeed.layout.JetspeedPowerTool
Parameters:
f - Fragment
Returns:
whether or not the Fragment in question should be considered visible during rendering.

getTemplate

public org.apache.jetspeed.locator.TemplateDescriptor getTemplate(String path,
                                                                  String templateType)
                                                           throws org.apache.jetspeed.locator.TemplateLocatorException
Retreives a template using Jetspeed's

Specified by:
getTemplate in interface org.apache.jetspeed.layout.JetspeedPowerTool
Parameters:
path - Expected to the template. This may actually be changed by the TL service based the capability and localization information provided by the client.
templateType - Type off template we are interested in.
Returns:
Template object containng the pertinent information required to inlcude the request template path in the current response
Throws:
org.apache.jetspeed.locator.TemplateLocatorException - if the path does not exist.
See Also:
TemplateLocator

getTypeConfiguration

public org.apache.commons.configuration.Configuration getTypeConfiguration(String type,
                                                                           String name,
                                                                           String location)
                                                                    throws Exception
Throws:
Exception

getDecoration

public org.apache.jetspeed.locator.TemplateDescriptor getDecoration(String path,
                                                                    String templateType)
                                                             throws org.apache.jetspeed.locator.TemplateLocatorException
Specified by:
getDecoration in interface org.apache.jetspeed.layout.JetspeedPowerTool
Throws:
org.apache.jetspeed.locator.TemplateLocatorException

includeTemplate

public String includeTemplate(String template,
                              String templateType)
                       throws IOException
Specified by:
includeTemplate in interface org.apache.jetspeed.layout.JetspeedPowerTool
Throws:
IOException

includeDecoration

public String includeDecoration(String template,
                                String templateType)
                         throws IOException
Specified by:
includeDecoration in interface org.apache.jetspeed.layout.JetspeedPowerTool
Throws:
IOException

decorateAndInclude

public String decorateAndInclude(org.apache.jetspeed.om.page.ContentFragment f)
                          throws Exception

Decorate and include fragment content.

Specified by:
decorateAndInclude in interface org.apache.jetspeed.layout.JetspeedPowerTool
Parameters:
f - Fragment to include and decorate
Returns:
String path to the decorator.
Throws:
Exception

decorateAndIncludePortlet

protected String decorateAndIncludePortlet(org.apache.jetspeed.om.page.ContentFragment f)
                                    throws Exception

The decorator template itself is responsible for including the content of the target Fragment which is easily acheived like so:
in Velocity:

   
 $jetspeed.include($jetspeed.currentFragment)
 
 
In JSP:
   
  
              <% 
               JetspeedPowerTool jetspeed = new JetspeedPowerTool(renderRequest, renderResponse, portletConfig);
               jetspeed.include(jetspeed.getCurrentFragment());
              %>
   
 
 

Parameters:
f - Portlet fragment to "decorate"
Throws:
Exception

checkState

protected void checkState()
Throws:
IllegalStateException - if the PortletConfig, RenderRequest or RenderReponse is null.

getTemplate

protected org.apache.jetspeed.locator.TemplateDescriptor getTemplate(String path,
                                                                     String templateType,
                                                                     org.apache.jetspeed.locator.TemplateLocator locator,
                                                                     org.apache.jetspeed.locator.LocatorDescriptor descriptor)
                                                              throws org.apache.jetspeed.locator.TemplateLocatorException
Throws:
org.apache.jetspeed.locator.TemplateLocatorException

handleError

protected void handleError(Exception e,
                           String msg,
                           org.apache.jetspeed.om.page.ContentFragment fragment)

handleError

Parameters:
e -
msg -

getDecoratorActions

public List getDecoratorActions()
Deprecated. 

Gets the list of decorator actions for a window. Each window (on each page) has its own collection of actionAccess flags associated with it.

Specified by:
getDecoratorActions in interface org.apache.jetspeed.layout.JetspeedPowerTool
Returns:
A list of actions available to the current window, filtered by securty access and current state.
Throws:
Exception

getPageDecoratorActions

public List getPageDecoratorActions()
                             throws Exception
Deprecated. 

Gets the list of decorator actions for a page. Each layout fragment on a page has its own collection of actionAccess flags associated with it.

Specified by:
getPageDecoratorActions in interface org.apache.jetspeed.layout.JetspeedPowerTool
Returns:
A list of actions available to the current window, filtered by securty access and current state.
Throws:
Exception

getTitle

public String getTitle(org.apache.pluto.om.entity.PortletEntity entity,
                       org.apache.jetspeed.om.page.ContentFragment f)

getTitle

Returns the appropriate for the title based on locale prferences

Specified by:
getTitle in interface org.apache.jetspeed.layout.JetspeedPowerTool
Parameters:
entity -
Returns:

getTitle

public String getTitle(org.apache.pluto.om.entity.PortletEntity entity)

getTitle

Returns the appropriate for the title based on locale prferences

Specified by:
getTitle in interface org.apache.jetspeed.layout.JetspeedPowerTool
Parameters:
entity -
Returns:

getComponent

public Object getComponent(String name)
Specified by:
getComponent in interface org.apache.jetspeed.layout.JetspeedPowerTool

getAbsoluteUrl

public String getAbsoluteUrl(String relativePath)
Specified by:
getAbsoluteUrl in interface org.apache.jetspeed.layout.JetspeedPowerTool

getSubject

public Subject getSubject()
Specified by:
getSubject in interface org.apache.jetspeed.layout.JetspeedPowerTool

getLoggedOn

public boolean getLoggedOn()
Specified by:
getLoggedOn in interface org.apache.jetspeed.layout.JetspeedPowerTool

getBasePath

public String getBasePath()
Specified by:
getBasePath in interface org.apache.jetspeed.layout.JetspeedPowerTool

getPageBasePath

public String getPageBasePath()
Specified by:
getPageBasePath in interface org.apache.jetspeed.layout.JetspeedPowerTool

setVelocityContext

public void setVelocityContext(org.apache.velocity.context.Context velocityContext)
Description copied from interface: JetspeedVelocityPowerTool
Sets the Velocity Context object for this powertool instance. This is only required if using Velocity based decortaions and layouts.

Specified by:
setVelocityContext in interface JetspeedVelocityPowerTool

setAttribute

protected void setAttribute(String name,
                            Object object)
Sets an attribute for use within your layout and decoration templates. The value is always stored within the current javax.portlet.Renderrequest and is also stored within the current org.apache.velocity.Context if it is available.

Parameters:
name - to store the attribute under.
obj - object to set.

renderPortletEntity

public String renderPortletEntity(String entityId,
                                  String portletId)
Specified by:
renderPortletEntity in interface org.apache.jetspeed.layout.JetspeedPowerTool


Copyright © 1999-2007 Apache Software Foundation. All Rights Reserved.