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."
- Static commands are exactly what they sound like: static. They are
final
, threadsafe, and immutable. They have no intrinsic idea of the context they are acting in. For example, the static command {@link PageCommand#VIEW} embodies the idea of viewing a page —but exactly which page is left undefined. Static commands exist so that they can be freely shared and passed around without incurring the penalties of object creation. Static commands are a lot like naked request contexts ("edit", "view", etc.) except that they include additional, essential properites such as the associated URL pattern and content JSP. - Targeted commands "decorate" static commands by scoping a static Command at a specific target such as a WikiPage or GroupPrincipal. Targeted commands are created by calling an existing Command's {@link #targetedCommand(Object)} and supplying the target object.Implementing classes generally require a specific target type. For example, the {@link PageCommand} class requires that the target object be of type{@link org.apache.wiki.WikiPage}.
Concrete implementations of Command include:
- PageCommand: commands for editing, renaming, and viewing pages
- GroupCommand: commands for viewing, editing and deleting wiki groups
- WikiCommand: commands for wiki-wide operations such as creating groups, editing preferences and profiles, and logging in/out
- RedirectCommand: commands for redirections to off-site special pages
For a given targeted Command, its {@link #getTarget()} method will return anon-null
value. In addition, its {@link #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 {@link #requiredPermission()}.
@since 2.4.22