org.apache.wiki.ui
Interface Command

All Known Implementing Classes:
AbstractCommand, GroupCommand, PageCommand, RedirectCommand, WikiCommand, WikiContext

public interface Command

Represents a logical "unit of work" that includes a request context, JSP, URLPattern, content template and (optionally) a target and required security permission. Examples of Commands include "view a page," "create a group," and "edit user preferences."

Commands come in two flavors: "static" and "targeted."

Concrete implementations of Command include:

For a given targeted Command, its getTarget() method will return a non-null value. In addition, its requiredPermission() method will generally also return a non-null value. It is each implementation's responsibility to construct and store the correct Permission for a given Command and Target. For example, when PageCommand.VIEW is targeted at the WikiPage Main, the Command's associated permission is PagePermission "theWiki:Main", "view".

Static Commands, and targeted Commands that do not require specific permissions to execute, return a null result for requiredPermission().

Since:
2.4.22

Method Summary
 String getContentTemplate()
          Returns the content template associated with a Command, such as PreferencesContent.jsp.
 String getJSP()
          Returns the JSP associated with the Command.
 String getName()
          Returns the human-friendly name for this command.
 String getRequestContext()
          Returns the request context associated with this Command.
 Object getTarget()
          Returns the target associated with a Command, if it was created with one.
 String getURLPattern()
          Returns the URL pattern associated with this Command.
 Permission requiredPermission()
          Returns the Permission required to successfully execute this Command.
 Command targetedCommand(Object target)
          Creates and returns a targeted Command by combining a target, such as a WikiPage or GroupPrincipal into the existing Command.
 

Method Detail

targetedCommand

Command targetedCommand(Object target)
Creates and returns a targeted Command by combining a target, such as a WikiPage or GroupPrincipal into the existing Command. Subclasses should check to make sure the supplied target object is of the correct type. This method is guaranteed to return a non-null Command (unless the target is an incorrect type).

Parameters:
target - the object to combine, such as a GroupPrincipal or WikiPage
Returns:
the new, targeted Command
Throws:
IllegalArgumentException - if the target is not of the correct type

getContentTemplate

String getContentTemplate()
Returns the content template associated with a Command, such as PreferencesContent.jsp. For Commands that are not page-related, this method will always return null. Calling methods should always check to see if the result of this method is null.

Returns:
the content template

getJSP

String getJSP()
Returns the JSP associated with the Command. The JSP is a "local" JSP within the JSPWiki webapp; it is not a general HTTP URL. If it exists, the JSP will be expressed relative to the webapp root, without a leading slash. This method is guaranteed to return a non-null result, although in some cases the result may be an empty string.

Returns:
the JSP or url associated with the wiki command

getName

String getName()
Returns the human-friendly name for this command.

Returns:
the name

getRequestContext

String getRequestContext()
Returns the request context associated with this Command. This method is guaranteed to return a non-null String.

Returns:
the request context

requiredPermission

Permission requiredPermission()
Returns the Permission required to successfully execute this Command. If no Permission is requred, this method returns null. For example, the static command PageCommand.VIEW doesn't require a permission because it isn't referring to a particular WikiPage. However, if this command targets a WikiPage called Main(via PageCommand.targetedCommand(Object), the resulting Command would require the permission PagePermission "yourWiki:Main", "view".

Returns:
the required permission, or null if not required

getTarget

Object getTarget()
Returns the target associated with a Command, if it was created with one. Commands created with targetedCommand(Object) will always return a non-null object. Calling methods should always check to see if the result of this method is null.

Returns:
the wiki page

getURLPattern

String getURLPattern()
Returns the URL pattern associated with this Command. This method is guaranteed to return a non-null String.

Returns:
the URL pattern


Copyright © {inceptionYear}-2014 The Apache Software Foundation. All rights reserved.