org.tigris.scarab.util
Class ScarabLink

java.lang.Object
  extended byorg.apache.turbine.DynamicURI
      extended byorg.apache.turbine.tool.TemplateLink
          extended byorg.tigris.scarab.util.ScarabLink
All Implemented Interfaces:
org.apache.turbine.services.pull.ApplicationTool, org.apache.fulcrum.pool.InitableRecyclable, org.apache.fulcrum.pool.Recyclable, SkipFiltering
Direct Known Subclasses:
ModuleSwitchingLink

public class ScarabLink
extends org.apache.turbine.tool.TemplateLink
implements org.apache.fulcrum.pool.InitableRecyclable, SkipFiltering

This class adds a ModuleManager.CURRENT_PROJECT to every link. This class is added into the context to replace the $link that Turbine adds.

Version:
$Id: ScarabLink.java 9476 2005-03-16 22:56:11Z dabbous $
Author:
Jon S. Stevens, John McNally, Maarten Coene

Field Summary
 
Fields inherited from class org.apache.turbine.tool.TemplateLink
TEMPLATE_KEY
 
Fields inherited from class org.apache.turbine.DynamicURI
ANCHOR_STATIC_PART_LENGTH, HTTP, HTTPS, PATH_INFO, pathInfo, QUERY_DATA, queryData, redirect, res
 
Constructor Summary
ScarabLink()
          Constructor.
 
Method Summary
 org.apache.turbine.DynamicURI addPathInfo(java.lang.String name, boolean value)
          Adds a name=value pair to the path_info string.
 ScarabLink addPathInfo(java.lang.String key, org.apache.fulcrum.parser.ParameterParser pp)
           
 ScarabLink addPathInfo(org.apache.fulcrum.parser.ValueParser pp)
          Adds all the parameters in a ValueParser to the pathinfo except the action, screen, or template keys as defined by Turbine
 void dispose()
          Disposes the object by setting its disposed flag.
 java.lang.String getCurrentView()
          Returns the name of the template that is being being processed
 ScarabLink getIssueIdAbsoluteLink(Issue issue)
          Returns a short link for viewing a single issue that will not include session info and will be absolute.
 ScarabLink getIssueIdLink(Issue issue)
          Returns a short link for viewing a single issue
protected  org.apache.turbine.RunData getRunData()
          Give subclasses access to the RunData, so they do not have to reimplement the pooling code, just to get at it.
 java.lang.String getScriptName()
          Gets the server scriptName (/s).
 java.lang.String getServerName()
          Gets the server name.
 int getServerPort()
          Gets the server port.
 java.lang.String getServerScheme()
          Gets the server scheme (HTTP or HTTPS).
 void init(java.lang.Object data)
          This will initialise a TemplateLink object that was constructed with the default constructor (ApplicationTool method).
 boolean isAllowed()
          Check if the user has the permission to see the link.
 boolean isAllowed(java.lang.String t)
          Check if the user has the permission to see the template t.
 boolean isDisposed()
          Checks whether the object is disposed.
 ScarabLink omitModule()
          Causes the link to not include the module id.
 ScarabLink overrideSecurity()
          Shuts off permission checking.
 void recycle()
          Recycles the object by removing its disposed flag.
 void refresh()
           
 ScarabLink setAlternateText(java.lang.String alternateText)
          Text that will be returned from toString if the user did not have permission to see the link.
 ScarabLink setAttributeText(java.lang.String attributeText)
          Allows for setting attributes such as class on an anchor tag label.
 ScarabLink setLabel(java.lang.String label)
          Setting the label will cause the link tool to print out the the text for the anchor tag.
 org.apache.turbine.tool.TemplateLink setPage(java.lang.String t)
          Sets the template variable used by the Template Service.
protected  org.apache.turbine.tool.TemplateLink setPage(java.lang.String t, java.lang.String moduleid)
          Sets the template variable used by the Template Service.
 ScarabLink setPathInfo(java.lang.String key, java.lang.String value)
           
 java.lang.String toString()
          Prints out the url and resets the relative flag to true.
 
Methods inherited from class org.apache.turbine.tool.TemplateLink
getPage, getURI, setAbsolute, setEncodeURLOff
 
Methods inherited from class org.apache.turbine.DynamicURI
add, add, add, addPair, addPathInfo, addPathInfo, addPathInfo, addPathInfo, addPathInfo, addPathInfo, addQueryData, addQueryData, addQueryData, addQueryData, addQueryData, addQueryData, getA, hasPathInfo, hasQueryData, init, init, isEncodeUrl, isRelative, remove, removePairByName, removePathInfo, removePathInfo, removeQueryData, removeQueryData, renderPairs, renderPathInfo, renderPathInfo, renderQueryString, renderQueryString, setAction, setEncodeUrl, setRedirect, setRelative, setScreen, setSecure, setSecure, setTemplate, toString, toString, writeEncoded, writeFastEncoded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScarabLink

public ScarabLink()
Constructor.

Method Detail

init

public void init(java.lang.Object data)
This will initialise a TemplateLink object that was constructed with the default constructor (ApplicationTool method).

Specified by:
init in interface org.apache.fulcrum.pool.InitableRecyclable
Parameters:
data - assumed to be a RunData object

refresh

public void refresh()
Specified by:
refresh in interface org.apache.turbine.services.pull.ApplicationTool

getServerName

public java.lang.String getServerName()
Gets the server name.

Returns:
A String with the server name.

getServerPort

public int getServerPort()
Gets the server port.

Returns:
A String with the server port.

getServerScheme

public java.lang.String getServerScheme()
Gets the server scheme (HTTP or HTTPS).

Returns:
A String with the server scheme.

getScriptName

public java.lang.String getScriptName()
Gets the server scriptName (/s).

Returns:
A String with the server scriptName.

setPage

public org.apache.turbine.tool.TemplateLink setPage(java.lang.String t)
Sets the template variable used by the Template Service.

Parameters:
t - A String with the template name.
Returns:
A TemplateLink.

omitModule

public ScarabLink omitModule()
Causes the link to not include the module id. Useful for templates where a module is not required or desired.

Returns:
a ScarabLink value

overrideSecurity

public ScarabLink overrideSecurity()
Shuts off permission checking. Use case: a user saves a query with module scope, so an email is sent to the project owner to approve it. The email is sent from the user who does not have permission to use the Approval.vm template. But it is known that the recipient(s) does, because that is how they are chosen to receive the email. We probably need a different link tool for emails that is not request based. but for now use this sparingly and with forethought.

Returns:
this

setPage

protected org.apache.turbine.tool.TemplateLink setPage(java.lang.String t,
                                                       java.lang.String moduleid)
Sets the template variable used by the Template Service. The module id of the new selected module is given.

Parameters:
t - A String with the template name.
moduleid - The id of the new selected module.
Returns:
A TemplateLink.

getCurrentView

public java.lang.String getCurrentView()
Returns the name of the template that is being being processed


setPathInfo

public ScarabLink setPathInfo(java.lang.String key,
                              java.lang.String value)

addPathInfo

public ScarabLink addPathInfo(java.lang.String key,
                              org.apache.fulcrum.parser.ParameterParser pp)

addPathInfo

public org.apache.turbine.DynamicURI addPathInfo(java.lang.String name,
                                                 boolean value)
Adds a name=value pair to the path_info string. This method is missing in DynamicURI, but should be there.

Parameters:
name - A String with the name to add.
value - A double with the value to add.

addPathInfo

public ScarabLink addPathInfo(org.apache.fulcrum.parser.ValueParser pp)
Adds all the parameters in a ValueParser to the pathinfo except the action, screen, or template keys as defined by Turbine


setLabel

public ScarabLink setLabel(java.lang.String label)
Setting the label will cause the link tool to print out the the text for the anchor tag. This is useful in that if the link should not be active for security reasons it can be completely eliminated.

Parameters:
label - a String value
Returns:
a ScarabLink value

setAttributeText

public ScarabLink setAttributeText(java.lang.String attributeText)
Allows for setting attributes such as class on an anchor tag label. Note the complete anchor tag is only returned from toString, if the lable has been set so this setter will have no effect unless setLabel is called.

Parameters:
attributeText - a String value
Returns:
a ScarabLink value

setAlternateText

public ScarabLink setAlternateText(java.lang.String alternateText)
Text that will be returned from toString if the user did not have permission to see the link. The default is the empty string

Parameters:
alternateText - a String value
Returns:
a ScarabLink value

toString

public java.lang.String toString()
Prints out the url and resets the relative flag to true.

Specified by:
toString in interface SkipFiltering
Returns:
a String url

getIssueIdLink

public ScarabLink getIssueIdLink(Issue issue)
                          throws java.lang.Exception
Returns a short link for viewing a single issue

Parameters:
issue - an Issue value
Returns:
a String value
Throws:
java.lang.Exception - if an error occurs

getIssueIdAbsoluteLink

public ScarabLink getIssueIdAbsoluteLink(Issue issue)
                                  throws java.lang.Exception
Returns a short link for viewing a single issue that will not include session info and will be absolute. It is meant to be suitable for embedding in an email that points to the issue.

Parameters:
issue - an Issue value
Returns:
a String value
Throws:
java.lang.Exception - if an error occurs

isAllowed

public boolean isAllowed()
Check if the user has the permission to see the link. If the user has the permission(s), true is returned. if the user does NOT have the proper permissions, this method has the side effect of reseting the link, so that it is ready for use in building the next link.


isAllowed

public boolean isAllowed(java.lang.String t)
Check if the user has the permission to see the template t. If the user has the permission(s), true is returned. If template t is null, this method returns false.


getRunData

protected org.apache.turbine.RunData getRunData()
Give subclasses access to the RunData, so they do not have to reimplement the pooling code, just to get at it.


recycle

public void recycle()
Recycles the object by removing its disposed flag.

Specified by:
recycle in interface org.apache.fulcrum.pool.Recyclable

dispose

public void dispose()
Disposes the object by setting its disposed flag.

Specified by:
dispose in interface org.apache.fulcrum.pool.Recyclable

isDisposed

public boolean isDisposed()
Checks whether the object is disposed.

Specified by:
isDisposed in interface org.apache.fulcrum.pool.Recyclable
Returns:
true, if the object is disposed.


Copyright © 2000-2004 Tigris.org. All Rights Reserved.