This is an automated email from the ASF dual-hosted git repository. juanpablo pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/jspwiki.git
commit c5f0b073f433b18f7a442993ddd23767ddf1aa49 Author: juanpablo <[email protected]> AuthorDate: Sun Mar 15 13:15:42 2020 +0100 JSPWIKI-303: remove o.a.w.ui.Command and use o.a.w.api.core.command Context extends Command also, move WikiPlugin to jspwiki-210-adapters module --- .../org/apache/wiki/api/plugin/WikiPlugin.java | 0 .../java/org/apache/wiki/api/core/Context.java | 13 ++- .../main/java/org/apache/wiki/LinkCollector.java | 4 +- .../java/org/apache/wiki/StringTransmutator.java | 3 +- .../src/main/java/org/apache/wiki/WikiContext.java | 44 +++---- .../java/org/apache/wiki/ui/AbstractCommand.java | 1 + .../src/main/java/org/apache/wiki/ui/Command.java | 128 --------------------- .../java/org/apache/wiki/ui/CommandResolver.java | 1 + .../org/apache/wiki/ui/DefaultCommandResolver.java | 1 + .../main/java/org/apache/wiki/ui/GroupCommand.java | 5 +- .../main/java/org/apache/wiki/ui/PageCommand.java | 5 +- .../java/org/apache/wiki/ui/RedirectCommand.java | 6 +- .../main/java/org/apache/wiki/ui/WikiCommand.java | 5 +- .../java/org/apache/wiki/ui/WikiServletFilter.java | 3 +- .../org/apache/wiki/url/DefaultURLConstructor.java | 2 +- .../org/apache/wiki/ui/CommandResolverTest.java | 1 + .../java/org/apache/wiki/ui/GroupCommandTest.java | 9 +- .../java/org/apache/wiki/ui/PageCommandTest.java | 1 + .../org/apache/wiki/ui/RedirectCommandTest.java | 5 +- .../java/org/apache/wiki/ui/WikiCommandTest.java | 7 +- 20 files changed, 66 insertions(+), 178 deletions(-) diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/WikiPlugin.java b/jspwiki-210-adapters/src/main/java/org/apache/wiki/api/plugin/WikiPlugin.java similarity index 100% rename from jspwiki-main/src/main/java/org/apache/wiki/api/plugin/WikiPlugin.java rename to jspwiki-210-adapters/src/main/java/org/apache/wiki/api/plugin/WikiPlugin.java diff --git a/jspwiki-api/src/main/java/org/apache/wiki/api/core/Context.java b/jspwiki-api/src/main/java/org/apache/wiki/api/core/Context.java index 158425f..0b58a92 100644 --- a/jspwiki-api/src/main/java/org/apache/wiki/api/core/Context.java +++ b/jspwiki-api/src/main/java/org/apache/wiki/api/core/Context.java @@ -36,7 +36,18 @@ import java.security.Principal; * * @see org.apache.wiki.plugin.Counter */ -public interface Context extends Cloneable /*, Command*/ { +public interface Context extends Cloneable, Command { + + String ATTR_CONTEXT = "jspwiki.context"; + + /** + * Variable name which tells whether plugins should be executed or not. Value can be either {@code Boolean.TRUE} or + * {@code Boolean.FALSE}. While not set it's value is {@code null}. + */ + String VAR_EXECUTE_PLUGINS = "_PluginContent.execute"; + + /** Name of the variable which is set to Boolean.TRUE or Boolean.FALSE depending on whether WYSIWYG is currently in effect. */ + String VAR_WYSIWYG_EDITOR_MODE = "WYSIWYG_EDITOR_MODE"; /** * Returns the WikiPage that is being handled. diff --git a/jspwiki-main/src/main/java/org/apache/wiki/LinkCollector.java b/jspwiki-main/src/main/java/org/apache/wiki/LinkCollector.java index 1800b0d..286b3f3 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/LinkCollector.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/LinkCollector.java @@ -18,6 +18,8 @@ */ package org.apache.wiki; +import org.apache.wiki.api.core.Context; + import java.util.ArrayList; import java.util.List; @@ -40,7 +42,7 @@ public class LinkCollector implements StringTransmutator { /** * {@inheritDoc} */ - public String mutate( final WikiContext context, final String in ) { + public String mutate( final Context context, final String in ) { m_items.add( in ); return in; } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/StringTransmutator.java b/jspwiki-main/src/main/java/org/apache/wiki/StringTransmutator.java index d806486..c2fc1c6 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/StringTransmutator.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/StringTransmutator.java @@ -18,6 +18,7 @@ */ package org.apache.wiki; +import org.apache.wiki.api.core.Context; /** @@ -34,6 +35,6 @@ public interface StringTransmutator { * @param source The source string. * @return The mutated string. */ - String mutate( WikiContext context, String source ); + String mutate( Context context, String source ); } diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java index adf5799..717b9d3 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java @@ -19,6 +19,7 @@ package org.apache.wiki; import org.apache.log4j.Logger; +import org.apache.wiki.api.core.Command; import org.apache.wiki.api.core.Context; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.core.Page; @@ -30,7 +31,6 @@ import org.apache.wiki.auth.WikiPrincipal; import org.apache.wiki.auth.permissions.AllPermission; import org.apache.wiki.auth.user.UserDatabase; import org.apache.wiki.pages.PageManager; -import org.apache.wiki.ui.Command; import org.apache.wiki.ui.CommandResolver; import org.apache.wiki.ui.GroupCommand; import org.apache.wiki.ui.Installer; @@ -74,17 +74,6 @@ public class WikiContext implements Context, Command { private Session m_session; - public static final String ATTR_CONTEXT = "jspwiki.context"; - - /** - * Variable name which tells whether plugins should be executed or not. Value can be either {@code Boolean.TRUE} or - * {@code Boolean.FALSE}. While not set it's value is {@code null}. - */ - public static final String VAR_EXECUTE_PLUGINS = "_PluginContent.execute"; - - /** Name of the variable which is set to Boolean.TRUE or Boolean.FALSE depending on whether WYSIWYG is currently in effect. */ - public static final String VAR_WYSIWYG_EDITOR_MODE = "WYSIWYG_EDITOR_MODE"; - /** User is administering JSPWiki (Install, SecurityConfig). */ public static final String INSTALL = WikiCommand.INSTALL.getRequestContext(); @@ -172,13 +161,12 @@ public class WikiContext implements Context, Command { private static final Permission DUMMY_PERMISSION = new PropertyPermission( "os.name", "read" ); /** - * Create a new WikiContext for the given WikiPage. Delegates to {@link #WikiContext(Engine, HttpServletRequest, WikiPage)}. + * Create a new WikiContext for the given WikiPage. Delegates to {@link #WikiContext(Engine, HttpServletRequest, Page)}. * * @param engine The Engine that is handling the request. * @param page The WikiPage. If you want to create a WikiContext for an older version of a page, you must use this constructor. */ - public WikiContext( final Engine engine, final WikiPage page ) - { + public WikiContext( final Engine engine, final Page page ) { this( engine, null, findCommand( engine, null, page ) ); } @@ -240,14 +228,14 @@ public class WikiContext implements Context, Command { /** * Creates a new WikiContext for the given Engine, WikiPage and HttpServletRequest. This method simply looks up the appropriate - * Command using {@link #findCommand(Engine, HttpServletRequest, WikiPage)} and delegates to + * Command using {@link #findCommand(Engine, HttpServletRequest, Page)} and delegates to * {@link #WikiContext(Engine, HttpServletRequest, Command)}. * * @param engine The Engine that is handling the request * @param request The HttpServletRequest that should be associated with this context. This parameter may be <code>null</code>. * @param page The WikiPage. If you want to create a WikiContext for an older version of a page, you must supply this parameter */ - public WikiContext( final Engine engine, final HttpServletRequest request, final WikiPage page ) { + public WikiContext( final Engine engine, final HttpServletRequest request, final Page page ) { this( engine, request, findCommand( engine, request, page ) ); } @@ -260,7 +248,7 @@ public class WikiContext implements Context, Command { * @return a new WikiContext object. * * @see org.apache.wiki.ui.CommandResolver - * @see org.apache.wiki.ui.Command + * @see org.apache.wiki.api.core.Command * @since 2.1.15. */ public WikiContext( final Engine engine, final HttpServletRequest request, final String requestContext ) { @@ -272,7 +260,7 @@ public class WikiContext implements Context, Command { /** * {@inheritDoc} - * @see org.apache.wiki.ui.Command#getContentTemplate() + * @see org.apache.wiki.api.core.Command#getContentTemplate() */ @Override public String getContentTemplate() @@ -282,7 +270,7 @@ public class WikiContext implements Context, Command { /** * {@inheritDoc} - * @see org.apache.wiki.ui.Command#getJSP() + * @see org.apache.wiki.api.core.Command#getJSP() */ @Override public String getJSP() @@ -411,7 +399,7 @@ public class WikiContext implements Context, Command { /** * {@inheritDoc} - * @see org.apache.wiki.ui.Command#getTarget() + * @see org.apache.wiki.api.core.Command#getTarget() */ @Override public Object getTarget() @@ -421,7 +409,7 @@ public class WikiContext implements Context, Command { /** * {@inheritDoc} - * @see org.apache.wiki.ui.Command#getURLPattern() + * @see org.apache.wiki.api.core.Command#getURLPattern() */ @Override public String getURLPattern() @@ -436,9 +424,9 @@ public class WikiContext implements Context, Command { * @return The variable contents. */ @Override - public Object getVariable( final String key ) - { - return m_variableMap.get( key ); + @SuppressWarnings( "unchecked" ) + public < T > T getVariable( final String key ) { + return ( T )m_variableMap.get( key ); } /** @@ -518,7 +506,7 @@ public class WikiContext implements Context, Command { /** * Returns the target of this wiki context: a page, group name or JSP. If the associated Command is a PageCommand, this method - * returns the page's name. Otherwise, this method delegates to the associated Command's {@link org.apache.wiki.ui.Command#getName()} + * returns the page's name. Otherwise, this method delegates to the associated Command's {@link org.apache.wiki.api.core.Command#getName()} * method. Calling classes can rely on the results of this method for looking up canonically-correct page or group names. Because it * does not automatically assume that the wiki context is a PageCommand, calling this method is inherently safer than calling * {@code getPage().getName()}. @@ -732,7 +720,7 @@ public class WikiContext implements Context, Command { * Associates a target with the current Command and returns the new targeted Command. If the Command associated with this * WikiContext is already "targeted", it is returned instead. * - * @see org.apache.wiki.ui.Command#targetedCommand(java.lang.Object) + * @see org.apache.wiki.api.core.Command#targetedCommand(java.lang.Object) * * {@inheritDoc} */ @@ -800,7 +788,7 @@ public class WikiContext implements Context, Command { * @param page the wiki page * @return the correct command */ - protected static Command findCommand( final Engine engine, final HttpServletRequest request, final WikiPage page ) { + protected static Command findCommand( final Engine engine, final HttpServletRequest request, final Page page ) { final String defaultContext = PageCommand.VIEW.getRequestContext(); Command command = engine.getManager( CommandResolver.class ).findCommand( request, defaultContext ); if ( command instanceof PageCommand && page != null ) { diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/AbstractCommand.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/AbstractCommand.java index 777a5ad..4bccec1 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/ui/AbstractCommand.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/AbstractCommand.java @@ -18,6 +18,7 @@ */ package org.apache.wiki.ui; +import org.apache.wiki.api.core.Command; import org.apache.wiki.util.TextUtil; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/Command.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/Command.java deleted file mode 100644 index 5a40e6a..0000000 --- a/jspwiki-main/src/main/java/org/apache/wiki/ui/Command.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - Licensed to the Apache Software Foundation (ASF) under one - or more contributor license agreements. See the NOTICE file - distributed with this work for additional information - regarding copyright ownership. The ASF licenses this file - to you 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.wiki.ui; - -import java.security.Permission; - -/** - * <p>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." </p> - * <p> Commands come in two flavors: "static" and "targeted." </p> - * <ul> - * <li><strong>Static commands</strong> are exactly what they sound like: static. They are <code>final</code>, 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 <em>which</em> 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 properties such as the associated URL pattern and content JSP.</li> - * <li><strong>Targeted commands</strong> "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}.</li> - * </ul> - * <p> Concrete implementations of Command include: </p> - * <ul> - * <li><strong>PageCommand</strong>: commands for editing, renaming, and viewing pages</li> - * <li><strong>GroupCommand</strong>: commands for viewing, editing and - * deleting wiki groups</li> - * <li><strong>WikiCommand</strong>: commands for wiki-wide operations such as - * creating groups, editing preferences and profiles, and logging in/out</li> - * <li><strong>RedirectCommand</strong>: commands for redirections to off-site - * special pages</li> - * </ul> - * <p> - * For a given targeted Command, its {@link #getTarget()} method will return a non-<code>null</code> value. In addition, its - * {@link #requiredPermission()} method will generally also return a non-<code>null</code> 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 <code>Main</code>, the Command's associated permission is <code>PagePermission "<em>theWiki</em>:Main", "view".</code></p> - * <p>Static Commands, and targeted Commands that do not require specific permissions to execute, return a <code>null</code> result for - * {@link #requiredPermission()}.</p> - * @since 2.4.22 - */ -public interface Command { - - /** - * 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 <code>target</code> object is of the correct type. This method is guaranteed - * to return a non-<code>null</code> Command (unless the target is an incorrect type). - * - * @param target the object to combine, such as a GroupPrincipal or WikiPage - * @return the new, targeted Command - * @throws IllegalArgumentException if the target is not of the correct type - */ - Command targetedCommand( Object target ); - - /** - * Returns the content template associated with a Command, such as <code>PreferencesContent.jsp</code>. For Commands that are not - * page-related, this method will always return <code>null</code>. <em>Calling methods should always check to see if the result - * of this method is <code>null</code></em>. - * - * @return the content template - */ - String getContentTemplate(); - - /** - * 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-<code>null</code> result, although in some cases the result may be an empty string. - * - * @return the JSP or url associated with the wiki command - */ - String getJSP(); - - /** - * Returns the human-friendly name for this command. - * - * @return the name - */ - String getName(); - - /** - * Returns the request context associated with this Command. This method is guaranteed to return a non-<code>null</code> String. - * @return the request context - */ - String getRequestContext(); - - /** - * Returns the Permission required to successfully execute this Command. If no Permission is requred, this method returns - * <code>null</code>. For example, the static command {@link PageCommand#VIEW} doesn't require a permission because it isn't referring - * to a particular WikiPage. However, if this command targets a WikiPage called <code>Main</code>(via - * {@link PageCommand#targetedCommand(Object)}, the resulting Command would require the permission - * <code>PagePermission "<em>yourWiki</em>:Main", "view"</code>. - * - * @return the required permission, or <code>null</code> if not required - */ - Permission requiredPermission(); - - /** - * Returns the target associated with a Command, if it was created with one. Commands created with {@link #targetedCommand(Object)} will - * <em>always</em> return a non-<code>null</code> object. <em>Calling methods should always check to see if the result of this method - * is <code>null</code></em>. - * - * @return the wiki page - */ - Object getTarget(); - - /** - * Returns the URL pattern associated with this Command. This method is guaranteed to return a non-<code>null</code> String. - * - * @return the URL pattern - */ - String getURLPattern(); - -} diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java index c684b2a..f24f830 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java @@ -19,6 +19,7 @@ package org.apache.wiki.ui; import org.apache.wiki.WikiPage; +import org.apache.wiki.api.core.Command; import org.apache.wiki.api.exceptions.ProviderException; import javax.servlet.http.HttpServletRequest; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java index 74ea378..a2a5c82 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java @@ -21,6 +21,7 @@ package org.apache.wiki.ui; import org.apache.log4j.Logger; import org.apache.wiki.InternalWikiException; import org.apache.wiki.WikiPage; +import org.apache.wiki.api.core.Command; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.exceptions.ProviderException; import org.apache.wiki.api.providers.WikiProvider; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/GroupCommand.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/GroupCommand.java index 2466236..3379b03 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/ui/GroupCommand.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/GroupCommand.java @@ -18,6 +18,7 @@ */ package org.apache.wiki.ui; +import org.apache.wiki.api.core.Command; import org.apache.wiki.auth.GroupPrincipal; import org.apache.wiki.auth.permissions.GroupPermission; @@ -100,7 +101,7 @@ public final class GroupCommand extends AbstractCommand { * Returns the name of the command, which will either be the target (if specified), or the "friendly name" for the JSP. * * @return the name - * @see org.apache.wiki.ui.Command#getName() + * @see org.apache.wiki.api.core.Command#getName() */ public String getName() { final Object target = getTarget(); @@ -114,7 +115,7 @@ public final class GroupCommand extends AbstractCommand { * Returns the permission required to execute this GroupCommand. * * @return the permission - * @see org.apache.wiki.ui.Command#requiredPermission() + * @see org.apache.wiki.api.core.Command#requiredPermission() */ public Permission requiredPermission() { return m_permission; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java index cd0d886..b8fcca7 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java @@ -19,6 +19,7 @@ package org.apache.wiki.ui; import org.apache.wiki.WikiPage; +import org.apache.wiki.api.core.Command; import org.apache.wiki.auth.permissions.PagePermission; import org.apache.wiki.auth.permissions.PermissionFactory; @@ -118,7 +119,7 @@ public final class PageCommand extends AbstractCommand { } /** - * @see org.apache.wiki.ui.Command#getName() + * @see org.apache.wiki.api.core.Command#getName() */ public String getName() { final Object target = getTarget(); @@ -129,7 +130,7 @@ public final class PageCommand extends AbstractCommand { } /** - * @see org.apache.wiki.ui.Command#requiredPermission() + * @see org.apache.wiki.api.core.Command#requiredPermission() */ public Permission requiredPermission() { return m_permission; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/RedirectCommand.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/RedirectCommand.java index cb098c2..2a221f4 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/ui/RedirectCommand.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/RedirectCommand.java @@ -18,6 +18,8 @@ */ package org.apache.wiki.ui; +import org.apache.wiki.api.core.Command; + import java.security.Permission; /** @@ -63,7 +65,7 @@ public final class RedirectCommand extends AbstractCommand { } /** - * @see org.apache.wiki.ui.Command#getName() + * @see org.apache.wiki.api.core.Command#getName() */ public String getName() { final Object target = getTarget(); @@ -76,7 +78,7 @@ public final class RedirectCommand extends AbstractCommand { /** * No-op; always returns <code>null</code>. * - * @see org.apache.wiki.ui.Command#requiredPermission() + * @see org.apache.wiki.api.core.Command#requiredPermission() */ public Permission requiredPermission() { return null; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiCommand.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiCommand.java index 1d81475..7ac7cec 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiCommand.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiCommand.java @@ -18,6 +18,7 @@ */ package org.apache.wiki.ui; +import org.apache.wiki.api.core.Command; import org.apache.wiki.auth.permissions.AllPermission; import org.apache.wiki.auth.permissions.WikiPermission; @@ -123,14 +124,14 @@ public final class WikiCommand extends AbstractCommand { /** * Always returns the "friendly" JSP name. * - * @see org.apache.wiki.ui.Command#getName() + * @see org.apache.wiki.api.core.Command#getName() */ @Override public String getName() { return getJSPFriendlyName(); } /** - * @see org.apache.wiki.ui.Command#requiredPermission() + * @see org.apache.wiki.api.core.Command#requiredPermission() */ @Override public Permission requiredPermission() { return m_permission; diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java index 9b98604..6583ba6 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java @@ -22,6 +22,7 @@ import org.apache.log4j.Logger; import org.apache.log4j.NDC; import org.apache.wiki.WikiContext; import org.apache.wiki.WikiEngine; +import org.apache.wiki.api.core.Context; import org.apache.wiki.api.core.Engine; import org.apache.wiki.api.core.Session; import org.apache.wiki.auth.AuthenticationManager; @@ -159,7 +160,7 @@ public class WikiServletFilter implements Filter { */ protected WikiContext getWikiContext( final ServletRequest request ) { final HttpServletRequest httpRequest = (HttpServletRequest) request; - return ( WikiContext )httpRequest.getAttribute( WikiContext.ATTR_CONTEXT ); + return ( WikiContext )httpRequest.getAttribute( Context.ATTR_CONTEXT ); } /** diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java index 370b6c4..d60a2d4 100644 --- a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java +++ b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java @@ -20,8 +20,8 @@ package org.apache.wiki.url; import org.apache.commons.lang3.StringUtils; import org.apache.wiki.WikiContext; +import org.apache.wiki.api.core.Command; import org.apache.wiki.api.core.Engine; -import org.apache.wiki.ui.Command; import org.apache.wiki.ui.CommandResolver; import org.apache.wiki.util.TextUtil; diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java index 192aba2..112a214 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java @@ -27,6 +27,7 @@ import org.apache.wiki.TestEngine; import org.apache.wiki.WikiContext; import org.apache.wiki.WikiEngine; import org.apache.wiki.WikiPage; +import org.apache.wiki.api.core.Command; import org.apache.wiki.auth.GroupPrincipal; import org.apache.wiki.pages.PageManager; import org.junit.jupiter.api.AfterEach; diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ui/GroupCommandTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ui/GroupCommandTest.java index 34a40d4..5f5e43e 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/ui/GroupCommandTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/ui/GroupCommandTest.java @@ -22,21 +22,22 @@ */ package org.apache.wiki.ui; -import java.util.Properties; - import org.apache.wiki.TestEngine; +import org.apache.wiki.api.core.Command; import org.apache.wiki.auth.GroupPrincipal; import org.apache.wiki.auth.permissions.GroupPermission; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.util.Properties; + public class GroupCommandTest { @BeforeEach public void setUp() throws Exception { - Properties props = TestEngine.getTestProperties(); + final Properties props = TestEngine.getTestProperties(); new TestEngine( props ); } @@ -78,7 +79,7 @@ public class GroupCommandTest { // Get view command Command a = GroupCommand.VIEW_GROUP; - GroupPrincipal group = new GroupPrincipal( "Test" ); + final GroupPrincipal group = new GroupPrincipal( "Test" ); // Combine with wiki group; make sure it's not equal to old command Command b = a.targetedCommand( group ); diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java index 483713d..ed81d7a 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java @@ -24,6 +24,7 @@ package org.apache.wiki.ui; import org.apache.wiki.TestEngine; import org.apache.wiki.WikiPage; +import org.apache.wiki.api.core.Command; import org.apache.wiki.auth.permissions.PermissionFactory; import org.apache.wiki.pages.PageManager; import org.junit.jupiter.api.Assertions; diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ui/RedirectCommandTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ui/RedirectCommandTest.java index c127f2f..796e124 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/ui/RedirectCommandTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/ui/RedirectCommandTest.java @@ -22,6 +22,7 @@ */ package org.apache.wiki.ui; +import org.apache.wiki.api.core.Command; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -32,7 +33,7 @@ public class RedirectCommandTest @Test public void testStaticCommand() { - Command a = RedirectCommand.REDIRECT; + final Command a = RedirectCommand.REDIRECT; Assertions.assertEquals( "", a.getRequestContext() ); Assertions.assertEquals( "", a.getJSP() ); Assertions.assertEquals( "%u%n", a.getURLPattern() ); @@ -44,7 +45,7 @@ public class RedirectCommandTest @Test public void testTargetedCommand() { - Command a = RedirectCommand.REDIRECT; + final Command a = RedirectCommand.REDIRECT; // Test with local JSP Command b = a.targetedCommand( "%uTestPage.jsp" ); diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ui/WikiCommandTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ui/WikiCommandTest.java index 590a2a9..4bfe803 100644 --- a/jspwiki-main/src/test/java/org/apache/wiki/ui/WikiCommandTest.java +++ b/jspwiki-main/src/test/java/org/apache/wiki/ui/WikiCommandTest.java @@ -22,14 +22,15 @@ */ package org.apache.wiki.ui; -import java.util.Properties; - import org.apache.wiki.TestEngine; +import org.apache.wiki.api.core.Command; import org.apache.wiki.auth.permissions.WikiPermission; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.util.Properties; + public class WikiCommandTest { TestEngine testEngine; @@ -38,7 +39,7 @@ public class WikiCommandTest @BeforeEach public void setUp() throws Exception { - Properties props = TestEngine.getTestProperties(); + final Properties props = TestEngine.getTestProperties(); testEngine = new TestEngine( props ); wiki = testEngine.getApplicationName(); }
