You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2020/01/28 20:34:01 UTC

[jspwiki] branch master updated (ffee109 -> 62bb84c)

This is an automated email from the ASF dual-hosted git repository.

juanpablo pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/jspwiki.git.


    from ffee109  2.11.0-M7-git-05
     new 4a639d7  fix WikiEngine#getViewURL so that absolute parameter from makeUrl(..) is correctly calculated against the resolved variable instead to its associated key
     new 9329f14  add unit test for WikiEngine#getViewURL fix
     new ddb2cdd  apply fixes and formatting suggested by IntelliJ
     new 8a7d63b  fix: add synchronization to progressing tasks on progress manager
     new d9ad1ac  add synchronization to ajaxServlets on WikiAjaxDispatcherServlet + apply intellij's suggested format
     new 3e00cb1  add @SuppressWarnings("unchecked") to getAttribute( String )
     new 9d3daea  apply intellij's suggested formatting
     new 5eb41ff  rename + extract interface from ProgressManager, instantiate it through classmappings.xml on WikiEngine
     new bddeab5  explicit javadoc
     new c88e155  apply formatting fixes suggested by intellij
     new 9aeae93  WikiEngine init now enforces at least a 3.1 servlet api environment, inline with the servlet-api dependency version
     new c41fa09  fix TestEngine so it uses a "3.1" compatible servlet context
     new a2c8381  revisit + revert getViewURL(..) previous fix
     new d3f4bd3  JSPWIKI-120: remove WikiEngine#getRedirectURL(..) use same method on WikiContext
     new b6465dd  WikiEngine init'd check must be done only on new constructor
     new 719c115  JSPWIKI-120: propagate WikiEngine#createContext(..) to new WikiContext change on jsps
     new 21c46bb  JSPWIKI-1127: remove getViewURL from WikiEngine + remove absolute parameter from url constructors
     new 74e0434  JSPWIKI-1127: propagate changes on java code
     new f5701c0  JSPWIKI-1127: propagate changes on JSPs
     new 3e8e1e6  JSPWIKI-1127: remove references to PROP_REFSTYLE
     new f7cf1a6  JSPWIKI-1127: as a result, LinkTag no longer needs/uses absolute parameter
     new 6a20fb4  JSPWIKI-1127: remove absolute parameter from wiki:Link tags
     new bab93e9  Update dependencies
     new d741a8b  move PageEventFilter to filters package: it's a wiki filter, and we break a package cycle between event and filter
     new 6e4d2f3  fix javadocs so the updated package of PageEventFilter is used.
     new 6c42eb1  JSPWIKI-120: rename CommandResolver as DefaultCommandResolver and extract CommandResolver interface from it
     new 08eec1e  apply formatting fixes suggested by intellij
     new 2642c4b  apply formatting and fixes suggested by intellij
     new 7782b72  remove WikiEventUtils
     new d94e958  apply format and fixes suggested by intellij to classes under the org.apache.wiki.search package
     new 593f947  Update ASF parent pom to version 23
     new 62bb84c  2.11.0-M7-git-06

The 32 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 ChangeLog.md                                       |  26 +-
 .../src/main/java/org/apache/wiki/Release.java     |   2 +-
 .../src/main/java/org/apache/wiki/WikiContext.java |  29 +-
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 402 ++++++----------
 .../main/java/org/apache/wiki/ajax/AjaxUtil.java   |  70 +--
 .../wiki/ajax/WikiAjaxDispatcherServlet.java       | 123 ++---
 .../java/org/apache/wiki/ajax/WikiAjaxServlet.java |  11 +-
 .../apache/wiki/attachment/AttachmentServlet.java  | 129 ++---
 .../org/apache/wiki/auth/AuthorizationManager.java |   2 +-
 .../org/apache/wiki/event/WikiEngineEvent.java     |  63 ++-
 .../main/java/org/apache/wiki/event/WikiEvent.java | 114 ++---
 .../org/apache/wiki/event/WikiEventListener.java   |   2 +-
 .../org/apache/wiki/event/WikiEventManager.java    | 483 +++++++------------
 .../java/org/apache/wiki/event/WikiEventUtils.java | 167 -------
 .../java/org/apache/wiki/event/WikiPageEvent.java  | 216 ++++-----
 .../org/apache/wiki/event/WikiPageRenameEvent.java |  55 +--
 .../org/apache/wiki/event/WikiSecurityEvent.java   | 101 ++--
 .../java/org/apache/wiki/event/WorkflowEvent.java  |  13 +-
 .../wiki/{event => filters}/PageEventFilter.java   |   6 +-
 .../apache/wiki/filters/PingWeblogsComFilter.java  |  82 ++--
 .../main/java/org/apache/wiki/plugin/Groups.java   |  40 +-
 .../wiki/references/DefaultReferenceManager.java   |   4 +-
 .../wiki/render/DefaultRenderingManager.java       |   4 +-
 .../main/java/org/apache/wiki/rss/AtomFeed.java    | 112 ++---
 .../main/java/org/apache/wiki/rss/RSS10Feed.java   |  10 +-
 .../main/java/org/apache/wiki/rss/RSS20Feed.java   |   2 +-
 .../java/org/apache/wiki/rss/RSSGenerator.java     | 279 +++++------
 .../apache/wiki/search/BasicSearchProvider.java    | 143 +++---
 .../java/org/apache/wiki/search/QueryItem.java     |   3 +-
 .../java/org/apache/wiki/search/SearchManager.java | 210 ++++-----
 .../java/org/apache/wiki/search/SearchMatcher.java |  49 +-
 .../org/apache/wiki/search/SearchProvider.java     |  17 +-
 .../java/org/apache/wiki/search/SearchResult.java  |   3 +-
 .../apache/wiki/search/SearchResultComparator.java |   7 +-
 .../org/apache/wiki/tags/FeedDiscoveryTag.java     |  37 +-
 .../main/java/org/apache/wiki/tags/LinkTag.java    | 329 +++++--------
 .../wiki/tasks/auth/SaveUserProfileTask.java       |  13 +-
 .../java/org/apache/wiki/ui/AbstractCommand.java   | 133 ++----
 .../src/main/java/org/apache/wiki/ui/Command.java  | 121 ++---
 .../java/org/apache/wiki/ui/CommandResolver.java   | 518 +++------------------
 .../org/apache/wiki/ui/DefaultCommandResolver.java | 330 +++++++++++++
 .../java/org/apache/wiki/ui/EditorManager.java     | 160 +++----
 .../org/apache/wiki/ui/GenericHTTPHandler.java     |  12 +-
 .../main/java/org/apache/wiki/ui/GroupCommand.java |  90 ++--
 .../java/org/apache/wiki/ui/InputValidator.java    | 135 +++---
 .../main/java/org/apache/wiki/ui/Installer.java    | 180 +++----
 .../main/java/org/apache/wiki/ui/PageCommand.java  |  62 ++-
 .../java/org/apache/wiki/ui/RedirectCommand.java   |  64 +--
 .../java/org/apache/wiki/ui/TemplateManager.java   | 478 +++++++------------
 .../main/java/org/apache/wiki/ui/WikiCommand.java  |  70 ++-
 .../java/org/apache/wiki/ui/WikiJSPFilter.java     | 233 ++++-----
 .../org/apache/wiki/ui/WikiRequestWrapper.java     | 103 ++--
 .../java/org/apache/wiki/ui/WikiServletFilter.java |   8 +-
 ...essManager.java => DefaultProgressManager.java} | 123 +++--
 .../org/apache/wiki/ui/progress/ProgressItem.java  |  17 +-
 .../apache/wiki/ui/progress/ProgressManager.java   | 127 +----
 .../org/apache/wiki/url/DefaultURLConstructor.java |  38 +-
 .../org/apache/wiki/url/ShortURLConstructor.java   | 200 +++-----
 .../apache/wiki/url/ShortViewURLConstructor.java   |  82 ++--
 .../java/org/apache/wiki/url/URLConstructor.java   |   3 +-
 .../org/apache/wiki/xmlrpc/MetaWeblogHandler.java  | 209 ++++-----
 .../java/org/apache/wiki/xmlrpc/RPCHandler.java    |   3 -
 .../org/apache/wiki/xmlrpc/RPCHandlerUTF8.java     |   3 -
 .../java/org/apache/wiki/xmlrpc/RPCServlet.java    | 132 ++----
 .../src/main/resources/META-INF/jspwiki.tld        |   4 -
 .../src/main/resources/ini/classmappings.xml       |   8 +
 .../src/test/java/org/apache/wiki/TestEngine.java  |  17 +-
 .../test/java/org/apache/wiki/WikiServletTest.java |  26 +-
 .../org/apache/wiki/search/SearchManagerTest.java  |   8 +-
 .../apache/wiki/url/DefaultURLConstructorTest.java |  30 +-
 .../apache/wiki/url/ShortURLConstructorTest.java   |  30 +-
 .../wiki/url/ShortViewURLConstructorTest.java      |  30 +-
 jspwiki-war/src/main/webapp/Captcha.jsp            |   2 +-
 jspwiki-war/src/main/webapp/Comment.jsp            |   8 +-
 jspwiki-war/src/main/webapp/CookieError.jsp        |   6 +-
 jspwiki-war/src/main/webapp/Delete.jsp             |  12 +-
 jspwiki-war/src/main/webapp/DeleteGroup.jsp        |   2 +-
 jspwiki-war/src/main/webapp/Diff.jsp               |   2 +-
 jspwiki-war/src/main/webapp/Edit.jsp               |  10 +-
 jspwiki-war/src/main/webapp/EditGroup.jsp          |   2 +-
 jspwiki-war/src/main/webapp/Error.jsp              |   3 +-
 jspwiki-war/src/main/webapp/Group.jsp              |   2 +-
 jspwiki-war/src/main/webapp/Install.jsp            |   2 +-
 jspwiki-war/src/main/webapp/Login.jsp              |   8 +-
 jspwiki-war/src/main/webapp/LoginForm.jsp          |   2 +-
 jspwiki-war/src/main/webapp/LostPassword.jsp       |   4 +-
 jspwiki-war/src/main/webapp/Message.jsp            |   2 +-
 jspwiki-war/src/main/webapp/NewBlogEntry.jsp       |   2 +-
 jspwiki-war/src/main/webapp/NewGroup.jsp           |   2 +-
 jspwiki-war/src/main/webapp/PageInfo.jsp           |   2 +-
 jspwiki-war/src/main/webapp/PageModified.jsp       |   2 +-
 jspwiki-war/src/main/webapp/Preview.jsp            |   2 +-
 jspwiki-war/src/main/webapp/Rename.jsp             |   2 +-
 jspwiki-war/src/main/webapp/Search.jsp             |   2 +-
 jspwiki-war/src/main/webapp/SisterSites.jsp        |   4 +-
 jspwiki-war/src/main/webapp/Upload.jsp             |   6 +-
 jspwiki-war/src/main/webapp/UserPreferences.jsp    |  14 +-
 jspwiki-war/src/main/webapp/Wiki.jsp               |   2 +-
 jspwiki-war/src/main/webapp/Workflow.jsp           |   2 +-
 jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp     |   2 +-
 jspwiki-war/src/main/webapp/admin/Admin.jsp        |   5 +-
 .../src/main/webapp/admin/SecurityConfig.jsp       |   5 +-
 jspwiki-war/src/main/webapp/rss.jsp                |   6 +-
 .../main/webapp/templates/210/AttachmentTab.jsp    |   2 +-
 .../src/main/webapp/templates/210/InfoContent.jsp  |   2 +-
 .../webapp/templates/default/AJAXCategories.jsp    |   2 +-
 .../main/webapp/templates/default/AJAXPreview.jsp  |   2 +-
 .../main/webapp/templates/default/AJAXSearch.jsp   |   2 +-
 .../webapp/templates/default/AttachmentTab.jsp     |   2 +-
 .../main/webapp/templates/default/InfoContent.jsp  |   2 +-
 pom.xml                                            |  12 +-
 111 files changed, 2874 insertions(+), 4424 deletions(-)
 delete mode 100644 jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java
 rename jspwiki-main/src/main/java/org/apache/wiki/{event => filters}/PageEventFilter.java (96%)
 create mode 100644 jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java
 copy jspwiki-main/src/main/java/org/apache/wiki/ui/progress/{ProgressManager.java => DefaultProgressManager.java} (50%)


[jspwiki] 28/32: apply formatting and fixes suggested by intellij

Posted by ju...@apache.org.
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 2642c4bb55e557b8e4d828560c625722f60cc83c
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Jan 27 23:43:41 2020 +0100

    apply formatting and fixes suggested by intellij
---
 .../org/apache/wiki/event/WikiEventManager.java    | 483 ++++++++-------------
 1 file changed, 171 insertions(+), 312 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventManager.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventManager.java
index 555f405..9709004 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventManager.java
@@ -19,6 +19,8 @@
 
 package org.apache.wiki.event;
 
+import org.apache.log4j.Logger;
+
 import java.lang.ref.WeakReference;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -31,31 +33,21 @@ import java.util.Set;
 import java.util.TreeSet;
 import java.util.Vector;
 
-import org.apache.log4j.Logger;
-
 /**
- *  A singleton class that manages the addition and removal of WikiEvent
- *  listeners to a event source, as well as the firing of events to those
- *  listeners. An "event source" is the object delegating its event
- *  handling to an inner delegating class supplied by this manager. The
- *  class being serviced is considered a "client" of the delegate. The
- *  WikiEventManager operates across any number of simultaneously-existing
- *  WikiEngines since it manages all delegation on a per-object basis.
- *  Anything that might fire a WikiEvent (or any of its subclasses) can be
- *  a client.
+ *  A singleton class that manages the addition and removal of WikiEvent listeners to a event source, as well as the firing of events
+ *  to those listeners. An "event source" is the object delegating its event handling to an inner delegating class supplied by this
+ *  manager. The class being serviced is considered a "client" of the delegate. The WikiEventManager operates across any number of
+ *  simultaneously-existing WikiEngines since it manages all delegation on a per-object basis. Anything that might fire a WikiEvent
+ *  (or any of its subclasses) can be a client.
  *  </p>
  *
  *  <h3>Using a Delegate for Event Listener Management</h3>
  *  <p>
- *  Basically, rather than have all manner of client classes maintain their
- *  own listener lists, add and remove listener methods, any class wanting
- *  to attach listeners can simply request a delegate object to provide that
- *  service. The delegate handles the listener list, the add and remove
- *  listener methods. Firing events is then a matter of calling the
- *  WikiEventManager's {@link #fireEvent(Object,WikiEvent)} method, where
- *  the Object is the client. Prior to instantiating the event object, the
- *  client can call {@link #isListening(Object)} to see there are any
- *  listeners attached to its delegate.
+ *  Basically, rather than have all manner of client classes maintain their own listener lists, add and remove listener methods, any
+ *  class wanting to attach listeners can simply request a delegate object to provide that service. The delegate handles the listener
+ *  list, the add and remove listener methods. Firing events is then a matter of calling the WikiEventManager's
+ *  {@link #fireEvent(Object,WikiEvent)} method, where the Object is the client. Prior to instantiating the event object, the
+ *  client can call {@link #isListening(Object)} to see there are any listeners attached to its delegate.
  *  </p>
  *
  *  <h3>Adding Listeners</h3>
@@ -63,7 +55,7 @@ import org.apache.log4j.Logger;
  *  Adding a WikiEventListener to an object is very simple:
  *  </p>
  *  <pre>
- *      WikiEventManager.addWikiEventListener(object,listener);
+ *      WikiEventManager.addWikiEventListener( object, listener );
  *  </pre>
  *
  *  <h3>Removing Listeners</h3>
@@ -71,86 +63,66 @@ import org.apache.log4j.Logger;
  *  Removing a WikiEventListener from an object is very simple:
  *  </p>
  *  <pre>
- *      WikiEventManager.removeWikiEventListener(object,listener);
+ *      WikiEventManager.removeWikiEventListener( object, listener );
  *  </pre>
- *  If you only have a reference to the listener, the following method
- *  will remove it from any clients managed by the WikiEventManager:
+ *  If you only have a reference to the listener, the following method will remove it from any clients managed by the WikiEventManager:
  *  <pre>
- *      WikiEventManager.removeWikiEventListener(listener);
+ *      WikiEventManager.removeWikiEventListener( listener );
  *  </pre>
  *
  *  <h3>Backward Compatibility: Replacing Existing <tt>fireEvent()</tt> Methods</h3>
  *  <p>
- *  Using one manager for all events processing permits consolidation of all event
- *  listeners and their associated methods in one place rather than having them
- *  attached to specific subcomponents of an application, and avoids a great deal
- *  of event-related cut-and-paste code. Convenience methods that call the
- *  WikiEventManager for event delegation can be written to maintain existing APIs.
+ *  Using one manager for all events processing permits consolidation of all event listeners and their associated methods in one place
+ *  rather than having them attached to specific subcomponents of an application, and avoids a great deal of event-related cut-and-paste
+ *  code. Convenience methods that call the WikiEventManager for event delegation can be written to maintain existing APIs.
  *  </p>
  *  <p>
- *  For example, an existing <tt>fireEvent()</tt> method might look something like
- *  this:
+ *  For example, an existing <tt>fireEvent()</tt> method might look something like this:
  *  </p>
  *  <pre>
- *    protected final void fireEvent( WikiEvent event )
- *    {
- *        for ( Iterator it = m_listeners.iterator(); it.hasNext(); )
- *        {
- *            WikiEventListener listener = (WikiEventListener)it.next();
- *            listener.actionPerformed(event);
+ *    protected final void fireEvent( WikiEvent event ) {
+ *        for( WikiEventListener listener : m_listeners ) {
+ *            listener.actionPerformed( event );
  *        }
  *    }
  *  </pre>
  *  <p>
- *  One disadvantage is that the above method is supplied with event objects,
- *  which are created even when no listener exists for them. In a busy wiki
- *  with many users unused/unnecessary event creation could be considerable.
- *  Another advantage is that in addition to the iterator, there must be code
- *  to support the addition and remove of listeners. The above could be
- *  replaced with the below code (and with no necessary local support for
- *  adding and removing listeners):
+ *  One disadvantage is that the above method is supplied with event objects, which are created even when no listener exists for them.
+ *  In a busy wiki with many users unused/unnecessary event creation could be considerable. Another advantage is that in addition to
+ *  the iterator, there must be code to support the addition and remove of listeners. The above could be replaced with the below code
+ *  (and with no necessary local support for adding and removing listeners):
  *  </p>
  *  <pre>
- *    protected final void fireEvent( int type )
- *    {
- *        if ( WikiEventManager.isListening(this) )
- *        {
- *            WikiEventManager.fireEvent(this,new WikiEngineEvent(this,type));
+ *    protected final void fireEvent( int type ) {
+ *        if( WikiEventManager.isListening( this ) ) {
+ *            WikiEventManager.fireEvent( this, new WikiEngineEvent( this, type ) );
  *        }
  *    }
  *  </pre>
  *  <p>
- *  This only needs to be customized to supply the specific parameters for
- *  whatever WikiEvent you want to create.
+ *  This only needs to be customized to supply the specific parameters for whatever WikiEvent you want to create.
  *  </p>
  *
  *  <h3 id="preloading">Preloading Listeners</h3>
  *  <p>
- *  This may be used to create listeners for objects that don't yet exist,
- *  particularly designed for embedded applications that need to be able
- *  to listen for the instantiation of an Object, by maintaining a cache
- *  of client-less WikiEvent sources that set their client upon being
- *  popped from the cache. Each time any of the methods expecting a client
- *  parameter is called with a null parameter it will preload an internal
- *  cache with a client-less delegate object that will be popped and
- *  returned in preference to creating a new object. This can have unwanted
- *  side effects if there are multiple clients populating the cache with
- *  listeners. The only check is for a Class match, so be aware if others
- *  might be populating the client-less cache with listeners.
+ *  This may be used to create listeners for objects that don't yet exist, particularly designed for embedded applications that need
+ *  to be able to listen for the instantiation of an Object, by maintaining a cache of client-less WikiEvent sources that set their
+ *  client upon being popped from the cache. Each time any of the methods expecting a client parameter is called with a null parameter
+ *  it will preload an internal cache with a client-less delegate object that will be popped and returned in preference to creating a
+ *  new object. This can have unwanted side effects if there are multiple clients populating the cache with listeners. The only check
+ *  is for a Class match, so be aware if others might be populating the client-less cache with listeners.
  *  </p>
  *  <h3>Listener lifecycle</h3>
  *  <p>
- *  Note that in most cases it is not necessary to remove a listener.
- *  As of 2.4.97, the listeners are stored as WeakReferences, and will be
- *  automatically cleaned at the next garbage collection, if you no longer
- *  hold a reference to them.  Of course, until the garbage is collected,
- *  your object might still be getting events, so if you wish to avoid that,
- *  please remove it explicitly as described above.
+ *  Note that in most cases it is not necessary to remove a listener. As of 2.4.97, the listeners are stored as WeakReferences, and
+ *  will be automatically cleaned at the next garbage collection, if you no longer hold a reference to them.  Of course, until the
+ *  garbage is collected, your object might still be getting events, so if you wish to avoid that, please remove it explicitly as
+ *  described above.
  *  </p>
  * @since 2.4.20
  */
-public final class WikiEventManager
-{
+public final class WikiEventManager {
+
     private static final Logger log = Logger.getLogger(WikiEventManager.class);
 
     /* If true, permits a WikiEventMonitor to be set. */
@@ -160,163 +132,124 @@ public final class WikiEventManager
     private static WikiEventListener c_monitor = null;
 
     /* The Map of client object to WikiEventDelegate. */
-    private final Map<Object, WikiEventDelegate> m_delegates = new HashMap<>();
+    private final Map< Object, WikiEventDelegate > m_delegates = new HashMap<>();
 
     /* The Vector containing any preloaded WikiEventDelegates. */
-    private final Vector<WikiEventDelegate> m_preloadCache = new Vector<>();
+    private final Vector< WikiEventDelegate > m_preloadCache = new Vector<>();
 
     /* Singleton instance of the WikiEventManager. */
     private static WikiEventManager c_instance = null;
 
-    // ............
-
-    /**
-     *  Constructor for a WikiEventManager.
-     */
-    private WikiEventManager()
-    {
+    /** Constructor for a WikiEventManager. */
+    private WikiEventManager() {
         c_instance = this;
-        log.debug("instantiated WikiEventManager");
+        log.debug( "instantiated WikiEventManager" );
     }
 
     /**
-     *  As this is a singleton class, this returns the single
-     *  instance of this class provided with the property file
+     *  As this is a singleton class, this returns the single instance of this class provided with the property file
      *  filename and bit-wise application settings.
      *
      *  @return A shared instance of the WikiEventManager
      */
-    public static WikiEventManager getInstance()
-    {
-        if( c_instance == null )
-        {
-            synchronized( WikiEventManager.class )
-            {
-                WikiEventManager mgr = new WikiEventManager();
+    public static WikiEventManager getInstance() {
+        if( c_instance == null ) {
+            synchronized( WikiEventManager.class ) {
+                return new WikiEventManager();
                 // start up any post-instantiation services here
-                return mgr;
             }
         }
         return c_instance;
     }
 
-
     // public/API methods ......................................................
 
-
     /**
-     *  Registers a WikiEventListener with a WikiEventDelegate for
-     *  the provided client object.
+     *  Registers a WikiEventListener with a WikiEventDelegate for the provided client object.
      *
      *  <h3>Monitor Listener</h3>
      *
-     *  If <tt>client</tt> is a reference to the WikiEventManager class
-     *  itself and the compile-time flag {@link #c_permitMonitor} is true,
-     *  this attaches the listener as an all-event monitor, overwriting
-     *  any previous listener (hence returning true).
+     *  If <tt>client</tt> is a reference to the WikiEventManager class itself and the compile-time flag {@link #c_permitMonitor} is true,
+     *  this attaches the listener as an all-event monitor, overwriting any previous listener (hence returning true).
      *  <p>
-     *  You can remove any existing monitor by either calling this method
-     *  with <tt>client</tt> as a reference to this class and the
-     *  <tt>listener</tt> parameter as null, or
-     *  {@link #removeWikiEventListener(Object,WikiEventListener)} with a
-     *  <tt>client</tt> as a reference to this class. The <tt>listener</tt>
-     *  parameter in this case is ignored.
+     *  You can remove any existing monitor by either calling this method with <tt>client</tt> as a reference to this class and the
+     *  <tt>listener</tt> parameter as null, or {@link #removeWikiEventListener(Object,WikiEventListener)} with a <tt>client</tt>
+     *  as a reference to this class. The <tt>listener</tt> parameter in this case is ignored.
      *
      * @param client   the client of the event source
      * @param listener the event listener
      * @return true if the listener was added (i.e., it was not already in the list and was added)
      */
-    public static boolean addWikiEventListener(
-            Object client, WikiEventListener listener )
-    {
-        if ( client == WikiEventManager.class )
-        {
-            if ( c_permitMonitor ) c_monitor = listener;
+    public static boolean addWikiEventListener( final Object client, final WikiEventListener listener ) {
+        if( client == WikiEventManager.class ) {
+            if ( c_permitMonitor ) {
+                c_monitor = listener;
+            }
             return c_permitMonitor;
         }
-        WikiEventDelegate delegate = getInstance().getDelegateFor(client);
+        final WikiEventDelegate delegate = getInstance().getDelegateFor(client);
         return delegate.addWikiEventListener(listener);
     }
 
-
     /**
-     *  Un-registers a WikiEventListener with the WikiEventDelegate for
-     *  the provided client object.
+     *  Un-registers a WikiEventListener with the WikiEventDelegate for the provided client object.
      *
      * @param client   the client of the event source
      * @param listener the event listener
      * @return true if the listener was found and removed.
      */
-    public static boolean removeWikiEventListener(
-            Object client, WikiEventListener listener )
-    {
-        if ( client == WikiEventManager.class )
-        {
+    public static boolean removeWikiEventListener( final Object client, final WikiEventListener listener ) {
+        if ( client == WikiEventManager.class ) {
             c_monitor = null;
             return true;
         }
-        WikiEventDelegate delegate = getInstance().getDelegateFor(client);
+        final WikiEventDelegate delegate = getInstance().getDelegateFor(client);
         return delegate.removeWikiEventListener(listener);
     }
 
-
     /**
-     *  Return the Set containing the WikiEventListeners attached to the
-     *  delegate for the supplied client. If there are no attached listeners,
-     *  returns an empty Iterator rather than null.  Note that this will
-     *  create a delegate for the client if it did not exist prior to the call.
+     *  Return the Set containing the WikiEventListeners attached to the delegate for the supplied client. If there are no
+     *  attached listeners, returns an empty Iterator rather than null.  Note that this will create a delegate for the client
+     *  if it did not exist prior to the call.
      *
      *  <h3>NOTE</h3>
      *  <p>
-     *  This method returns a Set rather than an Iterator because of the high
-     *  likelihood of the Set being modified while an Iterator might be active.
-     *  This returns an unmodifiable reference to the actual Set containing
-     *  the delegate's listeners. Any attempt to modify the Set will throw an
-     *  {@link java.lang.UnsupportedOperationException}. This method is not
-     *  synchronized and it should be understood that the composition of the
-     *  backing Set may change at any time.
+     *  This method returns a Set rather than an Iterator because of the high likelihood of the Set being modified while an
+     *  Iterator might be active. This returns an unmodifiable reference to the actual Set containing the delegate's listeners.
+     *  Any attempt to modify the Set will throw an {@link java.lang.UnsupportedOperationException}. This method is not
+     *  synchronized and it should be understood that the composition of the backing Set may change at any time.
      *  </p>
      *
      * @param client   the client of the event source
      * @return an unmodifiable Set containing the WikiEventListeners attached to the client
      * @throws java.lang.UnsupportedOperationException  if any attempt is made to modify the Set
      */
-    public static Set<WikiEventListener> getWikiEventListeners( Object client )
-        throws UnsupportedOperationException
-    {
-        WikiEventDelegate delegate = getInstance().getDelegateFor(client);
+    public static Set<WikiEventListener> getWikiEventListeners( final Object client ) throws UnsupportedOperationException {
+        final WikiEventDelegate delegate = getInstance().getDelegateFor(client);
         return delegate.getWikiEventListeners();
     }
 
-
     /**
-     *  Un-registers a WikiEventListener from any WikiEventDelegate client managed by this
-     *  WikiEventManager. Since this is a one-to-one relation, the first match will be
-     *  returned upon removal; a true return value indicates the WikiEventListener was
-     *  found and removed.
+     *  Un-registers a WikiEventListener from any WikiEventDelegate client managed by this WikiEventManager. Since this is a one-to-one
+     *  relation, the first match will be returned upon removal; a true return value indicates the WikiEventListener was found and removed.
      *
      * @param listener the event listener
      * @return true if the listener was found and removed.
      */
-    public static boolean removeWikiEventListener( WikiEventListener listener )
-    {
+    public static boolean removeWikiEventListener( final WikiEventListener listener ) {
         // get the Map.entry object for the entire Map, then check match on entry (listener)
-        WikiEventManager mgr = getInstance();
-        Map< Object, WikiEventDelegate > sources = mgr.getDelegates();
-        synchronized( sources )
-        {
+        final WikiEventManager mgr = getInstance();
+        final Map< Object, WikiEventDelegate > sources = mgr.getDelegates();
+        synchronized( sources ) {
             // get an iterator over the Map.Enty objects in the map
-            Iterator< Map.Entry< Object, WikiEventDelegate > > it = sources.entrySet().iterator();
-            while( it.hasNext() )
-            {
-                Map.Entry< Object, WikiEventDelegate > entry = it.next();
+            final Iterator< Map.Entry< Object, WikiEventDelegate > > it = sources.entrySet().iterator();
+            while( it.hasNext() ) {
+                final Map.Entry< Object, WikiEventDelegate > entry = it.next();
                 // the entry value is the delegate
-                WikiEventDelegate delegate = (WikiEventDelegate)entry.getValue();
+                final WikiEventDelegate delegate = entry.getValue();
 
-                // now see if we can remove the listener from the delegate
-                // (delegate may be null because this is a weak reference)
-                if( delegate != null && delegate.removeWikiEventListener(listener) )
-                {
+                // now see if we can remove the listener from the delegate (delegate may be null because this is a weak reference)
+                if( delegate != null && delegate.removeWikiEventListener(listener) ) {
                     return true; // was removed
                 }
             }
@@ -324,87 +257,65 @@ public final class WikiEventManager
         return false;
     }
 
-
     /**
-     *  Returns true if there are one or more listeners registered with
-     *  the provided client Object (undelegated event source). This locates
+     *  Returns true if there are one or more listeners registered with the provided client Object (undelegated event source). This locates
      *  any delegate and checks to see if it has any listeners attached.
      *
      *  @param client the client Object
      *  @return True, if there is a listener for this client object.
      */
-    public static boolean isListening( Object client )
-    {
-        WikiEventDelegate source = getInstance().getDelegateFor(client);
-        return source != null ? source.isListening() : false ;
+    public static boolean isListening( final Object client ) {
+        return getInstance().getDelegateFor( client ).isListening();
     }
 
-
     /**
-     *  Notify all listeners of the WikiEventDelegate having a registered
-     *  interest in change events of the supplied WikiEvent.
+     *  Notify all listeners of the WikiEventDelegate having a registered interest in change events of the supplied WikiEvent.
      *
      * @param client the client initiating the event.
      * @param event  the WikiEvent to fire.
      */
-    public static void fireEvent( Object client, WikiEvent event )
-    {
-        WikiEventDelegate source = getInstance().getDelegateFor(client);
-        if ( source != null ) source.fireEvent(event);
-        if ( c_monitor != null ) c_monitor.actionPerformed(event);
+    public static void fireEvent( final Object client, final WikiEvent event ) {
+        final WikiEventDelegate source = getInstance().getDelegateFor( client );
+        source.fireEvent( event );
+        if( c_monitor != null ) {
+            c_monitor.actionPerformed( event );
+        }
     }
 
-
     // private and utility methods .............................................
 
-
     /**
      *  Return the client-to-delegate Map.
      */
-    private Map< Object, WikiEventDelegate > getDelegates()
-    {
+    private Map< Object, WikiEventDelegate > getDelegates() {
         return m_delegates;
     }
 
-
     /**
-     *  Returns a WikiEventDelegate for the provided client Object.
-     *  If the parameter is a class reference, will generate and return a
-     *  client-less WikiEventDelegate. If the parameter is not a Class and
-     *  the delegate cache contains any objects matching the Class of any
-     *  delegates in the cache, the first Class-matching delegate will be
-     *  used in preference to creating a new delegate.
-     *  If a null parameter is supplied, this will create a client-less
-     *  delegate that will attach to the first incoming client (i.e.,
+     *  Returns a WikiEventDelegate for the provided client Object. If the parameter is a class reference, will generate and return a
+     *  client-less WikiEventDelegate. If the parameter is not a Class and the delegate cache contains any objects matching the Class
+     *  of any delegates in the cache, the first Class-matching delegate will be used in preference to creating a new delegate.
+     *  If a null parameter is supplied, this will create a client-less delegate that will attach to the first incoming client (i.e.,
      *  there will be no Class-matching requirement).
      *
      * @param client   the client Object, or alternately a Class reference
      * @return the WikiEventDelegate.
      */
-    private WikiEventDelegate getDelegateFor( Object client )
-    {
-        synchronized( m_delegates )
-        {
-            if( client == null || client instanceof Class ) // then preload the cache
-            {
-                WikiEventDelegate delegate = new WikiEventDelegate(client);
-                m_preloadCache.add(delegate);
+    private WikiEventDelegate getDelegateFor( final Object client ) {
+        synchronized( m_delegates ) {
+            if( client == null || client instanceof Class ) { // then preload the cache
+                final WikiEventDelegate delegate = new WikiEventDelegate( client );
+                m_preloadCache.add( delegate );
                 m_delegates.put( client, delegate );
                 return delegate;
-            }
-            else if( !m_preloadCache.isEmpty() )
-            {
+            } else if( !m_preloadCache.isEmpty() ) {
                 // then see if any of the cached delegates match the class of the incoming client
-                for( int i = m_preloadCache.size()-1 ; i >= 0 ; i-- ) // start with most-recently added
-                {
-                    WikiEventDelegate delegate = m_preloadCache.elementAt(i);
-                    if( delegate.getClientClass() == null
-                        || delegate.getClientClass().equals(client.getClass()) )
-                    {
+                for( int i = m_preloadCache.size()-1 ; i >= 0 ; i-- ) { // start with most-recently added
+                    final WikiEventDelegate delegate = m_preloadCache.elementAt( i );
+                    if( delegate.getClientClass() == null || delegate.getClientClass().equals( client.getClass() ) ) {
                         // we have a hit, so use it, but only on a client we haven't seen before
-                        if( !m_delegates.keySet().contains(client) )
-                        {
-                            m_preloadCache.remove(delegate);
+                        if( !m_delegates.containsKey( client ) ) {
+                            m_preloadCache.remove( delegate );
                             m_delegates.put( client, delegate );
                             return delegate;
                         }
@@ -413,8 +324,7 @@ public final class WikiEventManager
             }
             // otherwise treat normally...
             WikiEventDelegate delegate = m_delegates.get( client );
-            if( delegate == null )
-            {
+            if( delegate == null ) {
                 delegate = new WikiEventDelegate( client );
                 m_delegates.put( client, delegate );
             }
@@ -425,108 +335,80 @@ public final class WikiEventManager
 
     // .........................................................................
 
-
     /**
-     *  Inner delegating class that manages event listener addition and
-     *  removal. Classes that generate events can obtain an instance of
-     *  this class from the WikiEventManager and delegate responsibility
-     *  to it. Interaction with this delegating class is done via the
+     *  Inner delegating class that manages event listener addition and removal. Classes that generate events can obtain an instance of
+     *  this class from the WikiEventManager and delegate responsibility to it. Interaction with this delegating class is done via the
      *  methods of the {@link WikiEventDelegate} API.
      *
      * @since 2.4.20
      */
-    private static final class WikiEventDelegate
-    {
-        /* A list of event listeners for this instance. */
-
-        private ArrayList<WeakReference<WikiEventListener>> m_listenerList = new ArrayList<>();
+    private static final class WikiEventDelegate {
 
+        /* A list of event listeners for this instance. */
+        private final ArrayList< WeakReference< WikiEventListener > > m_listenerList = new ArrayList<>();
         private Class< ? >  m_class  = null;
 
         /**
-         *  Constructor for an WikiEventDelegateImpl, provided
-         *  with the client Object it will service, or the Class
-         *  of client, the latter when used to preload a future
-         *  incoming delegate.
+         *  Constructor for an WikiEventDelegateImpl, provided with the client Object it will service, or the Class
+         *  of client, the latter when used to preload a future incoming delegate.
          */
-        protected WikiEventDelegate( Object client )
-        {
-            if( client instanceof Class )
-            {
-                m_class = (Class< ? >)client;
+        protected WikiEventDelegate( final Object client ) {
+            if( client instanceof Class ) {
+                m_class = ( Class< ? > )client;
             }
         }
 
         /**
-         *  Returns the class of the client-less delegate, null if
-         *  this delegate is attached to a client Object.
+         *  Returns the class of the client-less delegate, null if this delegate is attached to a client Object.
          */
-        protected Class< ? > getClientClass()
-        {
+        protected Class< ? > getClientClass() {
             return m_class;
         }
 
-
         /**
-         *  Return an unmodifiable Set containing the WikiEventListeners of
-         *  this WikiEventDelegateImpl. If there are no attached listeners,
+         *  Return an unmodifiable Set containing the WikiEventListeners of this WikiEventDelegateImpl. If there are no attached listeners,
          *  returns an empty Set rather than null.
          *
          * @return an unmodifiable Set containing this delegate's WikiEventListeners
          * @throws java.lang.UnsupportedOperationException  if any attempt is made to modify the Set
          */
-        public Set<WikiEventListener> getWikiEventListeners()
-        {
-            synchronized( m_listenerList )
-            {
-                TreeSet<WikiEventListener> set = new TreeSet<>( new WikiEventListenerComparator() );
-
-                for( Iterator< WeakReference< WikiEventListener > >  i = m_listenerList.iterator(); i.hasNext(); )
-                {
-                    WikiEventListener l = i.next().get();
-
-                    if( l != null )
-                    {
+        public Set< WikiEventListener > getWikiEventListeners() {
+            synchronized( m_listenerList ) {
+                final TreeSet< WikiEventListener > set = new TreeSet<>( new WikiEventListenerComparator() );
+                for( final Iterator< WeakReference< WikiEventListener > >  i = m_listenerList.iterator(); i.hasNext(); ) {
+                    final WikiEventListener l = i.next().get();
+                    if( l != null ) {
                         set.add( l );
                     }
                 }
 
-                return Collections.unmodifiableSet(set);
+                return Collections.unmodifiableSet( set );
             }
         }
 
-
         /**
          *  Adds <tt>listener</tt> as a listener for events fired by the WikiEventDelegate.
          *
          * @param listener   the WikiEventListener to be added
          * @return true if the listener was added (i.e., it was not already in the list and was added)
          */
-        public boolean addWikiEventListener( WikiEventListener listener )
-        {
-            synchronized( m_listenerList )
-            {
+        public boolean addWikiEventListener( final WikiEventListener listener ) {
+            synchronized( m_listenerList ) {
                 return m_listenerList.add( new WeakReference<>(listener) );
             }
         }
 
-
         /**
          *  Removes <tt>listener</tt> from the WikiEventDelegate.
          *
          * @param listener   the WikiEventListener to be removed
          * @return true if the listener was removed (i.e., it was actually in the list and was removed)
          */
-        public boolean removeWikiEventListener( WikiEventListener listener )
-        {
-            synchronized( m_listenerList )
-            {
-                for( Iterator< WeakReference< WikiEventListener > > i = m_listenerList.iterator(); i.hasNext(); )
-                {
-                    WikiEventListener l = i.next().get();
-
-                    if( l == listener )
-                    {
+        public boolean removeWikiEventListener( final WikiEventListener listener ) {
+            synchronized( m_listenerList ) {
+                for( final Iterator< WeakReference< WikiEventListener > > i = m_listenerList.iterator(); i.hasNext(); ) {
+                    final WikiEventListener l = i.next().get();
+                    if( l == listener ) {
                         i.remove();
                         return true;
                     }
@@ -536,82 +418,59 @@ public final class WikiEventManager
             return false;
         }
 
-
         /**
-         *  Returns true if there are one or more listeners registered
-         *  with this instance.
+         *  Returns true if there are one or more listeners registered with this instance.
          */
-        public boolean isListening()
-        {
-            synchronized( m_listenerList )
-            {
+        public boolean isListening() {
+            synchronized( m_listenerList ) {
                 return !m_listenerList.isEmpty();
             }
         }
 
-
         /**
-         *  Notify all listeners having a registered interest
-         *  in change events of the supplied WikiEvent.
+         *  Notify all listeners having a registered interest in change events of the supplied WikiEvent.
          */
-        public void fireEvent( WikiEvent event )
-        {
+        public void fireEvent( final WikiEvent event ) {
             boolean needsCleanup = false;
-
-            try
-            {
-                synchronized( m_listenerList )
-                {
-                    for( int i = 0; i < m_listenerList.size(); i++ )
-                    {
-                        WikiEventListener listener = m_listenerList.get( i ).get();
-
-                        if( listener != null )
-                        {
+            try {
+                synchronized( m_listenerList ) {
+                    for( int i = 0; i < m_listenerList.size(); i++ ) {
+                        final WikiEventListener listener = m_listenerList.get( i ).get();
+                        if( listener != null ) {
                             listener.actionPerformed( event );
-                        }
-                        else
-                        {
+                        } else {
                             needsCleanup  = true;
                         }
                     }
 
-                    //
                     //  Remove all such listeners which have expired
-                    //
-                    if( needsCleanup )
-                    {
-                        for( int i = 0; i < m_listenerList.size(); i++ )
-                        {
-                            WeakReference< WikiEventListener > w = m_listenerList.get( i );
-
-                            if( w.get() == null ) m_listenerList.remove(i--);
+                    if( needsCleanup ) {
+                        for( int i = 0; i < m_listenerList.size(); i++ ) {
+                            final WeakReference< WikiEventListener > w = m_listenerList.get( i );
+                            if( w.get() == null ) {
+                                m_listenerList.remove(i--);
+                            }
                         }
                     }
 
                 }
-            }
-            catch( ConcurrentModificationException e )
-            {
-                //
+            } catch( final ConcurrentModificationException e ) {
                 //  We don't die, we just don't do notifications in that case.
-                //
-                log.info("Concurrent modification of event list; please report this.",e);
+                log.info( "Concurrent modification of event list; please report this.", e );
             }
-
         }
+    }
 
-    } // end inner class WikiEventDelegate
-
-    private static class WikiEventListenerComparator implements Comparator<WikiEventListener>
-    {
+    private static class WikiEventListenerComparator implements Comparator< WikiEventListener > {
         // TODO: This method is a critical performance bottleneck
         @Override
-        public int compare(WikiEventListener w0, WikiEventListener w1)
-        {
-            if( w1 == w0 || w0.equals(w1) ) return 0;
+        public int compare( final WikiEventListener w0, final WikiEventListener w1 ) {
+            if( w1 == w0 || w0.equals( w1 ) ) {
+                return 0;
+            }
 
             return w1.hashCode() - w0.hashCode();
         }
     }
-} // end org.apache.wiki.event.WikiEventManager
+
+}


[jspwiki] 29/32: remove WikiEventUtils

Posted by ju...@apache.org.
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 7782b72af40871cf08414c90d8df99247c182f8a
Author: juanpablo <ju...@apache.org>
AuthorDate: Tue Jan 28 21:16:15 2020 +0100

    remove WikiEventUtils
    
    as it was barely used and it basically was a synonym for WikiEventManager.getInstance().addWikiEventListener( client, listener ). While at it, on SearchManager we apply formatting and fixes from intellij
---
 .../java/org/apache/wiki/event/WikiEventUtils.java | 135 ------------------
 .../wiki/references/DefaultReferenceManager.java   |   4 +-
 .../wiki/render/DefaultRenderingManager.java       |   4 +-
 .../java/org/apache/wiki/search/SearchManager.java | 151 ++++++++++-----------
 4 files changed, 74 insertions(+), 220 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java
deleted file mode 100644
index 4d54d7c..0000000
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java
+++ /dev/null
@@ -1,135 +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.event;
-
-import org.apache.wiki.WikiEngine;
-
-/**
- *  A utility class that adds some JSPWiki-specific functionality to the WikiEventManager (which is really a general-purpose event manager).
- *
- * @since 2.4.20
- */
-public class WikiEventUtils {
-
-    /**
-     *  This ungainly convenience method adds a WikiEventListener to the appropriate component of the provided client Object, to listen
-     *  for events of the provided type (or related types, see the table below).
-     *  <p>
-     *  If the type value is valid but does not match any WikiEvent type known to this method, this will just attach the listener to the
-     *  client Object. This may mean that the Object never fires events of the desired type; type-to-client matching is left to you to
-     *  guarantee. Silence is golden, but not if you want those events.
-     *  </p>
-     *  <p>
-     *  Most event types expect a WikiEngine as the client, with the rest attaching the listener directly to the supplied source object, as
-     *  described below:
-     *  </p>
-     *  <table border="1" cellpadding="4">
-     *    <tr><th>WikiEvent Type(s)                          </th><th>Required Source Object    </th><th>Actually Attached To </th></tr>
-     *    <tr><td>any WikiEngineEvent                        </td><td>WikiEngine                </td><td>WikiEngine           </td></tr>
-     *    <tr><td>WikiPageEvent.PAGE_LOCK,
-     *            WikiPageEvent.PAGE_UNLOCK                  </td><td>WikiEngine or PageManager </td><td>PageManager          </td></tr>
-     *    <tr><td>WikiPageEvent.PAGE_REQUESTED,
-     *            WikiPageEvent.PAGE_DELIVERED               </td><td>WikiServletFilter         </td><td>WikiServletFilter    </td></tr>
-     *    <tr><td>WikiPageEvent (<a href="#pbeTypes">phase
-     *                                     boundary event</a>)</td><td>WikiEngine               </td><td>FilterManager         </td></tr>
-     *    <tr><td>WikiPageEvent (<a href="#ipeTypes">in-phase
-     *                                              event</a>)</td><td>WikiEngine               </td><td>WikiEngine            </td></tr>
-     *    <tr><td>WikiPageEvent (in-phase event)              </td><td>any                      </td><td>source object         </td></tr>
-     *    <tr><td>WikiSecurityEvent                           </td><td>any                      </td><td>source object         </td></tr>
-     *    <tr><td>any other valid type                        </td><td>any                      </td><td>source object         </td></tr>
-     *    <tr><td>any invalid type                            </td><td>any                      </td><td>nothing               </td></tr>
-     *  </table>
-     *
-     * <p id="pbeTypes"><small><b>phase boundary event types:</b>
-     * <tt>WikiPageEvent.PRE_TRANSLATE_BEGIN</tt>, <tt>WikiPageEvent.PRE_TRANSLATE_END</tt>, <tt>WikiPageEvent.POST_TRANSLATE_BEGIN</tt>,
-     * <tt>WikiPageEvent.POST_TRANSLATE_END</tt>, <tt>WikiPageEvent.PRE_SAVE_BEGIN</tt>, <tt>WikiPageEvent.PRE_SAVE_END</tt>,
-     * <tt>WikiPageEvent.POST_SAVE_BEGIN</tt>, and <tt>WikiPageEvent.POST_SAVE_END</tt>.
-     * </small></p>
-     * <p id="ipeTypes"><small><b>in-phase event types:</b>
-     * <tt>WikiPageEvent.PRE_TRANSLATE</tt>, <tt>WikiPageEvent.POST_TRANSLATE</tt>, <tt>WikiPageEvent.PRE_SAVE</tt>, and
-     * <tt>WikiPageEvent.POST_SAVE</tt>.
-     * </small></p>
-     *
-     * <p>
-     * <b>Note:</b> The <i>Actually Attached To</i> column may also be considered as the class(es) that fire events of the type(s)
-     * shown in the <i>WikiEvent Type</i> column.
-     * </p>
-     *
-     * @see org.apache.wiki.event.WikiEvent
-     * @see org.apache.wiki.event.WikiEngineEvent
-     * @see org.apache.wiki.event.WikiPageEvent
-     * @see org.apache.wiki.event.WikiSecurityEvent
-     * @throws ClassCastException if there is a type mismatch between certain event types and the client Object
-     */
-    public static synchronized void addWikiEventListener( final Object client, final int type, final WikiEventListener listener ) {
-        // Make sure WikiEventManager exists
-        WikiEventManager.getInstance();
-        
-        // first, figure out what kind of event is expected to be generated this does
-        // tie us into known types, but WikiEvent.isValidType() will return true so
-        // long as the type was set to any non-ERROR or non-UNKNOWN value
-
-        if( WikiEngineEvent.isValidType( type ) ) {
-            // add listener directly to WikiEngine
-            WikiEventManager.addWikiEventListener( client, listener );
-        } else if( WikiPageEvent.isValidType( type ) ) {
-            // add listener to one of several options
-            if(  type == WikiPageEvent.PAGE_LOCK
-              || type == WikiPageEvent.PAGE_UNLOCK ) {
-                // attach to PageManager
-                if( client instanceof WikiEngine ) {
-                    WikiEventManager.addWikiEventListener( ((WikiEngine)client).getPageManager(), listener );
-                } else {
-                    // client instanceof PageManager
-                    WikiEventManager.addWikiEventListener( client, listener );
-                }
-            } else if(  type == WikiPageEvent.PAGE_REQUESTED
-                     || type == WikiPageEvent.PAGE_DELIVERED ) {
-                // attach directly to WikiServletFilter
-                WikiEventManager.addWikiEventListener( client, listener );
-            }
-            else if(  type == WikiPageEvent.PRE_TRANSLATE_BEGIN
-                   || type == WikiPageEvent.PRE_TRANSLATE_END
-                   || type == WikiPageEvent.POST_TRANSLATE_BEGIN
-                   || type == WikiPageEvent.POST_TRANSLATE_END
-                   || type == WikiPageEvent.PRE_SAVE_BEGIN
-                   || type == WikiPageEvent.PRE_SAVE_END
-                   || type == WikiPageEvent.POST_SAVE_BEGIN
-                   || type == WikiPageEvent.POST_SAVE_END ) {
-                // attach to FilterManager
-                WikiEventManager.addWikiEventListener( ((WikiEngine)client).getFilterManager(), listener );
-            } else { //if (  type == WikiPageEvent.PRE_TRANSLATE
-                     //   || type == WikiPageEvent.POST_TRANSLATE
-                     //   || type == WikiPageEvent.PRE_SAVE
-                     //   || type == WikiPageEvent.POST_SAVE ) // attach to client
-                WikiEventManager.addWikiEventListener( client, listener );
-            }
-        } else if( WikiSecurityEvent.isValidType( type ) ) {
-            // currently just attach it to the client (we are ignorant of other options)
-            WikiEventManager.addWikiEventListener( client, listener );
-        } else if( WikiEvent.isValidType( type ) ) {
-            // we don't know what to do
-            WikiEventManager.addWikiEventListener( client, listener );
-        } else {
-            // is error or unknown, why are we being called with this?
-        }
-    }
-
-}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java
index e073b7f..5ebe5cc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java
@@ -30,7 +30,7 @@ import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.event.WikiEvent;
-import org.apache.wiki.event.WikiEventUtils;
+import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.providers.WikiPageProvider;
 import org.apache.wiki.util.TextUtil;
@@ -234,7 +234,7 @@ public class DefaultReferenceManager extends BasicPageFilter implements Referenc
         sw.stop();
         log.info( "Cross reference scan done in "+sw );
 
-        WikiEventUtils.addWikiEventListener( m_engine.getPageManager(), WikiPageEvent.PAGE_DELETED, this );
+        WikiEventManager.getInstance().addWikiEventListener( m_engine.getPageManager(), this );
     }
 
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java b/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
index cd1117a..c260455 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
@@ -33,7 +33,7 @@ import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
-import org.apache.wiki.event.WikiEventUtils;
+import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.parser.JSPWikiMarkupParser;
@@ -128,7 +128,7 @@ public class DefaultRenderingManager implements RenderingManager {
 
         log.info( "Rendering content with " + renderImplName + "." );
 
-        WikiEventUtils.addWikiEventListener(m_engine, WikiPageEvent.POST_SAVE_BEGIN, this);
+        WikiEventManager.getInstance().addWikiEventListener( m_engine.getFilterManager(),this );
     }
 
     private Constructor< ? > initRenderer( final String renderImplName, final Class< ? >[] rendererParams ) throws WikiException {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
index ac256fe..2d975f4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
@@ -33,7 +33,7 @@ import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
-import org.apache.wiki.event.WikiEventUtils;
+import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.modules.InternalModule;
 import org.apache.wiki.parser.MarkupParser;
@@ -59,18 +59,16 @@ import java.util.Set;
  */
 public class SearchManager extends BasicPageFilter implements InternalModule, WikiEventListener {
 
-    private static final Logger log = Logger.getLogger(SearchManager.class);
+    private static final Logger log = Logger.getLogger( SearchManager.class );
 
     private static final String DEFAULT_SEARCHPROVIDER  = "org.apache.wiki.search.LuceneSearchProvider";
 
     /** Property name for setting the search provider. Value is <tt>{@value}</tt>. */
-    public static final String PROP_SEARCHPROVIDER     = "jspwiki.searchProvider";
+    public static final String PROP_SEARCHPROVIDER      = "jspwiki.searchProvider";
 
     private SearchProvider    m_searchProvider;
 
-    /**
-     *  The name of the JSON object that manages search.
-     */
+    /** The name of the JSON object that manages search. */
     public static final String JSON_SEARCH = "search";
 
     /**
@@ -80,13 +78,9 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
      *  @param properties The list of Properties.
      *  @throws FilterException If it cannot be instantiated.
      */
-    public SearchManager( WikiEngine engine, Properties properties )
-        throws FilterException
-    {
+    public SearchManager( final WikiEngine engine, final Properties properties ) throws FilterException {
         initialize( engine, properties );
-
-        WikiEventUtils.addWikiEventListener(m_engine.getPageManager(),
-                                            WikiPageEvent.PAGE_DELETE_REQUEST, this);
+        WikiEventManager.getInstance().addWikiEventListener( m_engine.getPageManager(), this );
 
         //TODO: Replace with custom annotations. See JSPWIKI-566
         WikiAjaxDispatcherServlet.registerServlet( JSON_SEARCH, new JSONSearch() );
@@ -95,57 +89,54 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
     /**
      *  Provides a JSON RPC API to the JSPWiki Search Engine.
      */
-    public class JSONSearch implements WikiAjaxServlet
-    {
-		public static final String AJAX_ACTION_SUGGESTIONS = "suggestions";
-    	public static final String AJAX_ACTION_PAGES = "pages";
-    	public static final int DEFAULT_MAX_RESULTS = 20;
-    	public int maxResults = DEFAULT_MAX_RESULTS;
-
-		@Override
-		public String getServletMapping() {
-			return JSON_SEARCH;
-		}
-
-    	@Override
-    	public void service(HttpServletRequest req, HttpServletResponse resp, String actionName, List<String> params)
-    			throws ServletException, IOException {
-    		String result = "";
-    		if (StringUtils.isNotBlank(actionName)) {
-    			if (params.size()<1) {
-    				return;
-    			}
-    			String itemId = params.get(0);
-    			log.debug("itemId="+itemId);
-    			if (params.size()>1) {
-    				String maxResultsParam  = params.get(1);
-    				log.debug("maxResultsParam="+maxResultsParam);
-    				if (StringUtils.isNotBlank(maxResultsParam) && StringUtils.isNumeric(maxResultsParam)) {
-    					maxResults = Integer.parseInt(maxResultsParam);
-    				}
-    			}
-
-    			if (actionName.equals(AJAX_ACTION_SUGGESTIONS)) {
-    				List<String> callResults = new ArrayList<>();
-    				log.debug("Calling getSuggestions() START");
-    				callResults = getSuggestions(itemId, maxResults);
-    				log.debug("Calling getSuggestions() DONE. "+callResults.size());
-    				result = AjaxUtil.toJson(callResults);
-    			} else if (actionName.equals(AJAX_ACTION_PAGES)) {
-    				final List< Map< String, Object > > callResults;
-    				log.debug("Calling findPages() START");
-    				final WikiContext wikiContext = new WikiContext( m_engine, req, WikiContext.VIEW );
-    				if( wikiContext == null ) {
-    					throw new ServletException( "Could not create a WikiContext from the request " + req );
-    				}
-    				callResults = findPages(itemId, maxResults, wikiContext);
-    				log.debug("Calling findPages() DONE. "+callResults.size());
-    				result = AjaxUtil.toJson(callResults);
-    			}
-    		}
-    		log.debug("result="+result);
-    		resp.getWriter().write(result);
-    	}
+    public class JSONSearch implements WikiAjaxServlet {
+
+        public static final String AJAX_ACTION_SUGGESTIONS = "suggestions";
+        public static final String AJAX_ACTION_PAGES = "pages";
+        public static final int DEFAULT_MAX_RESULTS = 20;
+        public int maxResults = DEFAULT_MAX_RESULTS;
+
+        @Override
+        public String getServletMapping() {
+            return JSON_SEARCH;
+        }
+
+        @Override
+        public void service( final HttpServletRequest req,
+                             final HttpServletResponse resp,
+                             final String actionName,
+                             final List< String > params ) throws ServletException, IOException {
+            String result = "";
+            if( StringUtils.isNotBlank( actionName ) ) {
+                if( params.size() < 1 ) {
+                    return;
+                }
+                final String itemId = params.get( 0 );
+                log.debug( "itemId=" + itemId );
+                if( params.size() > 1 ) {
+                    final String maxResultsParam = params.get( 1 );
+                    log.debug( "maxResultsParam=" + maxResultsParam );
+                    if( StringUtils.isNotBlank( maxResultsParam ) && StringUtils.isNumeric( maxResultsParam ) ) {
+                        maxResults = Integer.parseInt( maxResultsParam );
+                    }
+                }
+
+                if( actionName.equals( AJAX_ACTION_SUGGESTIONS ) ) {
+                    log.debug( "Calling getSuggestions() START" );
+                    final List< String > callResults = getSuggestions( itemId, maxResults );
+                    log.debug( "Calling getSuggestions() DONE. " + callResults.size() );
+                    result = AjaxUtil.toJson( callResults );
+                } else if( actionName.equals( AJAX_ACTION_PAGES ) ) {
+                    log.debug("Calling findPages() START");
+                    final WikiContext wikiContext = new WikiContext( m_engine, req, WikiContext.VIEW );
+                    final List< Map< String, Object > > callResults = findPages( itemId, maxResults, wikiContext );
+                    log.debug( "Calling findPages() DONE. " + callResults.size() );
+                    result = AjaxUtil.toJson( callResults );
+                }
+            }
+            log.debug( "result=" + result );
+            resp.getWriter().write( result );
+        }
 
         /**
          *  Provides a list of suggestions to use for a page name. Currently the algorithm just looks into the value parameter,
@@ -155,16 +146,15 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
          *  @param maxLength maximum number of suggestions
          *  @return the suggestions
          */
-        public List<String> getSuggestions( String wikiName, final int maxLength ) {
+        public List< String > getSuggestions( String wikiName, final int maxLength ) {
             final StopWatch sw = new StopWatch();
             sw.start();
             final List< String > list = new ArrayList<>( maxLength );
 
             if( wikiName.length() > 0 ) {
-
                 // split pagename and attachment filename
                 String filename = "";
-                int pos = wikiName.indexOf("/");
+                final int pos = wikiName.indexOf("/");
                 if( pos >= 0 ) {
                     filename = wikiName.substring( pos ).toLowerCase();
                     wikiName = wikiName.substring( 0, pos );
@@ -175,7 +165,7 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
                 final Set< String > allPages = m_engine.getReferenceManager().findCreated();
 
                 int counter = 0;
-                for( Iterator< String > i = allPages.iterator(); i.hasNext() && counter < maxLength; ) {
+                for( final Iterator< String > i = allPages.iterator(); i.hasNext() && counter < maxLength; ) {
                     final String p = i.next();
                     final String pp = p.toLowerCase();
                     if( pp.startsWith( cleanWikiName) || pp.startsWith( oldStyleName ) ) {
@@ -199,39 +189,38 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
          *  @param maxLength How many hits to return
          *  @return the pages found
          */
-        public List<Map<String,Object>> findPages( String searchString, int maxLength, WikiContext wikiContext )
-        {
-            StopWatch sw = new StopWatch();
+        public List< Map< String, Object > > findPages( final String searchString, final int maxLength, final WikiContext wikiContext ) {
+            final StopWatch sw = new StopWatch();
             sw.start();
 
-            List<Map<String,Object>> list = new ArrayList<>(maxLength);
-
+            final List< Map< String, Object > > list = new ArrayList<>( maxLength );
             if( searchString.length() > 0 ) {
                 try {
-                    Collection< SearchResult > c;
+                    final Collection< SearchResult > c;
 
                     if( m_searchProvider instanceof LuceneSearchProvider ) {
-                        c = ((LuceneSearchProvider)m_searchProvider).findPages( searchString, 0, wikiContext );
+                        c = ( ( LuceneSearchProvider )m_searchProvider ).findPages( searchString, 0, wikiContext );
                     } else {
                         c = m_searchProvider.findPages( searchString, wikiContext );
                     }
 
                     int count = 0;
-                    for( Iterator< SearchResult > i = c.iterator(); i.hasNext() && count < maxLength; count++ )
-                    {
-                        SearchResult sr = i.next();
-                        HashMap<String,Object> hm = new HashMap<>();
+                    for( final Iterator< SearchResult > i = c.iterator(); i.hasNext() && count < maxLength; count++ ) {
+                        final SearchResult sr = i.next();
+                        final HashMap< String, Object > hm = new HashMap<>();
                         hm.put( "page", sr.getPage().getName() );
                         hm.put( "score", sr.getScore() );
                         list.add( hm );
                     }
-                } catch(Exception e) {
-                    log.info("AJAX search failed; ",e);
+                } catch( final Exception e ) {
+                    log.info( "AJAX search failed; ", e );
                 }
             }
 
             sw.stop();
-            if( log.isDebugEnabled() ) log.debug("AJAX search complete in "+sw);
+            if( log.isDebugEnabled() ) {
+                log.debug( "AJAX search complete in " + sw );
+            }
             return list;
         }
     }


[jspwiki] 21/32: JSPWIKI-1127: as a result, LinkTag no longer needs/uses absolute parameter

Posted by ju...@apache.org.
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 f7cf1a6275ac3e6da2dbbc2355c2e461da58a1f1
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 22 23:31:21 2020 +0100

    JSPWIKI-1127: as a result, LinkTag no longer needs/uses absolute parameter
---
 jspwiki-main/src/main/resources/META-INF/jspwiki.tld | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/jspwiki-main/src/main/resources/META-INF/jspwiki.tld b/jspwiki-main/src/main/resources/META-INF/jspwiki.tld
index aec00de..c33e038 100644
--- a/jspwiki-main/src/main/resources/META-INF/jspwiki.tld
+++ b/jspwiki-main/src/main/resources/META-INF/jspwiki.tld
@@ -386,10 +386,6 @@
        <rtexprvalue>true</rtexprvalue>
     </attribute>
     <attribute>
-       <name>absolute</name>
-       <rtexprvalue>true</rtexprvalue>
-    </attribute>
-    <attribute>
        <name>templatefile</name>
        <rtexprvalue>true</rtexprvalue>
     </attribute>


[jspwiki] 27/32: apply formatting fixes suggested by intellij

Posted by ju...@apache.org.
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 08eec1ee807bdf2edae8867aeea30c5c2cb67f45
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 24 00:56:29 2020 +0100

    apply formatting fixes suggested by intellij
---
 .../org/apache/wiki/event/WikiEngineEvent.java     |  63 ++++++-----
 .../main/java/org/apache/wiki/event/WikiEvent.java | 114 ++++++++------------
 .../org/apache/wiki/event/WikiEventListener.java   |   2 +-
 .../java/org/apache/wiki/event/WikiEventUtils.java | 120 ++++++++-------------
 .../org/apache/wiki/event/WikiPageRenameEvent.java |  55 ++++------
 .../org/apache/wiki/event/WikiSecurityEvent.java   | 101 +++++++----------
 .../java/org/apache/wiki/event/WorkflowEvent.java  |  13 ++-
 7 files changed, 186 insertions(+), 282 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
index fed4cd0..7cb6758 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
@@ -31,47 +31,45 @@ public class WikiEngineEvent extends WikiEvent {
 
     private static final long serialVersionUID = 1829433967558773970L;
 
-    /** Indicates a WikiEngine initialization event, fired as the 
-      * wiki service is being initialized (in progress). */
+    /** Indicates a WikiEngine initialization event, fired as the  wiki service is being initialized (in progress). */
     public static final int INITIALIZING   = -1;
 
-    /** Indicates a WikiEngine initialized event, fired after the 
-      * wiki service is fully available. */
+    /** Indicates a WikiEngine initialized event, fired after the  wiki service is fully available. */
     public static final int INITIALIZED    = 0;
 
-    /** Indicates a WikiEngine closing event, fired as a signal that
-      * the wiki service is shutting down. */
+    /** Indicates a WikiEngine closing event, fired as a signal that the wiki service is shutting down. */
     public static final int SHUTDOWN       = 1;
 
-    /** Indicates a WikiEngine stopped event, fired after halting the wiki service.
-      * A WikiEngine in this state is not expected to provide further services. 
-      */
+    /**
+     * Indicates a WikiEngine stopped event, fired after halting the wiki service.
+     * A WikiEngine in this state is not expected to provide further services.
+     */
     public static final int STOPPED        = 2;
 
     private WikiEngine m_engine;
 
      /**
       *  Constructs an instance of this event.
-      * @param eventSource  the Object that is the source of the event,
-      * which <b>must</b> be the WikiEngine. If it is not, this
+      *
+      * @param eventSource  the Object that is the source of the event, which <b>must</b> be the WikiEngine. If it is not, this
       * method thows a ClassCastException
       * @param type the event type
       */
-    public WikiEngineEvent( Object eventSource, int type ) {
+    public WikiEngineEvent( final Object eventSource, final int type ) {
         super( eventSource, type );
-        m_engine = (WikiEngine)eventSource;
+        m_engine = ( WikiEngine )eventSource;
     }
 
     /**
      *  Sets the type of this event.
      *
-     * @param type      the type of this WikiEngineEvent.
+     * @param type the type of this WikiEngineEvent.
      */
-    protected void setType( int type ) {
-        if ( type >= INITIALIZING && type <= STOPPED ) {
-            super.setType(type);
+    protected void setType( final int type ) {
+        if( type >= INITIALIZING && type <= STOPPED ) {
+            super.setType( type );
         } else {
-            super.setType(ERROR);
+            super.setType( ERROR );
         }
     }
 
@@ -80,18 +78,17 @@ public class WikiEngineEvent extends WikiEvent {
      *
      * @return  the WikiEngine that spawned this event.
      */
-    public WikiEngine getEngine()
-    {
+    public WikiEngine getEngine() {
         return m_engine;
     }
 
-   /**
+    /**
      * Returns <code>true</code> if the int value is a WikiPageEvent type.
+     *
      * @param type the event type
      * @return the result
      */
-    public static boolean isValidType( int type )
-    {
+    public static boolean isValidType( final int type ) {
         return type >= INITIALIZING && type <= STOPPED;
     }
 
@@ -102,11 +99,11 @@ public class WikiEngineEvent extends WikiEvent {
      */
     public final String eventName() {
         switch ( getType() ) {
-            case INITIALIZING:         return "INITIALIZING";
-            case INITIALIZED:          return "INITIALIZED";
-            case SHUTDOWN:             return "SHUTDOWN";
-            case STOPPED:              return "STOPPED";
-            default:                   return super.eventName();
+            case INITIALIZING: return "INITIALIZING";
+            case INITIALIZED:  return "INITIALIZED";
+            case SHUTDOWN:     return "SHUTDOWN";
+            case STOPPED:      return "STOPPED";
+            default:           return super.eventName();
         }
     }
 
@@ -117,11 +114,11 @@ public class WikiEngineEvent extends WikiEvent {
      */
     public final String getTypeDescription() {
         switch ( getType() ) {
-            case INITIALIZING:         return "wiki engine initializing";
-            case INITIALIZED:          return "wiki engine initialized";
-            case SHUTDOWN:             return "wiki engine shutting down";
-            case STOPPED:              return "wiki engine stopped";
-            default:                   return super.getTypeDescription();
+            case INITIALIZING: return "wiki engine initializing";
+            case INITIALIZED:  return "wiki engine initialized";
+            case SHUTDOWN:     return "wiki engine shutting down";
+            case STOPPED:      return "wiki engine stopped";
+            default:           return super.getTypeDescription();
         }
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEvent.java
index 22fcd5d..7ee9a96 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEvent.java
@@ -26,8 +26,8 @@ import java.util.EventObject;
  *
  * @since 2.3.79
  */
-public abstract class WikiEvent extends EventObject
-{
+public abstract class WikiEvent extends EventObject {
+
     private static final long serialVersionUID = 1829433967558773960L;
 
     /** Indicates a exception or error state. */
@@ -42,14 +42,13 @@ public abstract class WikiEvent extends EventObject
 
     // ............
 
-
-   /**
+    /**
      * Constructs an instance of this event.
+     *
      * @param src the Object that is the source of the event.
-     * @param type   the event type.
+     * @param type the event type.
      */
-    public WikiEvent( Object src, int type )
-    {
+    public WikiEvent( final Object src, final int type ) {
         super( src );
         m_when = System.currentTimeMillis();
         setType( type );
@@ -61,108 +60,85 @@ public abstract class WikiEvent extends EventObject
      * @return the typed object to which the event applied.
      */
     @SuppressWarnings("unchecked")
-    public <T> T getSrc()
-    {
-        return (T) super.getSource();
+    public < T > T getSrc() {
+        return ( T )super.getSource();
     }
 
+   /**
+    *  Returns the timestamp of when this WikiEvent occurred.
+    *
+    * @return this event's timestamp
+    * @since 2.4.74
+    */
+   public long getWhen() {
+       return m_when;
+   }
 
     /**
-     *  Returns the timestamp of when this WikiEvent occurred.
-     *
-     * @return this event's timestamp
-     * @since 2.4.74
-     */
-    public long getWhen()
-    {
-        return m_when;
-    }
-
-
-   /**
-     * Sets the type of this event. Validation of acceptable
-     * type values is the responsibility of each subclass.
+     * Sets the type of this event. Validation of acceptable type values is the responsibility of each subclass.
      *
-     * @param type      the type of this WikiEvent.
+     * @param type the type of this WikiEvent.
      */
-    protected void setType( int type )
-    {
+    protected void setType( final int type ) {
         m_type = type;
     }
 
-
-   /**
+    /**
      * Returns the type of this event.
      *
-     * @return  the type of this WikiEvent. See the enumerated values
-     *          defined in {@link org.apache.wiki.event.WikiEvent}).
+     * @return the type of this WikiEvent. See the enumerated values defined in {@link org.apache.wiki.event.WikiEvent}).
      */
-    public int getType()
-    {
+    public int getType() {
         return m_type;
     }
 
-
-   /** Returns a String (human-readable) description of an event type.
-     * This should be subclassed as necessary.
+    /**
+     * Returns a String (human-readable) description of an event type. This should be subclassed as necessary.
+     *
      * @return the String description
      */
-    public String getTypeDescription()
-    {
-        switch ( m_type )
-        {
-            case ERROR:                return "exception or error event";
-            case UNDEFINED:            return "undefined event type";
-            default:                   return "unknown event type (" + m_type + ")";
+    public String getTypeDescription() {
+        switch( m_type ) {
+            case ERROR:     return "exception or error event";
+            case UNDEFINED: return "undefined event type";
+            default:        return "unknown event type (" + m_type + ")";
         }
     }
 
-
-   /**
-     * Returns true if the int value is a valid WikiEvent type.
-     * Because the WikiEvent class does not itself any event types,
-     * this method returns true if the event type is anything except
-     * {@link #ERROR} or {@link #UNDEFINED}. This method is meant to
+    /**
+     * Returns true if the int value is a valid WikiEvent type. Because the WikiEvent class does not itself any event types,
+     * this method returns true if the event type is anything except {@link #ERROR} or {@link #UNDEFINED}. This method is meant to
      * be subclassed as appropriate.
      * 
      * @param type The value to test.
      * @return true, if the value is a valid WikiEvent type.
      */
-    public static boolean isValidType( int type )
-    {
+    public static boolean isValidType( final int type ) {
         return type != ERROR && type != UNDEFINED;
     }
 
 
     /**
      * Returns a textual representation of an event type.
+     *
      * @return the String representation
      */
-    public String eventName()
-    {
-        switch( m_type )
-        {
-            case ERROR:                return "ERROR";
-            case UNDEFINED:            return "UNDEFINED";
-            default:                   return "UNKNOWN (" + m_type + ")";
+    public String eventName() {
+        switch( m_type ) {
+            case ERROR:     return "ERROR";
+            case UNDEFINED: return "UNDEFINED";
+            default:        return "UNKNOWN (" + m_type + ")";
         }
     }
 
     /**
-     * Prints a String (human-readable) representation of this object.
-     * This should be subclassed as necessary.
+     * Prints a String (human-readable) representation of this object. This should be subclassed as necessary.
+     *
      * @see java.lang.Object#toString()
      * @return the String representation
      */
-    public String toString()
-    {
-    	StringBuilder out = new StringBuilder();
-        out.append( "WikiEvent." );
-        out.append( eventName() );
-        out.append( " [source=" );
-        out.append( getSource().toString() );
-        out.append( "]" );
-        return out.toString();
+    public String toString() {
+        return "WikiEvent." + eventName() + " [source=" + getSource().toString() + "]";
     }
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventListener.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventListener.java
index 6fbbfae..4f426c9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventListener.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventListener.java
@@ -29,7 +29,7 @@ import  java.util.EventListener;
   */
 public interface WikiEventListener extends EventListener {
 
-   /**
+    /**
      * Fired when a WikiEvent is triggered by an event source.
      *
      * @param event a WikiEvent object
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java
index 31cfd6b..4d54d7c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventUtils.java
@@ -22,65 +22,54 @@ package org.apache.wiki.event;
 import org.apache.wiki.WikiEngine;
 
 /**
- *  A utility class that adds some JSPWiki-specific functionality to the
- *  WikiEventManager (which is really a general-purpose event manager).
+ *  A utility class that adds some JSPWiki-specific functionality to the WikiEventManager (which is really a general-purpose event manager).
  *
  * @since 2.4.20
  */
-public class WikiEventUtils
-{
+public class WikiEventUtils {
+
     /**
-     *  This ungainly convenience method adds a WikiEventListener to the
-     *  appropriate component of the provided client Object, to listen
-     *  for events of the provided type (or related types, see the table
-     *  below).
+     *  This ungainly convenience method adds a WikiEventListener to the appropriate component of the provided client Object, to listen
+     *  for events of the provided type (or related types, see the table below).
      *  <p>
-     *  If the type value is valid but does not match any WikiEvent type
-     *  known to this method, this will just attach the listener to the
-     *  client Object. This may mean that the Object never fires events
-     *  of the desired type; type-to-client matching is left to you to
+     *  If the type value is valid but does not match any WikiEvent type known to this method, this will just attach the listener to the
+     *  client Object. This may mean that the Object never fires events of the desired type; type-to-client matching is left to you to
      *  guarantee. Silence is golden, but not if you want those events.
      *  </p>
      *  <p>
-     *  Most event types expect a WikiEngine as the client, with the rest
-     *  attaching the listener directly to the supplied source object, as
+     *  Most event types expect a WikiEngine as the client, with the rest attaching the listener directly to the supplied source object, as
      *  described below:
      *  </p>
      *  <table border="1" cellpadding="4">
-     *    <tr><th>WikiEvent Type(s) </th><th>Required Source Object </th><th>Actually Attached To </th>
-     *    </tr>
-     *    <tr><td>any WikiEngineEvent       </td><td>WikiEngine  </td><td>WikiEngine        </td></tr>
+     *    <tr><th>WikiEvent Type(s)                          </th><th>Required Source Object    </th><th>Actually Attached To </th></tr>
+     *    <tr><td>any WikiEngineEvent                        </td><td>WikiEngine                </td><td>WikiEngine           </td></tr>
      *    <tr><td>WikiPageEvent.PAGE_LOCK,
-     *            WikiPageEvent.PAGE_UNLOCK </td><td>WikiEngine or
-     *                                               PageManager </td><td>PageManager       </td></tr>
+     *            WikiPageEvent.PAGE_UNLOCK                  </td><td>WikiEngine or PageManager </td><td>PageManager          </td></tr>
      *    <tr><td>WikiPageEvent.PAGE_REQUESTED,
-     *            WikiPageEvent.PAGE_DELIVERED </td>
-     *                                           <td>WikiServletFilter </td>
-     *                                                                <td>WikiServletFilter </td></tr>
-     *    <tr><td>WikiPageEvent (<a href="#pbeTypes">phase boundary event</a>)</td>
-     *                                           <td>WikiEngine  </td><td>FilterManager     </td></tr>
-     *    <tr><td>WikiPageEvent (<a href="#ipeTypes">in-phase event</a>)</td>
-     *    <tr><td>WikiPageEvent (in-phase event)</td>
-     *                                           <td>any         </td><td>source object     </td></tr>
-     *    <tr><td>WikiSecurityEvent         </td><td>any         </td><td>source object     </td></tr>
-     *    <tr><td>any other valid type      </td><td>any         </td><td>source object     </td></tr>
-     *    <tr><td>any invalid type          </td><td>any         </td><td>nothing           </td></tr>
+     *            WikiPageEvent.PAGE_DELIVERED               </td><td>WikiServletFilter         </td><td>WikiServletFilter    </td></tr>
+     *    <tr><td>WikiPageEvent (<a href="#pbeTypes">phase
+     *                                     boundary event</a>)</td><td>WikiEngine               </td><td>FilterManager         </td></tr>
+     *    <tr><td>WikiPageEvent (<a href="#ipeTypes">in-phase
+     *                                              event</a>)</td><td>WikiEngine               </td><td>WikiEngine            </td></tr>
+     *    <tr><td>WikiPageEvent (in-phase event)              </td><td>any                      </td><td>source object         </td></tr>
+     *    <tr><td>WikiSecurityEvent                           </td><td>any                      </td><td>source object         </td></tr>
+     *    <tr><td>any other valid type                        </td><td>any                      </td><td>source object         </td></tr>
+     *    <tr><td>any invalid type                            </td><td>any                      </td><td>nothing               </td></tr>
      *  </table>
      *
      * <p id="pbeTypes"><small><b>phase boundary event types:</b>
-     * <tt>WikiPageEvent.PRE_TRANSLATE_BEGIN</tt>, <tt>WikiPageEvent.PRE_TRANSLATE_END</tt>,
-     * <tt>WikiPageEvent.POST_TRANSLATE_BEGIN</tt>, <tt>WikiPageEvent.POST_TRANSLATE_END</tt>,
-     * <tt>WikiPageEvent.PRE_SAVE_BEGIN</tt>, <tt>WikiPageEvent.PRE_SAVE_END</tt>,
+     * <tt>WikiPageEvent.PRE_TRANSLATE_BEGIN</tt>, <tt>WikiPageEvent.PRE_TRANSLATE_END</tt>, <tt>WikiPageEvent.POST_TRANSLATE_BEGIN</tt>,
+     * <tt>WikiPageEvent.POST_TRANSLATE_END</tt>, <tt>WikiPageEvent.PRE_SAVE_BEGIN</tt>, <tt>WikiPageEvent.PRE_SAVE_END</tt>,
      * <tt>WikiPageEvent.POST_SAVE_BEGIN</tt>, and <tt>WikiPageEvent.POST_SAVE_END</tt>.
      * </small></p>
      * <p id="ipeTypes"><small><b>in-phase event types:</b>
-     * <tt>WikiPageEvent.PRE_TRANSLATE</tt>, <tt>WikiPageEvent.POST_TRANSLATE</tt>,
-     * <tt>WikiPageEvent.PRE_SAVE</tt>, and <tt>WikiPageEvent.POST_SAVE</tt>.
+     * <tt>WikiPageEvent.PRE_TRANSLATE</tt>, <tt>WikiPageEvent.POST_TRANSLATE</tt>, <tt>WikiPageEvent.PRE_SAVE</tt>, and
+     * <tt>WikiPageEvent.POST_SAVE</tt>.
      * </small></p>
      *
      * <p>
-     * <b>Note:</b> The <i>Actually Attached To</i> column may also be considered as the
-     * class(es) that fire events of the type(s) shown in the <i>WikiEvent Type</i> column.
+     * <b>Note:</b> The <i>Actually Attached To</i> column may also be considered as the class(es) that fire events of the type(s)
+     * shown in the <i>WikiEvent Type</i> column.
      * </p>
      *
      * @see org.apache.wiki.event.WikiEvent
@@ -89,9 +78,7 @@ public class WikiEventUtils
      * @see org.apache.wiki.event.WikiSecurityEvent
      * @throws ClassCastException if there is a type mismatch between certain event types and the client Object
      */
-    public static synchronized void addWikiEventListener(
-            Object client, int type, WikiEventListener listener )
-    {
+    public static synchronized void addWikiEventListener( final Object client, final int type, final WikiEventListener listener ) {
         // Make sure WikiEventManager exists
         WikiEventManager.getInstance();
         
@@ -99,31 +86,22 @@ public class WikiEventUtils
         // tie us into known types, but WikiEvent.isValidType() will return true so
         // long as the type was set to any non-ERROR or non-UNKNOWN value
 
-        if ( WikiEngineEvent.isValidType(type) )
-        {
+        if( WikiEngineEvent.isValidType( type ) ) {
             // add listener directly to WikiEngine
             WikiEventManager.addWikiEventListener( client, listener );
-        }
-        else if ( WikiPageEvent.isValidType(type) )
-        {
+        } else if( WikiPageEvent.isValidType( type ) ) {
             // add listener to one of several options
             if(  type == WikiPageEvent.PAGE_LOCK
-              || type == WikiPageEvent.PAGE_UNLOCK )
-            {
+              || type == WikiPageEvent.PAGE_UNLOCK ) {
                 // attach to PageManager
-                if( client instanceof WikiEngine )
-                {
+                if( client instanceof WikiEngine ) {
                     WikiEventManager.addWikiEventListener( ((WikiEngine)client).getPageManager(), listener );
-                }
-                else
-                {
+                } else {
                     // client instanceof PageManager
                     WikiEventManager.addWikiEventListener( client, listener );
                 }
-            }
-            else if(  type == WikiPageEvent.PAGE_REQUESTED
-                   || type == WikiPageEvent.PAGE_DELIVERED )
-            {
+            } else if(  type == WikiPageEvent.PAGE_REQUESTED
+                     || type == WikiPageEvent.PAGE_DELIVERED ) {
                 // attach directly to WikiServletFilter
                 WikiEventManager.addWikiEventListener( client, listener );
             }
@@ -134,34 +112,24 @@ public class WikiEventUtils
                    || type == WikiPageEvent.PRE_SAVE_BEGIN
                    || type == WikiPageEvent.PRE_SAVE_END
                    || type == WikiPageEvent.POST_SAVE_BEGIN
-                   || type == WikiPageEvent.POST_SAVE_END )
-            {
+                   || type == WikiPageEvent.POST_SAVE_END ) {
                 // attach to FilterManager
                 WikiEventManager.addWikiEventListener( ((WikiEngine)client).getFilterManager(), listener );
-            }
-            else //if (  type == WikiPageEvent.PRE_TRANSLATE
-                 // || type == WikiPageEvent.POST_TRANSLATE
-                 // || type == WikiPageEvent.PRE_SAVE
-                 // || type == WikiPageEvent.POST_SAVE ) // attach to client
-            {
+            } else { //if (  type == WikiPageEvent.PRE_TRANSLATE
+                     //   || type == WikiPageEvent.POST_TRANSLATE
+                     //   || type == WikiPageEvent.PRE_SAVE
+                     //   || type == WikiPageEvent.POST_SAVE ) // attach to client
                 WikiEventManager.addWikiEventListener( client, listener );
             }
-        }
-        else if( WikiSecurityEvent.isValidType(type) )
-        {
+        } else if( WikiSecurityEvent.isValidType( type ) ) {
             // currently just attach it to the client (we are ignorant of other options)
             WikiEventManager.addWikiEventListener( client, listener );
-        }
-        else if( WikiEvent.isValidType(type) )
-        {
+        } else if( WikiEvent.isValidType( type ) ) {
             // we don't know what to do
             WikiEventManager.addWikiEventListener( client, listener );
-        }
-        else
-        {
-            // is error or unknown
-            // why are we being called with this?
+        } else {
+            // is error or unknown, why are we being called with this?
         }
     }
 
-} // end org.apache.wiki.event.WikiEventUtils
+}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageRenameEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageRenameEvent.java
index 4a35215..7d0608c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageRenameEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageRenameEvent.java
@@ -20,28 +20,24 @@
 package org.apache.wiki.event;
 
 /**
- *  WikiPageRenameEvent extends WikiPageEvent to indicate a change in
- *  the name of a WikiPage.
+ *  WikiPageRenameEvent extends WikiPageEvent to indicate a change in the name of a WikiPage.
  *  <p>
- *  This reuses {@link #getPageName()} to return the new name of the
- *  page, with {@link #getOldPageName()} returning the old name.
+ *  This reuses {@link #getPageName()} to return the new name of the page, with {@link #getOldPageName()} returning the old name.
  *
  * @see     org.apache.wiki.event.WikiPageEvent
  * @since   2.5.108
  */
-public class WikiPageRenameEvent extends WikiPageEvent
-{
+public class WikiPageRenameEvent extends WikiPageEvent {
+
     private static final long serialVersionUID = 1L;
 
-    /** Indicates a page rename event. This is based on events
-      * generated by {@link org.apache.wiki.content.PageRenamer}. */
+    /** Indicates a page rename event. This is based on events generated by {@link org.apache.wiki.content.PageRenamer}. */
     public static final int PAGE_RENAMED         = 28;
 
-    private String m_oldpagename  = null;
+    private String m_oldpagename;
 
     // ............
 
-
     /**
      *  Constructs an instance of this event.
      *
@@ -49,53 +45,43 @@ public class WikiPageRenameEvent extends WikiPageEvent
      * @param oldname   the old name of the WikiPage being acted upon.
      * @param newname   the new name of the WikiPage being acted upon.
      */
-    public WikiPageRenameEvent( Object src, String oldname, String newname )
-    {
+    public WikiPageRenameEvent( final Object src, final String oldname, final String newname ) {
         super( src, PAGE_RENAMED, newname );
         m_oldpagename = oldname;
     }
 
-
-   /**
-     * Returns the old Wiki page name associated with this event.
-     * This may be null if unavailable.
+    /**
+     * Returns the old Wiki page name associated with this event. This may be null if unavailable.
      *
      * @return     the old Wiki page name associated with this WikiEvent, or null.
      */
-    public String getOldPageName()
-    {
+    public String getOldPageName() {
         return m_oldpagename;
     }
 
-
-   /**
-     * Returns the new Wiki page name associated with this event. This
-     * returns the same value as the superclass' {@link #getPageName()}.
+    /**
+     * Returns the new Wiki page name associated with this event. This returns the same value as the superclass' {@link #getPageName()}.
      * This may be null if unavailable.
      *
      * @return     the new Wiki page name associated with this WikiEvent, or null.
      */
-    public String getNewPageName()
-    {
+    public String getNewPageName() {
         return super.getPageName();
     }
 
-
-   /**
+    /**
      * Returns true if the int value is a WikiPageRenameEvent type.
      */
-    public static boolean isValidType( int type )
-    {
+    public static boolean isValidType( final int type ) {
         return type == PAGE_RENAMED;
     }
 
-
     /**
      * Returns a textual representation of the event type.
+     *
      * @return a String representation of the type
      */
-    public String eventName()
-    {
+    public String eventName() {
         return "PAGE_RENAMED";
     //  switch ( getType() )
     //  {
@@ -105,11 +91,10 @@ public class WikiPageRenameEvent extends WikiPageEvent
     }
 
 
-   /** Returns a human-readable description of the event type.
+    /** Returns a human-readable description of the event type.
      * @return a String description of the type
      */
-    public String getTypeDescription()
-    {
+    public String getTypeDescription() {
         return "page renamed event";
     //  switch ( getType() )
     //  {
@@ -118,4 +103,4 @@ public class WikiPageRenameEvent extends WikiPageEvent
     //  }
     }
 
-} // end class org.apache.wiki.event.WikiPageRenameEvent
+}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java
index e7d1cc8..94a633c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiSecurityEvent.java
@@ -25,9 +25,8 @@ import org.apache.log4j.Logger;
 import java.security.Principal;
 
 /**
- * <p>Event class for security events: login/logout, wiki group adds/changes, and
- * authorization decisions. When a WikiSecurityEvent is constructed, the
- * security logger {@link #log} is notified.</p>
+ * <p>Event class for security events: login/logout, wiki group adds/changes, and authorization decisions. When a WikiSecurityEvent
+ * is constructed, the security logger {@link #log} is notified.</p>
  * <p>These events are logged with priority <code>ERROR</code>:</p>
  * <ul>
  *   <li>login failed - bad credential or password</li>
@@ -56,8 +55,7 @@ import java.security.Principal;
  * </ul>
  * @since 2.3.79
  */
-public final class WikiSecurityEvent extends WikiEvent
-{
+public final class WikiSecurityEvent extends WikiEvent {
 
     private static final long serialVersionUID    = -6751950399721334496L;
 
@@ -121,114 +119,97 @@ public final class WikiSecurityEvent extends WikiEvent
 
     private static final int[] ERROR_EVENTS = { LOGIN_FAILED };
     
-    private static final int[] WARN_EVENTS  = { LOGIN_ACCOUNT_EXPIRED,
-                                                LOGIN_CREDENTIAL_EXPIRED };
+    private static final int[] WARN_EVENTS  = { LOGIN_ACCOUNT_EXPIRED, LOGIN_CREDENTIAL_EXPIRED };
     
-    private static final int[] INFO_EVENTS  = { LOGIN_AUTHENTICATED,
-                                                SESSION_EXPIRED, LOGOUT, PROFILE_NAME_CHANGED };
+    private static final int[] INFO_EVENTS  = { LOGIN_AUTHENTICATED, SESSION_EXPIRED, LOGOUT, PROFILE_NAME_CHANGED };
     
     /**
-     * Constructs a new instance of this event type, which signals a security
-     * event has occurred. The <code>source</code> parameter is required, and
-     * may not be <code>null</code>. When the WikiSecurityEvent is
-     * constructed, the security logger {@link #log} is notified.
-     * @param src the source of the event, which can be any object: a wiki
-     *            page, group or authentication/authentication/group manager.
+     * Constructs a new instance of this event type, which signals a security event has occurred. The <code>source</code> parameter is
+     * required, and may not be <code>null</code>. When the WikiSecurityEvent is constructed, the security logger {@link #log} is notified.
+     *
+     * @param src the source of the event, which can be any object: a wiki page, group or authentication/authentication/group manager.
      * @param type the type of event
      * @param principal the subject of the event, which may be <code>null</code>
      * @param target the changed Object, which may be <code>null</code>
      */
-    public WikiSecurityEvent( Object src, int type, Principal principal, Object target )
-    {
+    public WikiSecurityEvent( final Object src, final int type, final Principal principal, final Object target ) {
         super( src, type );
-        if ( src == null )
-        {
+        if( src == null ) {
             throw new IllegalArgumentException( "Argument(s) cannot be null." );
         }
         this.m_principal = principal;
         this.m_target = target;
-        if ( log.isEnabledFor( Level.ERROR ) && ArrayUtils.contains( ERROR_EVENTS, type ) )
-        {
+        if( log.isEnabledFor( Level.ERROR ) && ArrayUtils.contains( ERROR_EVENTS, type ) ) {
             log.error( this );
-        }
-        else if ( log.isEnabledFor( Level.WARN ) && ArrayUtils.contains( WARN_EVENTS, type ) )
-        {
+        } else if( log.isEnabledFor( Level.WARN ) && ArrayUtils.contains( WARN_EVENTS, type ) ) {
             log.warn( this );
-        }
-        else if ( log.isEnabledFor( Level.INFO ) && ArrayUtils.contains( INFO_EVENTS, type ) )
-        {
+        } else if( log.isEnabledFor( Level.INFO ) && ArrayUtils.contains( INFO_EVENTS, type ) ) {
             log.info( this );
         }
         log.debug( this );
     }
 
     /**
-     * Constructs a new instance of this event type, which signals a security
-     * event has occurred. The <code>source</code> parameter is required, and
-     * may not be <code>null</code>. When the WikiSecurityEvent is
-     * constructed, the security logger {@link #log} is notified.
-     * @param src the source of the event, which can be any object: a wiki
-     *            page, group or authentication/authentication/group manager.
+     * Constructs a new instance of this event type, which signals a security event has occurred. The <code>source</code> parameter
+     * is required, and may not be <code>null</code>. When the WikiSecurityEvent is constructed, the security logger {@link #log}
+     * is notified.
+     *
+     * @param src the source of the event, which can be any object: a wiki page, group or authentication/authentication/group manager.
      * @param type the type of event
      * @param target the changed Object, which may be <code>null</code>.
      */
-    public WikiSecurityEvent( Object src, int type, Object target )
-    {
+    public WikiSecurityEvent( final Object src, final int type, final Object target ) {
         this( src, type, null, target );
     }
 
     /**
-     * Returns the principal to whom the opeation applied, if supplied. This
-     * method may return <code>null</code>
+     * Returns the principal to whom the opeation applied, if supplied. This method may return <code>null</code>
      * <em>&#8212; and calling methods should check for this condition</em>.
+     *
      * @return the changed object
      */
-    public Object getPrincipal()
-    {
+    public Object getPrincipal() {
         return m_principal;
     }
     
     /**
-     * Returns the object that was operated on, if supplied. This method may
-     * return <code>null</code>
+     * Returns the object that was operated on, if supplied. This method may return <code>null</code>
      * <em>&#8212; and calling methods should check for this condition</em>.
+     *
      * @return the changed object
      */
-    public Object getTarget()
-    {
+    public Object getTarget() {
         return m_target;
     }
 
     /**
      * Prints a String (human-readable) representation of this object.
+     *
      * @see java.lang.Object#toString()
      */
-    public String toString()
-    {
-    	StringBuilder msg = new StringBuilder();
+    public String toString() {
+        final StringBuilder msg = new StringBuilder();
         msg.append( "WikiSecurityEvent." );
         msg.append(  eventName( getType() ) );
-        Object obj = getSrc(); // cfr. https://forums.oracle.com/forums/thread.jspa?threadID=1184115
-        msg.append( " [source=" + obj.toString() );
-        if( m_principal != null )
-        {
-            msg.append( ", princpal=" + m_principal.getClass().getName() );
-            msg.append( " " + m_principal.getName() );
+        final Object obj = getSrc(); // cfr. https://forums.oracle.com/forums/thread.jspa?threadID=1184115
+        msg.append( " [source=" ).append( obj.toString() );
+        if( m_principal != null ) {
+            msg.append( ", princpal=" ).append( m_principal.getClass().getName() );
+            msg.append( " " ).append( m_principal.getName() );
         }
-        msg.append( ", target=" + m_target );
+        msg.append( ", target=" ).append( m_target );
         msg.append( "]" );
         return msg.toString();
     }
     
     /**
      * Returns a textual representation of an event type.
+     *
      * @param type the type
      * @return the string representation
      */
-    public String eventName( int type )
-    {
-        switch( type )
-        {
+    public String eventName( final int type ) {
+        switch( type ) {
             case LOGIN_AUTHENTICATED:       return "LOGIN_AUTHENTICATED";
             case LOGIN_ACCOUNT_EXPIRED:     return "LOGIN_ACCOUNT_EXPIRED";
             case LOGIN_CREDENTIAL_EXPIRED:  return "LOGIN_ACCOUNT_EXPIRED";
@@ -252,10 +233,8 @@ public final class WikiSecurityEvent extends WikiEvent
      *
      * @return a String description of the type
      */
-    public String getTypeDescription()
-    {
-        switch ( getType() )
-        {
+    public String getTypeDescription() {
+        switch ( getType() ) {
             case LOGIN_AUTHENTICATED:       return "login authenticated";
             case LOGIN_ACCOUNT_EXPIRED:     return "login failed: expired account";
             case LOGIN_CREDENTIAL_EXPIRED:  return "login failed: credential expired";
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WorkflowEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WorkflowEvent.java
index 5f2c552..d9be3b9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WorkflowEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WorkflowEvent.java
@@ -63,11 +63,10 @@ public final class WorkflowEvent extends WikiEvent {
      * The <code>source</code> parameter is required, and may not be <code>null</code>. When the 
      * WikiSecurityEvent is constructed, the security logger {@link WikiSecurityEvent#log} is notified.
      * 
-     * @param src the source of the event, which can be any object: a wiki page, group or 
-     *            authentication/authentication/group manager.
+     * @param src the source of the event, which can be any object: a wiki page, group or authentication/authentication/group manager.
      * @param type the type of event
      */
-    public WorkflowEvent( Object src, int type ) {
+    public WorkflowEvent( final Object src, final int type ) {
         super( src, type );
         if( src == null ) {
             throw new IllegalArgumentException( "Argument(s) cannot be null." );
@@ -80,11 +79,11 @@ public final class WorkflowEvent extends WikiEvent {
      * @see java.lang.Object#toString()
      */
     public String toString() {
-    	StringBuilder msg = new StringBuilder();
+        final StringBuilder msg = new StringBuilder();
         msg.append( "WorkflowEvent." );
         msg.append( eventName( getType() ) );
-        Object obj = getSrc(); // cfr. https://forums.oracle.com/forums/thread.jspa?threadID=1184115
-        msg.append( " [source=" + obj.toString() );
+        final Object obj = getSrc(); // cfr. https://forums.oracle.com/forums/thread.jspa?threadID=1184115
+        msg.append( " [source=" ).append( obj.toString() );
         msg.append( "]" );
         return msg.toString();
     }
@@ -95,7 +94,7 @@ public final class WorkflowEvent extends WikiEvent {
      * @param type the type
      * @return the string representation
      */
-    public String eventName( int type ) {
+    public String eventName( final int type ) {
         switch( type ) {
             case CREATED:   return "CREATED";
             case ABORTED:   return "ABORTED";


[jspwiki] 08/32: rename + extract interface from ProgressManager, instantiate it through classmappings.xml on WikiEngine

Posted by ju...@apache.org.
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 5eb41ff79eece279d2e116f5a0e15d2f02395540
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 18 15:36:10 2020 +0100

    rename + extract interface from ProgressManager, instantiate it through classmappings.xml on WikiEngine
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  10 +-
 ...essManager.java => DefaultProgressManager.java} |  11 +--
 .../apache/wiki/ui/progress/ProgressManager.java   | 101 ++-------------------
 .../src/main/resources/ini/classmappings.xml       |   4 +
 4 files changed, 17 insertions(+), 109 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 5014218..b261745 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -473,12 +473,9 @@ public class WikiEngine  {
         m_frontPage      = TextUtil.getStringProperty( props, PROP_FRONTPAGE,   "Main" );
 
         //
-        //  Initialize the important modules.  Any exception thrown by the
-        //  managers means that we will not start up.
+        //  Initialize the important modules.  Any exception thrown by the managers means that we will not start up.
         //
-
-        // FIXME: This part of the code is getting unwieldy.  We must think
-        //        of a better way to do the startup-sequence.
+        // FIXME: This part of the code is getting unwieldy.  We must think of a better way to do the startup-sequence.
         try {
             final Class< ? > urlclass = ClassUtil.findClass( "org.apache.wiki.url",
                                                              TextUtil.getStringProperty( props, PROP_URLCONSTRUCTOR, "DefaultURLConstructor" ) );
@@ -497,10 +494,9 @@ public class WikiEngine  {
             m_userManager           = ClassUtil.getMappedObject( UserManager.class.getName() );
             m_groupManager          = ClassUtil.getMappedObject( GroupManager.class.getName() );
             m_editorManager         = ClassUtil.getMappedObject( EditorManager.class.getName(), this );
+            m_progressManager       = ClassUtil.getMappedObject( ProgressManager.class.getName(), this );
             m_editorManager.initialize( props );
 
-            m_progressManager   = new ProgressManager();
-
             // Initialize the authentication, authorization, user and acl managers
             m_authenticationManager.initialize( this, props );
             m_authorizationManager.initialize( this, props );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/DefaultProgressManager.java
similarity index 93%
copy from jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java
copy to jspwiki-main/src/main/java/org/apache/wiki/ui/progress/DefaultProgressManager.java
index 6ce37ce..f363385 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/DefaultProgressManager.java
@@ -38,19 +38,16 @@ import java.util.concurrent.ConcurrentHashMap;
  *
  *  @since  2.6
  */
-public class ProgressManager {
+public class DefaultProgressManager implements ProgressManager {
 
     private final Map< String,ProgressItem > m_progressingTasks = new ConcurrentHashMap<>();
 
-    /** The name of the progress tracker JSON object.  The current value is "{@value}", */
-    public static final String JSON_PROGRESSTRACKER = "progressTracker";
-
-    private static final Logger log = Logger.getLogger( ProgressManager.class );
+    private static final Logger log = Logger.getLogger( DefaultProgressManager.class );
 
     /**
      *  Creates a new ProgressManager.
      */
-    public ProgressManager() {
+    public DefaultProgressManager() {
     	// TODO: Replace with custom annotations. See JSPWIKI-566
         WikiAjaxDispatcherServlet.registerServlet( JSON_PROGRESSTRACKER, new JSONTracker() );
     }
@@ -120,7 +117,7 @@ public class ProgressManager {
          */
         public int getProgress( final String progressId )
         {
-            return ProgressManager.this.getProgress( progressId );
+            return DefaultProgressManager.this.getProgress( progressId );
         }
         
         public String getServletMapping() {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java
index 6ce37ce..4f818f5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java
@@ -18,19 +18,6 @@
  */
 package org.apache.wiki.ui.progress;
 
-import org.apache.log4j.Logger;
-import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
-import org.apache.wiki.ajax.WikiAjaxServlet;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.concurrent.ConcurrentHashMap;
-
-
 /**
  *  Manages progressing items.  In general this class is used whenever JSPWiki is doing something which may require a long time.
  *  In addition, this manager provides a JSON interface for finding remotely what the progress is.  The JSON object name is
@@ -38,32 +25,16 @@ import java.util.concurrent.ConcurrentHashMap;
  *
  *  @since  2.6
  */
-public class ProgressManager {
-
-    private final Map< String,ProgressItem > m_progressingTasks = new ConcurrentHashMap<>();
+public interface ProgressManager {
 
-    /** The name of the progress tracker JSON object.  The current value is "{@value}", */
-    public static final String JSON_PROGRESSTRACKER = "progressTracker";
-
-    private static final Logger log = Logger.getLogger( ProgressManager.class );
-
-    /**
-     *  Creates a new ProgressManager.
-     */
-    public ProgressManager() {
-    	// TODO: Replace with custom annotations. See JSPWIKI-566
-        WikiAjaxDispatcherServlet.registerServlet( JSON_PROGRESSTRACKER, new JSONTracker() );
-    }
+    String JSON_PROGRESSTRACKER = "progressTracker";
 
     /**
      *  You can use this to get an unique process identifier.
      *
      *  @return A new random value
      */
-    public String getNewProgressIdentifier()
-    {
-        return UUID.randomUUID().toString();
-    }
+    String getNewProgressIdentifier();
 
     /**
      *  Call this method to get your ProgressItem into the ProgressManager queue. The ProgressItem will be moved to state STARTED.
@@ -71,11 +42,7 @@ public class ProgressManager {
      *  @param pi ProgressItem to start
      *  @param id The progress identifier
      */
-    public void startProgress( final ProgressItem pi, final String id ) {
-        log.debug( "Adding " + id + " to progress queue" );
-        m_progressingTasks.put( id, pi );
-        pi.setState( ProgressItem.STARTED );
-    }
+    void startProgress( ProgressItem pi, String id );
 
     /**
      *  Call this method to remove your ProgressItem from the queue (after which getProgress() will no longer find it.
@@ -83,13 +50,7 @@ public class ProgressManager {
      *
      *  @param id The progress identifier
      */
-    public void stopProgress( final String id ) {
-        log.debug( "Removed " + id + " from progress queue" );
-        final ProgressItem pi = m_progressingTasks.remove( id );
-        if( pi != null ) {
-            pi.setState( ProgressItem.STOPPED );
-        }
-    }
+    void stopProgress( String id );
 
     /**
      *  Get the progress in percents.
@@ -98,56 +59,6 @@ public class ProgressManager {
      *  @return a value between 0 to 100 indicating the progress
      *  @throws IllegalArgumentException If no such progress item exists.
      */
-    public int getProgress( final String id ) throws IllegalArgumentException {
-        final ProgressItem pi = m_progressingTasks.get( id );
-        if( pi != null ) {
-            return pi.getProgress();
-        }
-
-        throw new IllegalArgumentException( "No such id was found" );
-    }
-
-    /**
-     *  Provides access to a progress indicator, assuming you know the ID. Progress of zero (0) means that the progress has just started,
-     *  and a progress of 100 means that it is complete.
-     */
-    public class JSONTracker implements WikiAjaxServlet {
-        /**
-         *  Returns upload progress in percents so far.
-         *
-         *  @param progressId The string representation of the progress ID that you want to know the progress of.
-         *  @return a value between 0 to 100 indicating the progress
-         */
-        public int getProgress( final String progressId )
-        {
-            return ProgressManager.this.getProgress( progressId );
-        }
-        
-        public String getServletMapping() {
-        	return JSON_PROGRESSTRACKER;
-        }
-        
-        public void service( final HttpServletRequest req,
-                             final HttpServletResponse resp,
-                             final String actionName,
-                             final List< String > params ) throws IOException {
-        	log.debug( "ProgressManager.doGet() START" );
-        	if( params.size() < 1 ) {
-        		return;
-        	}
-        	final String progressId = params.get(0);
-        	log.debug( "progressId=" + progressId );
-        	String progressString = "";
-        	try {
-        		progressString = Integer.toString( getProgress( progressId ) );
-        	} catch( final IllegalArgumentException e ) { // ignore
-        		log.debug( "progressId " + progressId + " is no longer valid" );
-        	}
-        	log.debug( "progressString=" + progressString );
-        	resp.getWriter().write( progressString );
-        	log.debug( "ProgressManager.doGet() DONE" );
-        }
-
-    }
+    int getProgress( String id ) throws IllegalArgumentException;
 
 }
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index bc6f1e0..3f5bd1f 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -124,6 +124,10 @@
     <mappedClass>org.apache.wiki.ui.TemplateManager</mappedClass>
   </mapping>
   <mapping>
+    <requestedClass>org.apache.wiki.ui.progress.ProgressManager</requestedClass>
+    <mappedClass>org.apache.wiki.ui.progress.DefaultProgressManager</mappedClass>
+  </mapping>
+  <mapping>
     <requestedClass>org.apache.wiki.variables.VariableManager</requestedClass>
     <mappedClass>org.apache.wiki.variables.DefaultVariableManager</mappedClass>
   </mapping>


[jspwiki] 16/32: JSPWIKI-120: propagate WikiEngine#createContext(..) to new WikiContext change on jsps

Posted by ju...@apache.org.
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 719c1154d2589baa39a78545487c4f07686750ec
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Jan 20 22:35:06 2020 +0100

    JSPWIKI-120: propagate WikiEngine#createContext(..) to new WikiContext change on jsps
---
 jspwiki-war/src/main/webapp/Captcha.jsp                          | 2 +-
 jspwiki-war/src/main/webapp/Comment.jsp                          | 2 +-
 jspwiki-war/src/main/webapp/CookieError.jsp                      | 6 ++----
 jspwiki-war/src/main/webapp/Delete.jsp                           | 2 +-
 jspwiki-war/src/main/webapp/DeleteGroup.jsp                      | 2 +-
 jspwiki-war/src/main/webapp/Diff.jsp                             | 2 +-
 jspwiki-war/src/main/webapp/Edit.jsp                             | 2 +-
 jspwiki-war/src/main/webapp/EditGroup.jsp                        | 2 +-
 jspwiki-war/src/main/webapp/Error.jsp                            | 3 +--
 jspwiki-war/src/main/webapp/Group.jsp                            | 2 +-
 jspwiki-war/src/main/webapp/Install.jsp                          | 2 +-
 jspwiki-war/src/main/webapp/Login.jsp                            | 2 +-
 jspwiki-war/src/main/webapp/LoginForm.jsp                        | 2 +-
 jspwiki-war/src/main/webapp/LostPassword.jsp                     | 2 +-
 jspwiki-war/src/main/webapp/Message.jsp                          | 2 +-
 jspwiki-war/src/main/webapp/NewBlogEntry.jsp                     | 2 +-
 jspwiki-war/src/main/webapp/NewGroup.jsp                         | 2 +-
 jspwiki-war/src/main/webapp/PageInfo.jsp                         | 2 +-
 jspwiki-war/src/main/webapp/PageModified.jsp                     | 2 +-
 jspwiki-war/src/main/webapp/Preview.jsp                          | 2 +-
 jspwiki-war/src/main/webapp/Rename.jsp                           | 2 +-
 jspwiki-war/src/main/webapp/Search.jsp                           | 2 +-
 jspwiki-war/src/main/webapp/SisterSites.jsp                      | 2 +-
 jspwiki-war/src/main/webapp/Upload.jsp                           | 6 ++----
 jspwiki-war/src/main/webapp/UserPreferences.jsp                  | 2 +-
 jspwiki-war/src/main/webapp/Wiki.jsp                             | 2 +-
 jspwiki-war/src/main/webapp/Workflow.jsp                         | 2 +-
 jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp                   | 2 +-
 jspwiki-war/src/main/webapp/admin/Admin.jsp                      | 5 ++---
 jspwiki-war/src/main/webapp/admin/SecurityConfig.jsp             | 5 ++---
 jspwiki-war/src/main/webapp/rss.jsp                              | 2 +-
 jspwiki-war/src/main/webapp/templates/default/AJAXCategories.jsp | 2 +-
 jspwiki-war/src/main/webapp/templates/default/AJAXPreview.jsp    | 2 +-
 jspwiki-war/src/main/webapp/templates/default/AJAXSearch.jsp     | 2 +-
 34 files changed, 38 insertions(+), 45 deletions(-)

diff --git a/jspwiki-war/src/main/webapp/Captcha.jsp b/jspwiki-war/src/main/webapp/Captcha.jsp
index 83ee201..cc61882 100644
--- a/jspwiki-war/src/main/webapp/Captcha.jsp
+++ b/jspwiki-war/src/main/webapp/Captcha.jsp
@@ -37,7 +37,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
     String pagereq = wikiContext.getName();
 
diff --git a/jspwiki-war/src/main/webapp/Comment.jsp b/jspwiki-war/src/main/webapp/Comment.jsp
index 5ef57e3..0ca43c5 100644
--- a/jspwiki-war/src/main/webapp/Comment.jsp
+++ b/jspwiki-war/src/main/webapp/Comment.jsp
@@ -59,7 +59,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.COMMENT );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.COMMENT );
     if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
diff --git a/jspwiki-war/src/main/webapp/CookieError.jsp b/jspwiki-war/src/main/webapp/CookieError.jsp
index a2da236..b7cf4d7 100755
--- a/jspwiki-war/src/main/webapp/CookieError.jsp
+++ b/jspwiki-war/src/main/webapp/CookieError.jsp
@@ -23,11 +23,9 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context; authorization check not needed
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW );
  
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "CookieErrorTemplate.jsp" );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "CookieErrorTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
diff --git a/jspwiki-war/src/main/webapp/Delete.jsp b/jspwiki-war/src/main/webapp/Delete.jsp
index 40063d3..7dbe7d8 100644
--- a/jspwiki-war/src/main/webapp/Delete.jsp
+++ b/jspwiki-war/src/main/webapp/Delete.jsp
@@ -36,7 +36,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.DELETE );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.DELETE );
     if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
diff --git a/jspwiki-war/src/main/webapp/DeleteGroup.jsp b/jspwiki-war/src/main/webapp/DeleteGroup.jsp
index 827c725..9f38ae6 100644
--- a/jspwiki-war/src/main/webapp/DeleteGroup.jsp
+++ b/jspwiki-war/src/main/webapp/DeleteGroup.jsp
@@ -33,7 +33,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.DELETE_GROUP );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.DELETE_GROUP );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
 
     WikiSession wikiSession = wikiContext.getWikiSession();
diff --git a/jspwiki-war/src/main/webapp/Diff.jsp b/jspwiki-war/src/main/webapp/Diff.jsp
index 7dfaec2..1d2ede4 100644
--- a/jspwiki-war/src/main/webapp/Diff.jsp
+++ b/jspwiki-war/src/main/webapp/Diff.jsp
@@ -33,7 +33,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.DIFF );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.DIFF );
     if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
diff --git a/jspwiki-war/src/main/webapp/Edit.jsp b/jspwiki-war/src/main/webapp/Edit.jsp
index b572cae..3972ff3 100644
--- a/jspwiki-war/src/main/webapp/Edit.jsp
+++ b/jspwiki-war/src/main/webapp/Edit.jsp
@@ -49,7 +49,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.EDIT );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.EDIT );
     if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) {
         return;
     }
diff --git a/jspwiki-war/src/main/webapp/EditGroup.jsp b/jspwiki-war/src/main/webapp/EditGroup.jsp
index e90726f..8f573fb 100644
--- a/jspwiki-war/src/main/webapp/EditGroup.jsp
+++ b/jspwiki-war/src/main/webapp/EditGroup.jsp
@@ -32,7 +32,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.EDIT_GROUP );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.EDIT_GROUP );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
     
     // Extract the current user, group name, members and action attributes
diff --git a/jspwiki-war/src/main/webapp/Error.jsp b/jspwiki-war/src/main/webapp/Error.jsp
index 36fe2f4..86f3e76 100644
--- a/jspwiki-war/src/main/webapp/Error.jsp
+++ b/jspwiki-war/src/main/webapp/Error.jsp
@@ -27,8 +27,7 @@
 %>
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
-    WikiContext wikiContext = wiki.createContext( request,
-                                                  WikiContext.ERROR );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.ERROR );
     String pagereq = wikiContext.getName();
 
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
diff --git a/jspwiki-war/src/main/webapp/Group.jsp b/jspwiki-war/src/main/webapp/Group.jsp
index 6abcd7f..5fa3a32 100644
--- a/jspwiki-war/src/main/webapp/Group.jsp
+++ b/jspwiki-war/src/main/webapp/Group.jsp
@@ -33,7 +33,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW_GROUP );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW_GROUP );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
     
     // Extract the current user, group name, members
diff --git a/jspwiki-war/src/main/webapp/Install.jsp b/jspwiki-war/src/main/webapp/Install.jsp
index c4a5979..1f87580 100644
--- a/jspwiki-war/src/main/webapp/Install.jsp
+++ b/jspwiki-war/src/main/webapp/Install.jsp
@@ -36,7 +36,7 @@
 <%
 WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
 // Create wiki context and check for authorization
-WikiContext wikiContext = wiki.createContext( request, WikiContext.INSTALL );
+WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.INSTALL );
 if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
 
 Installer installer = new Installer( request, config );
diff --git a/jspwiki-war/src/main/webapp/Login.jsp b/jspwiki-war/src/main/webapp/Login.jsp
index c5db736..7cbd41e 100644
--- a/jspwiki-war/src/main/webapp/Login.jsp
+++ b/jspwiki-war/src/main/webapp/Login.jsp
@@ -37,7 +37,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     AuthenticationManager mgr = wiki.getAuthenticationManager();
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.LOGIN );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.LOGIN );
     pageContext.setAttribute( WikiContext.ATTR_CONTEXT, wikiContext, PageContext.REQUEST_SCOPE );
     WikiSession wikiSession = wikiContext.getWikiSession();
     ResourceBundle rb = Preferences.getBundle( wikiContext, "CoreResources" );
diff --git a/jspwiki-war/src/main/webapp/LoginForm.jsp b/jspwiki-war/src/main/webapp/LoginForm.jsp
index e85cf90..d918357 100644
--- a/jspwiki-war/src/main/webapp/LoginForm.jsp
+++ b/jspwiki-war/src/main/webapp/LoginForm.jsp
@@ -41,7 +41,7 @@
     
     // If no context, it means we're using container auth.  So, create one anyway
     if( wikiContext == null ) {
-        wikiContext = wiki.createContext( request, WikiContext.LOGIN );
+        wikiContext = new WikiContext( wiki, request, WikiContext.LOGIN );
         pageContext.setAttribute( WikiContext.ATTR_CONTEXT, wikiContext, PageContext.REQUEST_SCOPE );
     }
     
diff --git a/jspwiki-war/src/main/webapp/LostPassword.jsp b/jspwiki-war/src/main/webapp/LostPassword.jsp
index 32ffab4..5c15297 100644
--- a/jspwiki-war/src/main/webapp/LostPassword.jsp
+++ b/jspwiki-war/src/main/webapp/LostPassword.jsp
@@ -104,7 +104,7 @@
 
     // If no context, it means we're using container auth.  So, create one anyway
     if( wikiContext == null ) {
-        wikiContext = wiki.createContext( request, WikiContext.LOGIN ); /* reuse login context ! */
+        wikiContext = new WikiContext( wiki, request, WikiContext.LOGIN ); /* reuse login context ! */
         pageContext.setAttribute( WikiContext.ATTR_CONTEXT, wikiContext, PageContext.REQUEST_SCOPE );
     }
 
diff --git a/jspwiki-war/src/main/webapp/Message.jsp b/jspwiki-war/src/main/webapp/Message.jsp
index 6338e15..fdff7a0 100755
--- a/jspwiki-war/src/main/webapp/Message.jsp
+++ b/jspwiki-war/src/main/webapp/Message.jsp
@@ -26,7 +26,7 @@
 %>
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.MESSAGE );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.MESSAGE );
 
     // Stash the wiki context and message text
     request.setAttribute( WikiContext.ATTR_CONTEXT, wikiContext );
diff --git a/jspwiki-war/src/main/webapp/NewBlogEntry.jsp b/jspwiki-war/src/main/webapp/NewBlogEntry.jsp
index 3021ad8..f8128fa 100644
--- a/jspwiki-war/src/main/webapp/NewBlogEntry.jsp
+++ b/jspwiki-war/src/main/webapp/NewBlogEntry.jsp
@@ -30,7 +30,7 @@
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context; no need to check for authorization since the 
     // redirect will take care of that
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.EDIT );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.EDIT );
     String pagereq = wikiContext.getName();
     
     // Redirect if the request was for a 'special page'
diff --git a/jspwiki-war/src/main/webapp/NewGroup.jsp b/jspwiki-war/src/main/webapp/NewGroup.jsp
index 2582e43..a7194e2 100644
--- a/jspwiki-war/src/main/webapp/NewGroup.jsp
+++ b/jspwiki-war/src/main/webapp/NewGroup.jsp
@@ -35,7 +35,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.CREATE_GROUP );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.CREATE_GROUP );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
     
     // Extract the current user, group name, members and action attributes
diff --git a/jspwiki-war/src/main/webapp/PageInfo.jsp b/jspwiki-war/src/main/webapp/PageInfo.jsp
index 86885e4..fe5445c 100644
--- a/jspwiki-war/src/main/webapp/PageInfo.jsp
+++ b/jspwiki-war/src/main/webapp/PageInfo.jsp
@@ -31,7 +31,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.INFO );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.INFO );
     if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
diff --git a/jspwiki-war/src/main/webapp/PageModified.jsp b/jspwiki-war/src/main/webapp/PageModified.jsp
index 9130123..b5f00a8 100644
--- a/jspwiki-war/src/main/webapp/PageModified.jsp
+++ b/jspwiki-war/src/main/webapp/PageModified.jsp
@@ -33,7 +33,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.CONFLICT );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.CONFLICT );
     if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
diff --git a/jspwiki-war/src/main/webapp/Preview.jsp b/jspwiki-war/src/main/webapp/Preview.jsp
index 1058fda..31d39d0 100644
--- a/jspwiki-war/src/main/webapp/Preview.jsp
+++ b/jspwiki-war/src/main/webapp/Preview.jsp
@@ -32,7 +32,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.PREVIEW );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.PREVIEW );
     if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
diff --git a/jspwiki-war/src/main/webapp/Rename.jsp b/jspwiki-war/src/main/webapp/Rename.jsp
index 2df7fa5..7d5b767 100644
--- a/jspwiki-war/src/main/webapp/Rename.jsp
+++ b/jspwiki-war/src/main/webapp/Rename.jsp
@@ -38,7 +38,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-	WikiContext wikiContext = wiki.createContext( request, WikiContext.RENAME );
+	WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.RENAME );
 	if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
diff --git a/jspwiki-war/src/main/webapp/Search.jsp b/jspwiki-war/src/main/webapp/Search.jsp
index e373d9d..dce8b51 100644
--- a/jspwiki-war/src/main/webapp/Search.jsp
+++ b/jspwiki-war/src/main/webapp/Search.jsp
@@ -35,7 +35,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.FIND );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.FIND );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
     String pagereq = wikiContext.getName();
 
diff --git a/jspwiki-war/src/main/webapp/SisterSites.jsp b/jspwiki-war/src/main/webapp/SisterSites.jsp
index 0870b73..067d9ef 100644
--- a/jspwiki-war/src/main/webapp/SisterSites.jsp
+++ b/jspwiki-war/src/main/webapp/SisterSites.jsp
@@ -35,7 +35,7 @@
      */
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, "rss" );
+    WikiContext wikiContext = new WikiContext( wiki, request, "rss" );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
     
     Set< String > allPages = wiki.getReferenceManager().findCreated();
diff --git a/jspwiki-war/src/main/webapp/Upload.jsp b/jspwiki-war/src/main/webapp/Upload.jsp
index 4939588..db1002e 100644
--- a/jspwiki-war/src/main/webapp/Upload.jsp
+++ b/jspwiki-war/src/main/webapp/Upload.jsp
@@ -31,14 +31,12 @@
 <% 
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.UPLOAD );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.UPLOAD );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
     String pagereq = wikiContext.getName();
 
     // Set the content type and include the response content
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "UploadTemplate.jsp" );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "UploadTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
 
diff --git a/jspwiki-war/src/main/webapp/UserPreferences.jsp b/jspwiki-war/src/main/webapp/UserPreferences.jsp
index 7f58ded..101acb9 100644
--- a/jspwiki-war/src/main/webapp/UserPreferences.jsp
+++ b/jspwiki-war/src/main/webapp/UserPreferences.jsp
@@ -42,7 +42,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.PREFS );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.PREFS );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
     
     // Extract the user profile and action attributes
diff --git a/jspwiki-war/src/main/webapp/Wiki.jsp b/jspwiki-war/src/main/webapp/Wiki.jsp
index 1726725..7dca137 100644
--- a/jspwiki-war/src/main/webapp/Wiki.jsp
+++ b/jspwiki-war/src/main/webapp/Wiki.jsp
@@ -31,7 +31,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW );
     if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
     String pagereq = wikiContext.getName();
 
diff --git a/jspwiki-war/src/main/webapp/Workflow.jsp b/jspwiki-war/src/main/webapp/Workflow.jsp
index 1abf46e..5c5b5d3 100644
--- a/jspwiki-war/src/main/webapp/Workflow.jsp
+++ b/jspwiki-war/src/main/webapp/Workflow.jsp
@@ -38,7 +38,7 @@
 <%
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.WORKFLOW );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.WORKFLOW );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
     
     // Extract the wiki session
diff --git a/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp b/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp
index 3f1ace0..de0f96f 100644
--- a/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp
+++ b/jspwiki-war/src/main/webapp/XHRHtml2Markup.jsp
@@ -32,7 +32,7 @@
   WikiEngine wiki;
 %>
 <%
-  WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW );
+  WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW );
 
   if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
 
diff --git a/jspwiki-war/src/main/webapp/admin/Admin.jsp b/jspwiki-war/src/main/webapp/admin/Admin.jsp
index d2c05a3..b6d3742 100644
--- a/jspwiki-war/src/main/webapp/admin/Admin.jsp
+++ b/jspwiki-war/src/main/webapp/admin/Admin.jsp
@@ -34,12 +34,11 @@
     String bean = request.getParameter("bean");
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, WikiContext.ADMIN );
+    WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.ADMIN );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
 
     //
-    //  This is an experimental feature, so we will turn it off unless the
-    //  user really wants to.
+    //  This is an experimental feature, so we will turn it off unless the user really wants to.
     //
     if( !TextUtil.isPositive(wiki.getWikiProperties().getProperty("jspwiki-x.adminui.enable")) )
     {
diff --git a/jspwiki-war/src/main/webapp/admin/SecurityConfig.jsp b/jspwiki-war/src/main/webapp/admin/SecurityConfig.jsp
index 508c1a0..f0f59de 100644
--- a/jspwiki-war/src/main/webapp/admin/SecurityConfig.jsp
+++ b/jspwiki-war/src/main/webapp/admin/SecurityConfig.jsp
@@ -37,14 +37,13 @@
 <!doctype html>
 <html lang="en" name="top">
 <%
-  WikiContext wikiContext = wiki.createContext( request, WikiContext.NONE );
+  WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.NONE );
   if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
   response.setContentType("text/html; charset="+wiki.getContentEncoding() );
   verifier = new SecurityVerifier( wiki, wikiContext.getWikiSession() );
 
   //
-  //  This is a security feature, so we will turn it off unless the
-  //  user really wants to.
+  //  This is a security feature, so we will turn it off unless the user really wants to.
   //
   if( !TextUtil.isPositive(wiki.getWikiProperties().getProperty("jspwiki-x.securityconfig.enable")) )
   {
diff --git a/jspwiki-war/src/main/webapp/rss.jsp b/jspwiki-war/src/main/webapp/rss.jsp
index 0adb70c..d58c2c2 100644
--- a/jspwiki-war/src/main/webapp/rss.jsp
+++ b/jspwiki-war/src/main/webapp/rss.jsp
@@ -49,7 +49,7 @@
     }
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
-    WikiContext wikiContext = wiki.createContext( request, "rss" );
+    WikiContext wikiContext = new WikiContext( wiki, request, "rss" );
     if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
     WikiPage    wikipage    = wikiContext.getPage();
 
diff --git a/jspwiki-war/src/main/webapp/templates/default/AJAXCategories.jsp b/jspwiki-war/src/main/webapp/templates/default/AJAXCategories.jsp
index 675fefc..9b7c9cb 100644
--- a/jspwiki-war/src/main/webapp/templates/default/AJAXCategories.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/AJAXCategories.jsp
@@ -29,7 +29,7 @@
 %>
 <%
   // Copied from a top-level jsp -- which would be a better place to put this 
-  WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW );
+  WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW );
   if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
   String pagereq = wikiContext.getPage().getName();
 
diff --git a/jspwiki-war/src/main/webapp/templates/default/AJAXPreview.jsp b/jspwiki-war/src/main/webapp/templates/default/AJAXPreview.jsp
index c183837..996ef27 100644
--- a/jspwiki-war/src/main/webapp/templates/default/AJAXPreview.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/AJAXPreview.jsp
@@ -35,7 +35,7 @@
 %>
 <%
   // Copied from a top-level jsp -- which would be a better place to put this 
-  WikiContext wikiContext = wiki.createContext( request, WikiContext.VIEW );
+  WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.VIEW );
   if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
 
   response.setContentType("text/html; charset="+wiki.getContentEncoding() );
diff --git a/jspwiki-war/src/main/webapp/templates/default/AJAXSearch.jsp b/jspwiki-war/src/main/webapp/templates/default/AJAXSearch.jsp
index 56c4ad1..8a1c672 100644
--- a/jspwiki-war/src/main/webapp/templates/default/AJAXSearch.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/AJAXSearch.jsp
@@ -47,7 +47,7 @@
   /* ********************* actual start ********************* */
   /* FIXME: too much hackin on this level -- should better happen in toplevel jsp's */
   /* Create wiki context and check for authorization */
-  WikiContext wikiContext = wiki.createContext( request, WikiContext.FIND );
+  WikiContext wikiContext = new WikiContext( wiki, request, WikiContext.FIND );
   if(!wiki.getAuthorizationManager().hasAccess( wikiContext, response )) return;
 
   String query = request.getParameter( "query");


[jspwiki] 25/32: fix javadocs so the updated package of PageEventFilter is used.

Posted by ju...@apache.org.
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 6e4d2f3f6f9c4a1e72575a3425baf9e66a8dc4cb
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 23 21:48:32 2020 +0100

    fix javadocs so the updated package of PageEventFilter is used.
    
    Also, while at it, apply format suggestions by intellij
---
 .../java/org/apache/wiki/event/WikiPageEvent.java  | 216 +++++++++------------
 1 file changed, 95 insertions(+), 121 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageEvent.java
index 07825de..181e3a7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiPageEvent.java
@@ -21,84 +21,70 @@ package org.apache.wiki.event;
 
 
 /**
-  * WikiPageEvent indicates a change in the state or processing of a WikiPage.
-  * There are basically two types of page events:
-  * <dl>
-  *   <dt><b>Phase Boundary Events</b></dt>
-  *   <dd>Those considered as "beginning-of-phase", and those as "end-of-phase"
-  *       events (as designated by <tt>*_BEGIN</tt> and <tt>*_END</tt>), as
-  *       generated by the WikiEngine. The phases include pre-save, post-save,
-  *       pre-translate, and post-translate.
-  *   </dd>
-  *   <dt><b>In-Phase Events</b></dt>
-  *   <dd>In-phase events are generated as specific events from the
-  *       PageEventFilter (or elsewhere), on a per-listener basis. There may
-  *       be many such events during a particular phase.
-  *   </dd>
-  * </dl>
-  * <p>
-  * E.g., a typical event sequence for the pre-translate phase would be:
-  * </p>
-  * <ol>
-  *  <li>PRE_TRANSLATE_BEGIN</li>
-  *  <li>PRE_TRANSLATE</li>
-  *  <li>PRE_TRANSLATE</li>
-  *  <li>...</li>
-  *  <li>PRE_TRANSLATE_END</li>
-  * </ol>
-  *
-  * <h2>Notes</h2>
-  *
-  * <h3>Page Requested and Delivered Events</h3>
-  * <p>
-  * These two events are fired once per page request, at the beginning
-  * and after delivery of the page (respectively). They are generated
-  * by the {@link org.apache.wiki.ui.WikiServletFilter}.
-  * </p>
-  *
-  * <h3>Page Lock and Unlock Events</h3>
-  * <p>
-  * Page lock and unlock events occur only once during an editing session,
-  * so there are no begin and end events. They are generated
-  * by the {@link org.apache.wiki.pages.PageManager}.
-  * </p>
-  *
-  * <h3>WikiPageEvents</h3>
-  * <p>
-  * Other WikiPageEvents include both <i>phase boundary</i> and <i>in-phase</i>
-  * events for saving, pre- and post-translating content. These are very noisy 
-  * event types, but are not fired unless a listener is available. They are
-  * generated by the {@link org.apache.wiki.api.engine.FilterManager},
-  * {@link org.apache.wiki.event.PageEventFilter}, and potentially other 
-  * implementing classes.
-  * </p>
-  *
-  * <h3>Firing Order and Phase Boundaries</h3>
-  * <p>
-  * Note that due to the asynchronous nature of event processing, any threads
-  * spawned by such events will not necessarily have completed during their
-  * specific phase; we can assume only that no more events of that phase will
-  * be fired after its <tt>*_END</tt> event has been fired.
-  * </p>
-  *
-  * @see     org.apache.wiki.event.WikiEvent
-  * @since   2.4.20
-  */
-public class WikiPageEvent extends WikiEvent
-{
-    // PAGE LOCKING EVENTS ...
+ * WikiPageEvent indicates a change in the state or processing of a WikiPage. There are basically two types of page events:
+ * <dl>
+ *   <dt><b>Phase Boundary Events</b></dt>
+ *   <dd>Those considered as "beginning-of-phase", and those as "end-of-phase" events (as designated by <tt>*_BEGIN</tt> and
+ *        <tt>*_END</tt>), as generated by the WikiEngine. The phases include pre-save, post-save, pre-translate, and post-translate.
+ *   </dd>
+ *   <dt><b>In-Phase Events</b></dt>
+ *   <dd>In-phase events are generated as specific events from the PageEventFilter (or elsewhere), on a per-listener basis. There may
+ *       be many such events during a particular phase.
+ *   </dd>
+ * </dl>
+ * <p>
+ * E.g., a typical event sequence for the pre-translate phase would be:
+ * </p>
+ * <ol>
+ *  <li>PRE_TRANSLATE_BEGIN</li>
+ *  <li>PRE_TRANSLATE</li>
+ *  <li>PRE_TRANSLATE</li>
+ *  <li>...</li>
+ *  <li>PRE_TRANSLATE_END</li>
+ * </ol>
+ *
+ * <h2>Notes</h2>
+ *
+ * <h3>Page Requested and Delivered Events</h3>
+ * <p>
+ * These two events are fired once per page request, at the beginning and after delivery of the page (respectively). They are generated
+ * by the {@link org.apache.wiki.ui.WikiServletFilter}.
+ * </p>
+ *
+ * <h3>Page Lock and Unlock Events</h3>
+ * <p>
+ * Page lock and unlock events occur only once during an editing session, so there are no begin and end events. They are generated
+ * by the {@link org.apache.wiki.pages.PageManager}.
+ * </p>
+ *
+ * <h3>WikiPageEvents</h3>
+ * <p>
+ * Other WikiPageEvents include both <i>phase boundary</i> and <i>in-phase</i> events for saving, pre- and post-translating content.
+ * These are very noisy event types, but are not fired unless a listener is available. They are generated by the
+ * {@link org.apache.wiki.api.engine.FilterManager}, {@link org.apache.wiki.filters.PageEventFilter}, and potentially other
+ * implementing classes.
+ * </p>
+ *
+ * <h3>Firing Order and Phase Boundaries</h3>
+ * <p>
+ * Note that due to the asynchronous nature of event processing, any threads spawned by such events will not necessarily have completed
+ * during their specific phase; we can assume only that no more events of that phase will be fired after its <tt>*_END</tt> event has
+ * been fired.
+ * </p>
+ *
+ * @see     org.apache.wiki.event.WikiEvent
+ * @since   2.4.20
+ */
+public class WikiPageEvent extends WikiEvent {
 
-    /**
-     * 
-     */
     private static final long serialVersionUID = 1L;
 
-    /** Indicates a page lock event. This is based on events
-      * generated by {@link org.apache.wiki.pages.PageManager}. */
+    // PAGE LOCKING EVENTS ...
+
+    /** Indicates a page lock event. This is based on events generated by {@link org.apache.wiki.pages.PageManager}. */
     public static final int PAGE_LOCK            = 10;
 
-    /** Indicates a page unlock event. This is based on events
-      * generated by {@link org.apache.wiki.pages.PageManager}. */
+    /** Indicates a page unlock event. This is based on events generated by {@link org.apache.wiki.pages.PageManager}. */
     public static final int PAGE_UNLOCK          = 11;
 
     // PRE_TRANSLATE .........
@@ -108,7 +94,7 @@ public class WikiPageEvent extends WikiEvent
     public static final int PRE_TRANSLATE_BEGIN  = 12;
 
     /** Indicates a wiki pre-translate page event. This is based on events
-      * generated by {@link org.apache.wiki.event.PageEventFilter}. */
+      * generated by {@link org.apache.wiki.filters.PageEventFilter}. */
     public static final int PRE_TRANSLATE        = 13;
 
     /** Indicates the end of all wiki pre-translate page events. This is based
@@ -122,7 +108,7 @@ public class WikiPageEvent extends WikiEvent
     public static final int POST_TRANSLATE_BEGIN = 15;
 
     /** Indicates a wiki post-translate page event. This is based on events
-      * generated by {@link org.apache.wiki.event.PageEventFilter}. */
+      * generated by {@link org.apache.wiki.filters.PageEventFilter}. */
     public static final int POST_TRANSLATE       = 16;
 
     /** Indicates the end of all wiki post-translate page events. This is based
@@ -135,8 +121,7 @@ public class WikiPageEvent extends WikiEvent
       * on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
     public static final int PRE_SAVE_BEGIN       = 18;
 
-    /** Indicates a wiki pre-save page event. This is based on events
-      * generated by {@link org.apache.wiki.event.PageEventFilter}. */
+    /** Indicates a wiki pre-save page event. This is based on events generated by {@link org.apache.wiki.filters.PageEventFilter}. */
     public static final int PRE_SAVE             = 19;
 
     /** Indicates the end of all wiki pre-save page events. This is based
@@ -149,82 +134,72 @@ public class WikiPageEvent extends WikiEvent
       * on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
     public static final int POST_SAVE_BEGIN      = 21;
 
-    /** Indicates a wiki post-save page event. This is based on events
-      * generated by {@link org.apache.wiki.event.PageEventFilter}. */
+    /** Indicates a wiki post-save page event. This is based on events generated by {@link org.apache.wiki.filters.PageEventFilter}. */
     public static final int POST_SAVE            = 22;
 
     /** Indicates the end of all wiki post-save page events. This is based
-      * on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
+     *  on events generated by {@link org.apache.wiki.api.engine.FilterManager}. */
     public static final int POST_SAVE_END        = 23;
 
     // PAGE REQUESTS .........
 
     /** Indicates a wiki page request event (the start of a request). This is based
-      * on events generated by {@link org.apache.wiki.ui.WikiServletFilter}. */
+     *  on events generated by {@link org.apache.wiki.ui.WikiServletFilter}. */
     public static final int PAGE_REQUESTED       = 24;
 
     /** Indicates a wiki page delivery event (the end of a request). This is based
-      * on events generated by {@link org.apache.wiki.ui.WikiServletFilter}. */
+     *  on events generated by {@link org.apache.wiki.ui.WikiServletFilter}. */
     public static final int PAGE_DELIVERED       = 25;
 
     /** Indicates a wiki page delete event (the beginning of a delete request). 
-      * This is based on events generated by {@link org.apache.wiki.ui.WikiServletFilter}. 
-      * @since 2.4.65 */
+     * This is based on events generated by {@link org.apache.wiki.ui.WikiServletFilter}.
+     * @since 2.4.65 */
     public static final int PAGE_DELETE_REQUEST  = 26;
 
     /** Indicates a wiki page deleted event (after the delete has been completed). 
-      * This is based on events generated by {@link org.apache.wiki.ui.WikiServletFilter}. 
-      * @since 2.4.65 */
+     * This is based on events generated by {@link org.apache.wiki.ui.WikiServletFilter}.
+     * @since 2.4.65 */
     public static final int PAGE_DELETED         = 27;
 
-    private String m_pagename     = null;
+    private String m_pagename;
 
     // ............
 
-
     /**
       * Constructs an instance of this event.
-      * @param src    the Object that is the source of the event.
-      * @param type      the type of the event (see the enumerated int values defined
-      *                  in {@link org.apache.wiki.event.WikiEvent}).
-      * @param pagename  the WikiPage being acted upon.
+     *
+      * @param src  the Object that is the source of the event.
+      * @param type the type of the event (see the enumerated int values defined in {@link org.apache.wiki.event.WikiEvent}).
+      * @param pagename the WikiPage being acted upon.
       */
-    public WikiPageEvent( Object src, int type, String pagename )
-    {
+    public WikiPageEvent( final Object src, final int type, final String pagename ) {
         super( src, type );
         m_pagename = pagename;
     }
 
-
-   /**
-     * Returns the Wiki page name associated with this event.
-     * This may be null if unavailable.
+    /**
+     * Returns the Wiki page name associated with this event. This may be null if unavailable.
      *
-     * @return     the Wiki page name associated with this WikiEvent, or null.
+     * @return the Wiki page name associated with this WikiEvent, or null.
      */
-    public String getPageName()
-    {
+    public String getPageName() {
         return m_pagename;
     }
 
-
-   /**
+    /**
      * Returns true if the int value is a WikiPageEvent type.
      */
-    public static boolean isValidType( int type )
-    {
+    public static boolean isValidType( final int type ) {
         return type >= PAGE_LOCK && type <= PAGE_DELETED;
     }
 
-
     /**
      * Returns a textual representation of the event type.
+     *
      * @return a String representation of the type
      */
-    public String eventName()
-    {
-        switch ( getType() )
-        {
+    public String eventName() {
+        switch ( getType() ) {
             case PAGE_LOCK:            return "PAGE_LOCK";
             case PAGE_UNLOCK:          return "PAGE_UNLOCK";
 
@@ -245,23 +220,22 @@ public class WikiPageEvent extends WikiEvent
             case POST_SAVE_END:        return "POST_SAVE_END";
 
             case PAGE_REQUESTED:       return "PAGE_REQUESTED";
-            case PAGE_DELIVERED:       return "PAGE_DELIVERED";     
+            case PAGE_DELIVERED:       return "PAGE_DELIVERED";
 
-            case PAGE_DELETE_REQUEST:  return "PAGE_DELETE_REQUEST";     
-            case PAGE_DELETED:         return "PAGE_DELETED";     
+            case PAGE_DELETE_REQUEST:  return "PAGE_DELETE_REQUEST";
+            case PAGE_DELETED:         return "PAGE_DELETED";
 
             default:                   return super.eventName();
         }
     }
 
-
-   /** Returns a human-readable description of the event type.
+    /**
+     * Returns a human-readable description of the event type.
+     *
      * @return a String description of the type
      */
-    public String getTypeDescription()
-    {
-        switch ( getType() )
-        {
+    public String getTypeDescription() {
+        switch ( getType() ) {
             case PAGE_LOCK:            return "page lock event";
             case PAGE_UNLOCK:          return "page unlock event";
 
@@ -282,7 +256,7 @@ public class WikiPageEvent extends WikiEvent
             case POST_SAVE_END:        return "end of page post-save events";
 
             case PAGE_REQUESTED:       return "page requested event";
-            case PAGE_DELIVERED:       return "page delivered event";     
+            case PAGE_DELIVERED:       return "page delivered event";
 
             case PAGE_DELETE_REQUEST:  return "page delete request event";
             case PAGE_DELETED:         return "page deleted event";
@@ -291,4 +265,4 @@ public class WikiPageEvent extends WikiEvent
         }
     }
 
-} // end class org.apache.wiki.event.WikiPageEvent
+}


[jspwiki] 31/32: Update ASF parent pom to version 23

Posted by ju...@apache.org.
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 593f947429875591c8c383c336bb3828d303771c
Author: juanpablo <ju...@apache.org>
AuthorDate: Tue Jan 28 21:20:25 2020 +0100

    Update ASF parent pom to version 23
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 9c8c5e4..869d711 100644
--- a/pom.xml
+++ b/pom.xml
@@ -22,7 +22,7 @@
   <parent>
     <groupId>org.apache</groupId>
     <artifactId>apache</artifactId>
-    <version>22</version>
+    <version>23</version>
   </parent>
 
   <groupId>org.apache.jspwiki</groupId>


[jspwiki] 26/32: JSPWIKI-120: rename CommandResolver as DefaultCommandResolver and extract CommandResolver interface from it

Posted by ju...@apache.org.
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 6c42eb192724ef8c6ca691bc3ec392a8550f3ebb
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 23 22:43:45 2020 +0100

    JSPWIKI-120: rename CommandResolver as DefaultCommandResolver and extract CommandResolver interface from it
    
    Also, do not instantiate it directly on WikiEngine
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  |   8 +-
 .../java/org/apache/wiki/ui/CommandResolver.java   | 294 ++-------------------
 ...ndResolver.java => DefaultCommandResolver.java} | 109 ++------
 .../src/main/resources/ini/classmappings.xml       |   4 +
 4 files changed, 40 insertions(+), 375 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 873d583..29079b6 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -405,9 +405,6 @@ public class WikiEngine  {
 
         log.debug( "Configuring WikiEngine..." );
 
-        //  Initializes the CommandResolver
-        m_commandResolver = new CommandResolver( this, props );
-
         //  Create and find the default working directory.
         m_workDir = TextUtil.getStringProperty( props, PROP_WORKDIR, null );
 
@@ -453,6 +450,8 @@ public class WikiEngine  {
         //
         // FIXME: This part of the code is getting unwieldy.  We must think of a better way to do the startup-sequence.
         try {
+            //  Initializes the CommandResolver
+            m_commandResolver = ClassUtil.getMappedObject( CommandResolver.class.getName(), this, props );
             final Class< ? > urlclass = ClassUtil.findClass( "org.apache.wiki.url",
                                                              TextUtil.getStringProperty( props, PROP_URLCONSTRUCTOR, "DefaultURLConstructor" ) );
             m_urlConstructor = ( URLConstructor ) urlclass.getDeclaredConstructor().newInstance();
@@ -520,8 +519,7 @@ public class WikiEngine  {
         } catch( final Exception e ) {
             // Final catch-all for everything
             log.fatal( "JSPWiki could not start, due to an unknown exception when starting.",e );
-            throw new WikiException( "Failed to start. Caused by: " + e.getMessage() +
-                                     "; please check log files for better information.", e );
+            throw new WikiException( "Failed to start. Caused by: " + e.getMessage() + "; please check log files for better information.", e );
         }
 
         //
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 0e68e70..350523f 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
@@ -18,21 +18,12 @@
  */
 package org.apache.wiki.ui;
 
-import org.apache.log4j.Logger;
-import org.apache.wiki.InternalWikiException;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
-import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.exceptions.ProviderException;
-import org.apache.wiki.auth.GroupPrincipal;
-import org.apache.wiki.parser.MarkupParser;
-import org.apache.wiki.util.TextUtil;
 
 import javax.servlet.http.HttpServletRequest;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
+import java.util.Arrays;
+
 
 /**
  * <p>Resolves special pages, JSPs and Commands on behalf of a WikiEngine. CommandResolver will automatically resolve page names
@@ -53,70 +44,10 @@ import java.util.Properties;
  *
  * @since 2.4.22
  */
-public final class CommandResolver {
-    /** Prefix in jspwiki.properties signifying special page keys. */
-    private static final String PROP_SPECIALPAGE = "jspwiki.specialPage.";
-
-    /** Private map with request contexts as keys, Commands as values */
-    private static final Map< String, Command > CONTEXTS;
-
-    /** Private map with JSPs as keys, Commands as values */
-    private static final Map< String, Command > JSPS;
-
-    /* Store the JSP-to-Command and context-to-Command mappings */
-    static {
-        CONTEXTS = new HashMap<>();
-        JSPS = new HashMap<>();
-        final Command[] commands = AbstractCommand.allCommands();
-        for( final Command command : commands ) {
-            JSPS.put( command.getJSP(), command );
-            CONTEXTS.put( command.getRequestContext(), command );
-        }
-    }
-
-    private static final Logger LOG = Logger.getLogger( CommandResolver.class );
-
-    private final WikiEngine m_engine;
-
-    /** If true, we'll also consider english plurals (+s) a match. */
-    private final boolean m_matchEnglishPlurals;
-
-    /** Stores special page names as keys, and Commands as values. */
-    private final Map<String, Command> m_specialPages;
-
-    /**
-     * Constructs a CommandResolver for a given WikiEngine. This constructor will extract the special page references for this wiki and
-     * store them in a cache used for resolution.
-     *
-     * @param engine the wiki engine
-     * @param properties the properties used to initialize the wiki
-     */
-    public CommandResolver( final WikiEngine engine, final Properties properties ) {
-        m_engine = engine;
-        m_specialPages = new HashMap<>();
-
-        // Skim through the properties and look for anything with the "special page" prefix. Create maps that allow us look up
-        // the correct Command based on special page name. If a matching command isn't found, create a RedirectCommand.
-        for( final String key : properties.stringPropertyNames() ) {
-            if ( key.startsWith( PROP_SPECIALPAGE ) ) {
-                String specialPage = key.substring( PROP_SPECIALPAGE.length() );
-                String jsp = properties.getProperty( key );
-                if ( jsp != null ) {
-                    specialPage = specialPage.trim();
-                    jsp = jsp.trim();
-                    Command command = JSPS.get( jsp );
-                    if ( command == null ) {
-                        final Command redirect = RedirectCommand.REDIRECT;
-                        command = redirect.targetedCommand( jsp );
-                    }
-                    m_specialPages.put( specialPage, command );
-                }
-            }
-        }
+public interface CommandResolver {
 
-        // Do we match plurals?
-        m_matchEnglishPlurals = TextUtil.getBooleanProperty( properties, WikiEngine.PROP_MATCHPLURALS, true );
-    }
+    /** Prefix in jspwiki.properties signifying special page keys. */
+    String PROP_SPECIALPAGE = "jspwiki.specialPage.";
 
     /**
      * Attempts to locate a wiki command for a supplied request context. The resolution technique is simple: we examine the list of
@@ -126,12 +57,11 @@ public final class CommandResolver {
      * @param context the request context
      * @return the resolved context
      */
-    public static Command findCommand( final String context ) {
-        final Command command = CONTEXTS.get( context );
-        if ( command == null ) {
-            throw new IllegalArgumentException( "Unsupported wiki context: " + context + "." );
-        }
-        return command;
+    static Command findCommand( final String context ) {
+        return Arrays.stream( AbstractCommand.allCommands() )
+                     .filter( c -> c.getRequestContext().equals( context ) )
+                     .findFirst()
+                     .orElseThrow( () -> new IllegalArgumentException( "Unsupported wiki context: " + context + "." ) );
     }
 
     /**
@@ -152,68 +82,7 @@ public final class CommandResolver {
      * @param defaultContext the request context to use by default
      * @return the resolved wiki command
      */
-    public Command findCommand( final HttpServletRequest request, final String defaultContext ) {
-        // Corner case if request is null
-        if ( request == null ) {
-            return findCommand( defaultContext );
-        }
-
-        Command command = null;
-
-        // Determine the name of the page (which may be null)
-        String pageName = extractPageFromParameter( defaultContext, request );
-
-        // Can we find a special-page command matching the extracted page?
-        if ( pageName != null ) {
-            command = m_specialPages.get( pageName );
-        }
-
-        // If we haven't found a matching command yet, extract the JSP path and compare to our list of special pages
-        if ( command == null ) {
-            command = extractCommandFromPath( request );
-
-            // Otherwise: use the default context
-            if ( command == null ) {
-                command = CONTEXTS.get( defaultContext );
-                if ( command == null ) {
-                    throw new IllegalArgumentException( "Wiki context " + defaultContext + " is illegal." );
-                }
-            }
-        }
-
-        // For PageCommand.VIEW, default to front page if a page wasn't supplied
-        if( PageCommand.VIEW.equals( command ) && pageName == null ) {
-            pageName = m_engine.getFrontPage();
-        }
-
-        // These next blocks handle targeting requirements
-
-        // If we were passed a page parameter, try to resolve it
-        if ( command instanceof PageCommand && pageName != null ) {
-            // If there's a matching WikiPage, "wrap" the command
-            final WikiPage page = resolvePage( request, pageName );
-            return command.targetedCommand( page );
-        }
-
-        // If "create group" command, target this wiki
-        final String wiki = m_engine.getApplicationName();
-        if ( WikiCommand.CREATE_GROUP.equals( command ) ) {
-            return WikiCommand.CREATE_GROUP.targetedCommand( wiki );
-        }
-
-        // If group command, see if we were passed a group name
-        if( command instanceof GroupCommand ) {
-            String groupName = request.getParameter( "group" );
-            groupName = TextUtil.replaceEntities( groupName );
-            if ( groupName != null && groupName.length() > 0 ) {
-                final GroupPrincipal group = new GroupPrincipal( groupName );
-                return command.targetedCommand( group );
-            }
-        }
-
-        // No page provided; return an "ordinary" command
-        return command;
-    }
+    Command findCommand( HttpServletRequest request, String defaultContext );
 
     /**
      * <p>Returns the correct page name, or <code>null</code>, if no such page can be found. Aliases are considered.</p>
@@ -228,37 +97,7 @@ public final class CommandResolver {
      * @return The rewritten page name, or <code>null</code>, if the page does not exist.
      * @throws ProviderException if the underlyng page provider that locates pages throws an exception
      */
-    public String getFinalPageName( final String page ) throws ProviderException {
-        boolean isThere = simplePageExists( page );
-        String  finalName = page;
-
-        if ( !isThere && m_matchEnglishPlurals ) {
-            if ( page.endsWith( "s" ) ) {
-                finalName = page.substring( 0, page.length() - 1 );
-            } else {
-                finalName += "s";
-            }
-
-            isThere = simplePageExists( finalName );
-        }
-
-        if( !isThere ) {
-            finalName = MarkupParser.wikifyLink( page );
-            isThere = simplePageExists(finalName);
-
-            if( !isThere && m_matchEnglishPlurals ) {
-                if( finalName.endsWith( "s" ) ) {
-                    finalName = finalName.substring( 0, finalName.length() - 1 );
-                } else {
-                    finalName += "s";
-                }
-
-                isThere = simplePageExists( finalName );
-            }
-        }
-
-        return isThere ? finalName : null;
-    }
+    String getFinalPageName( String page ) throws ProviderException;
 
     /**
      * <p>If the page is a special page, this method returns a direct URL to that page; otherwise, it returns <code>null</code>.</p>
@@ -268,53 +107,7 @@ public final class CommandResolver {
      * @param page the page name ro search for
      * @return the URL of the special page, if the supplied page is one, or <code>null</code>
      */
-    public String getSpecialPageReference( final String page ) {
-        final Command command = m_specialPages.get( page );
-        if ( command != null ) {
-            return m_engine.getURLConstructor().makeURL( command.getRequestContext(), command.getURLPattern(), null );
-        }
-
-        return null;
-    }
-
-    /**
-     * Extracts a Command based on the JSP path of an HTTP request. If the JSP requested matches a Command's <code>getJSP()</code>
-     * value, that Command is returned.
-     *
-     * @param request the HTTP request
-     * @return the resolved Command, or <code>null</code> if not found
-     */
-    protected Command extractCommandFromPath( final HttpServletRequest request ) {
-        String jsp = request.getServletPath();
-
-        // Take everything to right of initial / and left of # or ?
-        final int hashMark = jsp.indexOf( '#' );
-        if ( hashMark != -1 ) {
-            jsp = jsp.substring( 0, hashMark );
-        }
-        final int questionMark = jsp.indexOf( '?' );
-        if ( questionMark != -1 ) {
-            jsp = jsp.substring( 0, questionMark );
-        }
-        if ( jsp.startsWith( "/" ) ) {
-            jsp = jsp.substring( 1 );
-        }
-
-        // Find special page reference?
-        for( final Map.Entry< String, Command > entry : m_specialPages.entrySet() ) {
-            final Command specialCommand = entry.getValue();
-            if( specialCommand.getJSP().equals( jsp ) ) {
-                return specialCommand;
-            }
-        }
-
-        // Still haven't found a matching command? Ok, see if we match against our standard list of JSPs
-        if ( jsp.length() > 0 && JSPS.containsKey( jsp ) ) {
-            return JSPS.get( jsp );
-        }
-
-        return null;
-    }
+    String getSpecialPageReference( final String page );
 
     /**
      * Determines the correct wiki page based on a supplied request context and HTTP request. This method attempts to determine the page
@@ -331,30 +124,7 @@ public final class CommandResolver {
      * @param request the HTTP request
      * @return the resolved page name
      */
-    protected String extractPageFromParameter( final String requestContext, final HttpServletRequest request ) {
-        // Extract the page name from the URL directly
-        try {
-            String page = m_engine.getURLConstructor().parsePage( requestContext, request, m_engine.getContentEncoding() );
-            if ( page != null ) {
-                try {
-                    // Look for singular/plural variants; if one not found, take the one the user supplied
-                    final String finalPage = getFinalPageName( page );
-                    if ( finalPage != null ) {
-                        page = finalPage;
-                    }
-                } catch( final ProviderException e ) {
-                    // FIXME: Should not ignore!
-                }
-                return page;
-            }
-        } catch( final IOException e ) {
-            LOG.error( "Unable to create context", e );
-            throw new InternalWikiException( "Big internal booboo, please check logs." , e );
-        }
-
-        // Didn't resolve; return null
-        return null;
-    }
+    String extractPageFromParameter( String requestContext, HttpServletRequest request );
 
     /**
      * Looks up and returns the correct, versioned WikiPage based on a supplied page name and optional <code>version</code> parameter
@@ -364,40 +134,6 @@ public final class CommandResolver {
      * @param page the name of the page to look up; this page <em>must</em> exist
      * @return the wiki page
      */
-    protected WikiPage resolvePage( final HttpServletRequest request, String page ) {
-        // See if the user included a version parameter
-        int version = WikiProvider.LATEST_VERSION;
-        final String rev = request.getParameter( "version" );
-        if ( rev != null ) {
-            try {
-                version = Integer.parseInt( rev );
-            } catch( final NumberFormatException e ) {
-                // This happens a lot with bots or other guys who are trying to test if we are vulnerable to e.g. XSS attacks.  We catch
-                // it here so that the admin does not get tons of mail.
-            }
-        }
-
-        WikiPage wikipage = m_engine.getPageManager().getPage( page, version );
-        if ( wikipage == null ) {
-            page = MarkupParser.cleanLink( page );
-            wikipage = new WikiPage( m_engine, page );
-        }
-        return wikipage;
-    }
-
-    /**
-     * Determines whether a "page" exists by examining the list of special pages and querying the page manager.
-     *
-     * @param page the page to seek
-     * @return <code>true</code> if the page exists, <code>false</code> otherwise
-     * @throws ProviderException if the underlyng page provider that locates pages
-     * throws an exception
-     */
-    protected boolean simplePageExists( final String page ) throws ProviderException {
-        if ( m_specialPages.containsKey( page ) ) {
-            return true;
-        }
-        return m_engine.getPageManager().pageExists( page );
-    }
+    WikiPage resolvePage( HttpServletRequest request, String page );
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java
similarity index 60%
copy from jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java
copy to jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java
index 0e68e70..65348ed 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java
@@ -34,28 +34,13 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
 
+
 /**
- * <p>Resolves special pages, JSPs and Commands on behalf of a WikiEngine. CommandResolver will automatically resolve page names
- * with singular/plural variants. It can also detect the correct Command based on parameters supplied in an HTTP request, or due to the
- * JSP being accessed.</p>
- * <p>
- * <p>CommandResolver's static {@link #findCommand(String)} method is the simplest method; it looks up and returns the Command matching
- * a supplied wiki context. For example, looking up the request context <code>view</code> returns {@link PageCommand#VIEW}. Use this method
- * to obtain static Command instances that aren't targeted at a particular page or group.</p>
- * <p>For more complex lookups in which the caller supplies an HTTP request, {@link #findCommand(HttpServletRequest, String)} will
- * look up and return the correct Command. The String parameter <code>defaultContext</code> supplies the request context to use
- * if it cannot be detected. However, note that the default wiki context may be overridden if the request was for a "special page."</p>
- * <p>For example, suppose the WikiEngine's properties specify a special page called <code>UserPrefs</code> that redirects to
- * <code>UserPreferences.jsp</code>. The ordinary lookup method {@linkplain #findCommand(String)} using a supplied context <code>view</code>
- * would return {@link PageCommand#VIEW}. But the {@linkplain #findCommand(HttpServletRequest, String)} method, when passed the same context
- * (<code>view</code>) and an HTTP request containing the page parameter value <code>UserPrefs</code>, will instead return
- * {@link WikiCommand#PREFS}.</p>
+ * <p>Default implementation for {@link CommandResolver}</p>
  *
  * @since 2.4.22
  */
-public final class CommandResolver {
-    /** Prefix in jspwiki.properties signifying special page keys. */
-    private static final String PROP_SPECIALPAGE = "jspwiki.specialPage.";
+public final class DefaultCommandResolver implements CommandResolver {
 
     /** Private map with request contexts as keys, Commands as values */
     private static final Map< String, Command > CONTEXTS;
@@ -74,7 +59,7 @@ public final class CommandResolver {
         }
     }
 
-    private static final Logger LOG = Logger.getLogger( CommandResolver.class );
+    private static final Logger LOG = Logger.getLogger( DefaultCommandResolver.class );
 
     private final WikiEngine m_engine;
 
@@ -91,7 +76,7 @@ public final class CommandResolver {
      * @param engine the wiki engine
      * @param properties the properties used to initialize the wiki
      */
-    public CommandResolver( final WikiEngine engine, final Properties properties ) {
+    public DefaultCommandResolver( final WikiEngine engine, final Properties properties ) {
         m_engine = engine;
         m_specialPages = new HashMap<>();
 
@@ -119,43 +104,13 @@ public final class CommandResolver {
     }
 
     /**
-     * Attempts to locate a wiki command for a supplied request context. The resolution technique is simple: we examine the list of
-     * Commands returned by {@link AbstractCommand#allCommands()} and return the one whose <code>requestContext</code> matches the
-     * supplied context. If the supplied context does not resolve to a known Command, this method throws an {@link IllegalArgumentException}.
-     *
-     * @param context the request context
-     * @return the resolved context
-     */
-    public static Command findCommand( final String context ) {
-        final Command command = CONTEXTS.get( context );
-        if ( command == null ) {
-            throw new IllegalArgumentException( "Unsupported wiki context: " + context + "." );
-        }
-        return command;
-    }
-
-    /**
-     * <p>Attempts to locate a Command for a supplied wiki context and HTTP request, incorporating the correct WikiPage into the command
-     * if required. This method will first determine what page the user requested by delegating to {@link #extractPageFromParameter(String, HttpServletRequest)}.
-     * If this page equates to a special page, we return the Command corresponding to that page. Otherwise, this method simply returns the
-     * Command for the supplied request context.</p>
-     * <p>The reason this method attempts to resolve against special pages is because some of them resolve to contexts that may be different
-     * from the one supplied. For example, a VIEW request context for the special page "UserPreferences" should return a PREFS context instead.</p>
-     * <p>When the caller supplies a request context and HTTP request that specifies an actual wiki page (rather than a special page),
-     * this method will return a "targeted" Command that includes the resolved WikiPage as the target. (See {@link #resolvePage(HttpServletRequest, String)}
-     * for the resolution algorithm). Specifically, the Command will return a non-<code>null</code> value for
-     * its {@link AbstractCommand#getTarget()} method.</p>
-     * <p><em>Note: if this method determines that the Command is the VIEW PageCommand, then the Command returned will always be targeted to
-     * the front page.</em></p>
-     *
-     * @param request the HTTP request; if <code>null</code>, delegates to {@link #findCommand(String)}
-     * @param defaultContext the request context to use by default
-     * @return the resolved wiki command
+     * {@inheritDoc}
      */
+    @Override
     public Command findCommand( final HttpServletRequest request, final String defaultContext ) {
         // Corner case if request is null
         if ( request == null ) {
-            return findCommand( defaultContext );
+            return CommandResolver.findCommand( defaultContext );
         }
 
         Command command = null;
@@ -216,18 +171,9 @@ public final class CommandResolver {
     }
 
     /**
-     * <p>Returns the correct page name, or <code>null</code>, if no such page can be found. Aliases are considered.</p>
-     * <p>In some cases, page names can refer to other pages. For example, when you have matchEnglishPlurals set, then a page name
-     * "Foobars" will be transformed into "Foobar", should a page "Foobars" not exist, but the page "Foobar" would. This method gives
-     * you the correct page name to refer to. </p>
-     * <p>This facility can also be used to rewrite any page name, for example, by using aliases. It can also be used to check the
-     * existence of any page.</p>
-     *
-     * @since 2.4.20
-     * @param page the page name.
-     * @return The rewritten page name, or <code>null</code>, if the page does not exist.
-     * @throws ProviderException if the underlyng page provider that locates pages throws an exception
+     * {@inheritDoc}
      */
+    @Override
     public String getFinalPageName( final String page ) throws ProviderException {
         boolean isThere = simplePageExists( page );
         String  finalName = page;
@@ -261,13 +207,9 @@ public final class CommandResolver {
     }
 
     /**
-     * <p>If the page is a special page, this method returns a direct URL to that page; otherwise, it returns <code>null</code>.</p>
-     * <p>Special pages are non-existant references to other pages. For example, you could define a special page reference "RecentChanges"
-     * which would always be redirected to "RecentChanges.jsp" instead of trying to find a Wiki page called "RecentChanges".</p>
-     *
-     * @param page the page name ro search for
-     * @return the URL of the special page, if the supplied page is one, or <code>null</code>
+     * {@inheritDoc}
      */
+    @Override
     public String getSpecialPageReference( final String page ) {
         final Command command = m_specialPages.get( page );
         if ( command != null ) {
@@ -317,21 +259,10 @@ public final class CommandResolver {
     }
 
     /**
-     * Determines the correct wiki page based on a supplied request context and HTTP request. This method attempts to determine the page
-     * requested by a user, taking into acccount special pages. The resolution algorithm will:
-     * <ul>
-     * <li>Extract the page name from the URL according to the rules for the current {@link org.apache.wiki.url.URLConstructor}. If a
-     * page name was passed in the request, return the correct name after taking into account potential plural matches.</li>
-     * <li>If the extracted page name is <code>null</code>, attempt to see if a "special page" was intended by examining the servlet path.
-     * For example, the request path "/UserPreferences.jsp" will resolve to "UserPreferences."</li>
-     * <li>If neither of these methods work, this method returns <code>null</code></li>
-     * </ul>
-     *
-     * @param requestContext the request context
-     * @param request the HTTP request
-     * @return the resolved page name
+     * {@inheritDoc}
      */
-    protected String extractPageFromParameter( final String requestContext, final HttpServletRequest request ) {
+    @Override
+    public String extractPageFromParameter( final String requestContext, final HttpServletRequest request ) {
         // Extract the page name from the URL directly
         try {
             String page = m_engine.getURLConstructor().parsePage( requestContext, request, m_engine.getContentEncoding() );
@@ -357,14 +288,10 @@ public final class CommandResolver {
     }
 
     /**
-     * Looks up and returns the correct, versioned WikiPage based on a supplied page name and optional <code>version</code> parameter
-     * passed in an HTTP request. If the <code>version</code> parameter does not exist in the request, the latest version is returned.
-     *
-     * @param request the HTTP request
-     * @param page the name of the page to look up; this page <em>must</em> exist
-     * @return the wiki page
+     * {@inheritDoc}
      */
-    protected WikiPage resolvePage( final HttpServletRequest request, String page ) {
+    @Override
+    public WikiPage resolvePage( final HttpServletRequest request, String page ) {
         // See if the user included a version parameter
         int version = WikiProvider.LATEST_VERSION;
         final String rev = request.getParameter( "version" );
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index 3f5bd1f..160761c 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -116,6 +116,10 @@
     <mappedClass>org.apache.wiki.tasks.DefaultTasksManager</mappedClass>
   </mapping>
   <mapping>
+    <requestedClass>org.apache.wiki.ui.CommandResolver</requestedClass>
+    <mappedClass>org.apache.wiki.ui.DefaultCommandResolver</mappedClass>
+  </mapping>
+  <mapping>
     <requestedClass>org.apache.wiki.ui.EditorManager</requestedClass>
     <mappedClass>org.apache.wiki.ui.EditorManager</mappedClass>
   </mapping>


[jspwiki] 12/32: fix TestEngine so it uses a "3.1" compatible servlet context

Posted by ju...@apache.org.
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 c41fa091fc7799e62584a1bbca1cf2b8ed1389cf
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Jan 20 21:38:24 2020 +0100

    fix TestEngine so it uses a "3.1" compatible servlet context
    
    (it's a bit of a kludge, but enough right now)
---
 .../src/test/java/org/apache/wiki/TestEngine.java  | 17 +++++++++++++-
 .../test/java/org/apache/wiki/WikiServletTest.java | 26 ++++++++++------------
 2 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
index f97fa6e..7178bdd 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -135,13 +135,28 @@ public class TestEngine extends WikiEngine
     }
 
     public TestEngine( Properties props ) throws WikiException {
-        super( new MockServletContext( "test" ), "test", cleanTestProps( props ) );
+        super( createServletContext( "test" ), "test", cleanTestProps( props ) );
 
         // Stash the WikiEngine in the servlet context
         ServletContext servletContext = this.getServletContext();
         servletContext.setAttribute("org.apache.wiki.WikiEngine", this);
     }
 
+    public static MockServletContext createServletContext( final String contextName ) {
+        return new MockServletContext( contextName ) {
+
+            @Override
+            public int getMajorVersion() {
+                return 3;
+            }
+
+            @Override
+            public int getMinorVersion() {
+                return 1;
+            }
+        };
+    }
+
     /**
      * Creates a correctly-instantiated mock HttpServletRequest with an associated
      * HttpSession.
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/WikiServletTest.java b/jspwiki-main/src/test/java/org/apache/wiki/WikiServletTest.java
index d4d67b3..6b783b0 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiServletTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiServletTest.java
@@ -18,24 +18,22 @@
  */
 package org.apache.wiki;
 
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
 import net.sourceforge.stripes.mock.MockHttpServletRequest;
 import net.sourceforge.stripes.mock.MockHttpServletResponse;
 import net.sourceforge.stripes.mock.MockServletConfig;
-import net.sourceforge.stripes.mock.MockServletContext;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
 
 
 public class WikiServletTest {
     
     @Test
     public void testDoGet() throws Exception {
-        MockHttpServletRequest req = new MockHttpServletRequest( "/JSPWiki", "/wiki/Wiki.jsp" );
-        MockHttpServletResponse res = new MockHttpServletResponse();
-        WikiServlet wikiServlet = new WikiServlet();
-        MockServletConfig config = new MockServletConfig();
-        config.setServletContext( new MockServletContext( "/JSPWiki" ) );
+        final MockHttpServletRequest req = new MockHttpServletRequest( "/JSPWiki", "/wiki/Wiki.jsp" );
+        final MockHttpServletResponse res = new MockHttpServletResponse();
+        final WikiServlet wikiServlet = new WikiServlet();
+        final MockServletConfig config = new MockServletConfig();
+        config.setServletContext( TestEngine.createServletContext( "/JSPWiki" ) );
         
         wikiServlet.init( config );
         wikiServlet.doGet( req, res );
@@ -46,11 +44,11 @@ public class WikiServletTest {
     
     @Test
     public void testNastyDoPost() throws Exception {
-        MockHttpServletRequest req = new MockHttpServletRequest( "/JSPWiki", "/wiki/Edit.jsp" );
-        MockHttpServletResponse res = new MockHttpServletResponse();
-        WikiServlet wikiServlet = new WikiServlet();
-        MockServletConfig config = new MockServletConfig();
-        config.setServletContext( new MockServletContext( "/JSPWiki" ) );
+        final MockHttpServletRequest req = new MockHttpServletRequest( "/JSPWiki", "/wiki/Edit.jsp" );
+        final MockHttpServletResponse res = new MockHttpServletResponse();
+        final WikiServlet wikiServlet = new WikiServlet();
+        final MockServletConfig config = new MockServletConfig();
+        config.setServletContext( TestEngine.createServletContext( "/JSPWiki" ) );
         
         wikiServlet.init( config );
         wikiServlet.doPost( req, res );


[jspwiki] 18/32: JSPWIKI-1127: propagate changes on java code

Posted by ju...@apache.org.
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 74e04345f5dcb5c1e8b61828848d53f11c47af7a
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 22 23:22:32 2020 +0100

    JSPWIKI-1127: propagate changes on java code
---
 .../apache/wiki/attachment/AttachmentServlet.java  |   4 +-
 .../org/apache/wiki/auth/AuthorizationManager.java |   2 +-
 .../apache/wiki/filters/PingWeblogsComFilter.java  |  82 +++---
 .../main/java/org/apache/wiki/plugin/Groups.java   |  40 ++-
 .../main/java/org/apache/wiki/rss/AtomFeed.java    |   5 +-
 .../main/java/org/apache/wiki/rss/RSS10Feed.java   |  10 +-
 .../main/java/org/apache/wiki/rss/RSS20Feed.java   |   2 +-
 .../java/org/apache/wiki/rss/RSSGenerator.java     |  16 +-
 .../org/apache/wiki/tags/FeedDiscoveryTag.java     |  37 +--
 .../main/java/org/apache/wiki/tags/LinkTag.java    | 310 ++++++++-------------
 .../wiki/tasks/auth/SaveUserProfileTask.java       |   2 +-
 .../java/org/apache/wiki/ui/CommandResolver.java   |   3 +-
 .../org/apache/wiki/xmlrpc/MetaWeblogHandler.java  |   4 +-
 .../org/apache/wiki/search/SearchManagerTest.java  |   2 +-
 14 files changed, 201 insertions(+), 318 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
index 2bb0053..53c6b7f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
@@ -275,7 +275,7 @@ public class AttachmentServlet extends HttpServlet {
                     res.sendRedirect(
                         validateNextPage(
                             TextUtil.urlEncodeUTF8(nextPage),
-                            m_engine.getURL( WikiContext.ERROR, "", null, false )
+                            m_engine.getURL( WikiContext.ERROR, "", null )
                         )
                     );
                 }
@@ -420,7 +420,7 @@ public class AttachmentServlet extends HttpServlet {
     protected String upload( final HttpServletRequest req ) throws RedirectException, IOException {
         String msg     = "";
         final String attName = "(unknown)";
-        final String errorPage = m_engine.getURL( WikiContext.ERROR, "", null, false ); // If something bad happened, Upload should be able to take care of most stuff
+        final String errorPage = m_engine.getURL( WikiContext.ERROR, "", null ); // If something bad happened, Upload should be able to take care of most stuff
         String nextPage = errorPage;
         final String progressId = req.getParameter( "progressid" );
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
index 040046d..f7fb9c4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
@@ -432,7 +432,7 @@ public class AuthorizationManager {
                 log.info("User "+currentUser.getName()+" has no access - redirecting (permission=" + context.requiredPermission() + ")");
                 context.getWikiSession().addMessage( MessageFormat.format( rb.getString("security.error.noaccess"), context.getName() ) );
             }
-            response.sendRedirect( m_engine.getURL(WikiContext.LOGIN, pageurl, null, false ) );
+            response.sendRedirect( m_engine.getURL(WikiContext.LOGIN, pageurl, null ) );
         }
         return allowed;
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java
index 8cbe7bf..f2a139a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java
@@ -18,12 +18,6 @@
  */
 package org.apache.wiki.filters;
 
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Hashtable;
-import java.util.Properties;
-import java.util.Vector;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -31,17 +25,21 @@ import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.xmlrpc.AsyncCallback;
 import org.apache.xmlrpc.XmlRpcClient;
 
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Hashtable;
+import java.util.Properties;
+import java.util.Vector;
+
 /**
- *  A very dumb class that pings weblogs.com on each save.  INTERNAL USE ONLY SO FAR!
- *  Look, but don't use as-is.
+ *  A very dumb class that pings weblogs.com on each save.  INTERNAL USE ONLY SO FAR! Look, but don't use as-is.
  */
 // FIXME: Needs to figure out when only weblogs have been saved.
 // FIXME: rpc endpoint must be configurable
 // FIXME: Should really be settable per-page.
 // FIXME: Weblog name has been set to stone
-public class PingWeblogsComFilter
-    extends BasicPageFilter
-{
+public class PingWeblogsComFilter extends BasicPageFilter {
+
     private static final Logger log = Logger.getLogger( PingWeblogsComFilter.class );
 
     private String m_pingURL;
@@ -54,64 +52,52 @@ public class PingWeblogsComFilter
     /**
      *  {@inheritDoc}
      */
-    public void initialize( WikiEngine engine, Properties props )
-    {
+    public void initialize( final WikiEngine engine, final Properties props ) {
         m_pingURL = props.getProperty( PROP_PINGURL, "http://rpc.weblogs.com/RPC2" );
     }
 
     /**
      *  {@inheritDoc}
      */
-    public void postSave( WikiContext context, String pagecontent )
-    {
-        String     blogName = context.getPage().getName();
-        WikiEngine engine   = context.getEngine();
-
-        int blogentryTxt = blogName.indexOf("_blogentry_");
-        if( blogentryTxt == -1 )
-        {
+    public void postSave( final WikiContext context, final String pagecontent ) {
+        String blogName = context.getPage().getName();
+        final WikiEngine engine   = context.getEngine();
+
+        final int blogentryTxt = blogName.indexOf("_blogentry_");
+        if( blogentryTxt == -1 ) {
             return; // This is not a weblog entry.
         }
         
         blogName = blogName.substring( 0, blogentryTxt );
 
-        if( blogName.equals( engine.getFrontPage() ) )
-        {
+        if( blogName.equals( engine.getFrontPage() ) ) {
             blogName = null;
         }
 
-        try
-        {
-            XmlRpcClient xmlrpc = new XmlRpcClient(m_pingURL);
-            Vector<String> params = new Vector<String>();
+        try {
+            final XmlRpcClient xmlrpc = new XmlRpcClient(m_pingURL);
+            final Vector< String > params = new Vector<>();
             params.addElement( "The Butt Ugly Weblog" ); // FIXME: Must be settable
-            params.addElement( engine.getURL( WikiContext.VIEW, blogName, null, true ) );
+            params.addElement( engine.getURL( WikiContext.VIEW, blogName, null ) );
 
-            if( log.isDebugEnabled() )
-                log.debug("Pinging weblogs.com with URL: "+engine.getURL( WikiContext.VIEW, blogName, null, true ));
+            if( log.isDebugEnabled() ) {
+                log.debug( "Pinging weblogs.com with URL: " + engine.getURL( WikiContext.VIEW, blogName, null ) );
+            }
 
             xmlrpc.executeAsync("weblogUpdates.ping", params, 
-                                new AsyncCallback() 
-                                {
-                                    public void handleError( Exception ex,
-                                                             URL url,
-                                                             String method )
-                                    {
-                                        log.error("Unable to execute weblogs.com ping to URL: "+url.toString(),ex);
+                                new AsyncCallback() {
+                                    public void handleError( final Exception ex, final URL url, final String method ) {
+                                        log.error( "Unable to execute weblogs.com ping to URL: " + url.toString(), ex );
                                     }
 
-                                    public void handleResult( Object result,
-                                                              URL url,
-                                                              String method )
-                                    {
+                                    public void handleResult( final Object result, final URL url, final String method ) {
                                         @SuppressWarnings("unchecked")
-                                        Hashtable< String, Object > res = (Hashtable < String, Object > ) result;
+                                        final Hashtable< String, Object > res = (Hashtable < String, Object > ) result;
 
-                                        Boolean flerror = (Boolean)res.get("flerror");
-                                        String  msg     = (String)res.get("message");
+                                        final Boolean flerror = (Boolean)res.get("flerror");
+                                        final String  msg     = (String)res.get("message");
 
-                                        if( flerror.booleanValue() )
-                                        {
+                                        if( flerror ) {
                                             log.error("Failed to ping: "+msg);
                                         }
 
@@ -119,9 +105,7 @@ public class PingWeblogsComFilter
                                     }
                                 }
                                 );
-        }
-        catch( MalformedURLException e )
-        {
+        } catch( final MalformedURLException e ) {
             log.error("Malformed URL",e);
         }
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.java
index fa6bfa6..5a77dfc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Groups.java
@@ -18,11 +18,6 @@
  */
 package org.apache.wiki.plugin;
 
-import java.security.Principal;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Map;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.exceptions.PluginException;
@@ -30,41 +25,41 @@ import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.auth.PrincipalComparator;
 import org.apache.wiki.auth.authorize.GroupManager;
 
+import java.security.Principal;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Map;
+
 /**
  *  <p>Prints the groups managed by this wiki, separated by commas.
  *  <br>The groups are sorted in ascending order, and are hyperlinked to the page that displays the group's members.
  *  </p>
  *  <p>Parameters : </p>
  *  NONE
- *  
- *  
+ *
  *  @since 2.4.19
  */
-public class Groups
-    implements WikiPlugin
-{
+public class Groups implements WikiPlugin {
+
     private static final Comparator<Principal> COMPARATOR = new PrincipalComparator();
     
     /**
      *  {@inheritDoc}
      */
-    public String execute( WikiContext context, Map<String, String> params )
-        throws PluginException
-    {
+    public String execute( final WikiContext context, final Map<String, String> params ) throws PluginException {
         // Retrieve groups, and sort by name
-        WikiEngine engine = context.getEngine();
-        GroupManager groupMgr = engine.getGroupManager();
-        Principal[] groups = groupMgr.getRoles();
+        final WikiEngine engine = context.getEngine();
+        final GroupManager groupMgr = engine.getGroupManager();
+        final Principal[] groups = groupMgr.getRoles();
         Arrays.sort( groups, COMPARATOR );
 
-        StringBuilder s = new StringBuilder();
+        final StringBuilder s = new StringBuilder();
         
-        for ( int i = 0; i < groups.length; i++ )
-        {
-            String name = groups[i].getName();
+        for ( int i = 0; i < groups.length; i++ ) {
+            final String name = groups[ i ].getName();
             
             // Make URL
-            String url = engine.getURLConstructor().makeURL( WikiContext.VIEW_GROUP, name, false, null );
+            final String url = engine.getURLConstructor().makeURL( WikiContext.VIEW_GROUP, name,  null );
             
             // Create hyperlink
             s.append( "<a href=\"" );
@@ -74,8 +69,7 @@ public class Groups
             s.append( "</a>" );
             
             // If not the last one, add a comma and space
-            if ( i < ( groups.length - 1 ) )
-            {
+            if ( i < ( groups.length - 1 ) ) {
                 s.append( ',' );
                 s.append( ' ' );
             }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
index b8d7449..4d38bc0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
@@ -103,7 +103,7 @@ public class AtomFeed extends Feed {
                     for( final Attachment att : c ) {
                         final Element attEl = getElement( "link" );
                         attEl.setAttribute( "rel", "enclosure" );
-                        attEl.setAttribute( "href", engine.getURL( WikiContext.ATTACH, att.getName(), null, true ) );
+                        attEl.setAttribute( "href", engine.getURL( WikiContext.ATTACH, att.getName(), null ) );
                         attEl.setAttribute( "length", Long.toString( att.getSize() ) );
                         attEl.setAttribute( "type", getMimeType( servletContext, att.getFileName() ) );
 
@@ -149,8 +149,7 @@ public class AtomFeed extends Feed {
         final String rssFeedURL  = engine.getURL(WikiContext.NONE, "rss.jsp",
                                                  "page=" + engine.encodeName( m_wikiContext.getPage().getName() ) +
                                                  "&mode=" + m_mode +
-                                                 "&type=atom",
-                                           true );
+                                                 "&type=atom" );
         final Element self = getElement( "link" ).setAttribute( "rel","self" );
         self.setAttribute( "href", rssFeedURL );
         root.addContent( self );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS10Feed.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS10Feed.java
index fe4dec4..12f8625 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS10Feed.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS10Feed.java
@@ -18,9 +18,6 @@
  */
 package org.apache.wiki.rss;
 
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
@@ -28,6 +25,9 @@ import org.apache.wiki.util.XhtmlUtil;
 import org.jdom2.Element;
 import org.jdom2.Namespace;
 
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
 
 /**
  * Provides an implementation of an RSS 1.0 feed.  In addition, this class is
@@ -87,7 +87,7 @@ public class RSS10Feed extends Feed {
 
             if( p.getVersion() > 1 ) {
                 item.addContent( new Element( "diff", NS_WIKI )
-                                         .addContent( engine.getURL( WikiContext.DIFF, p.getName(), "r1=-1", true ) ) );
+                                         .addContent( engine.getURL( WikiContext.DIFF, p.getName(), "r1=-1" ) ) );
             }
 
             //
@@ -127,7 +127,7 @@ public class RSS10Feed extends Feed {
             //
             //  PageHistory
             item.addContent( new Element( "history", NS_WIKI )
-                                    .addContent( engine.getURL( WikiContext.INFO, p.getName(), null, true ) ) );
+                                    .addContent( engine.getURL( WikiContext.INFO, p.getName(), null ) ) );
 
             //
             // Add to root
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java
index ba69b7b..d5026c2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSS20Feed.java
@@ -96,7 +96,7 @@ public class RSS20Feed extends Feed
                         Attachment att = a.next();
 
                         Element attEl = new Element("enclosure");
-                        attEl.setAttribute( "url", engine.getURL(WikiContext.ATTACH, att.getName(), null, true ) );
+                        attEl.setAttribute( "url", engine.getURL( WikiContext.ATTACH, att.getName(), null ) );
                         attEl.setAttribute( "length", Long.toString(att.getSize()) );
                         attEl.setAttribute( "type", getMimeType( servletContext, att.getFileName() ) );
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
index d48ea62..d7df53c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
@@ -166,10 +166,10 @@ public class RSSGenerator {
 
         sb.append( "<br /><hr /><br />" )
           .append( "Parent page: <a href=\"" )
-          .append( m_engine.getURL( WikiContext.VIEW, att.getParentName(), null, true ) )
+          .append( m_engine.getURL( WikiContext.VIEW, att.getParentName(), null ) )
           .append( "\">" ).append( att.getParentName() ).append( "</a><br />" )
           .append( "Info page: <a href=\"" )
-          .append( m_engine.getURL( WikiContext.INFO, att.getName(), null, true ) )
+          .append( m_engine.getURL( WikiContext.INFO, att.getName(), null ) )
           .append( "\">" ).append( att.getName() ).append( "</a>" );
 
         return sb.toString();
@@ -326,9 +326,9 @@ public class RSSGenerator {
 
             final String url;
             if( page instanceof Attachment ) {
-                url = m_engine.getURL( WikiContext.ATTACH, page.getName(),null, true );
+                url = m_engine.getURL( WikiContext.ATTACH, page.getName(),null );
             } else {
-                url = m_engine.getURL( WikiContext.VIEW, page.getName(), null, true );
+                url = m_engine.getURL( WikiContext.VIEW, page.getName(), null );
             }
 
             final Entry e = new Entry();
@@ -378,9 +378,9 @@ public class RSSGenerator {
             String url;
 
             if( page instanceof Attachment ) {
-                url = m_engine.getURL( WikiContext.ATTACH, page.getName(), "version=" + page.getVersion(),true );
+                url = m_engine.getURL( WikiContext.ATTACH, page.getName(), "version=" + page.getVersion() );
             } else {
-                url = m_engine.getURL( WikiContext.VIEW, page.getName(), "version=" + page.getVersion(), true );
+                url = m_engine.getURL( WikiContext.VIEW, page.getName(), "version=" + page.getVersion() );
             }
 
             // Unfortunately, this is needed because the code will again go through replacement conversion
@@ -441,9 +441,9 @@ public class RSSGenerator {
             final String url;
 
             if( page instanceof Attachment ) {
-                url = m_engine.getURL( WikiContext.ATTACH, page.getName(),null,true );
+                url = m_engine.getURL( WikiContext.ATTACH, page.getName(),null );
             } else {
-                url = m_engine.getURL( WikiContext.VIEW, page.getName(),null, true );
+                url = m_engine.getURL( WikiContext.VIEW, page.getName(),null );
             }
 
             e.setURL( url );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/FeedDiscoveryTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/FeedDiscoveryTag.java
index f5edcac..2acff88 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/FeedDiscoveryTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/FeedDiscoveryTag.java
@@ -18,8 +18,6 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
@@ -27,31 +25,26 @@ import org.apache.wiki.plugin.WeblogPlugin;
 import org.apache.wiki.rss.Feed;
 import org.apache.wiki.util.TextUtil;
 
+import java.io.IOException;
+
 /**
  *  Outputs links to all the site feeds and APIs this Wiki/blog supports.
  *
  *  @since 2.2
  */
-public class FeedDiscoveryTag
-    extends WikiTagBase
-{
+public class FeedDiscoveryTag extends WikiTagBase {
+
     private static final long serialVersionUID = 0L;
     
-    public final int doWikiStartTag()
-        throws IOException
-    {
-        WikiEngine engine = m_wikiContext.getEngine();
-        WikiPage   page   = m_wikiContext.getPage();
-
-        String encodedName = engine.encodeName( page.getName() );
+    public final int doWikiStartTag() throws IOException {
+        final WikiEngine engine = m_wikiContext.getEngine();
+        final WikiPage   page   = m_wikiContext.getPage();
 
-        String rssURL      = engine.getGlobalRSSURL();
-        String rssFeedURL  = engine.getURL(WikiContext.NONE, "rss.jsp", 
-                                           "page="+encodedName+"&amp;mode=wiki",
-                                           true );
+        final String encodedName = engine.encodeName( page.getName() );
+        final String rssURL      = engine.getGlobalRSSURL();
+        final String rssFeedURL  = engine.getURL( WikiContext.NONE, "rss.jsp","page="+encodedName+"&amp;mode=wiki" );
         
-        if( rssURL != null )
-        {
+        if( rssURL != null ) {
             String siteName = Feed.getSiteName(m_wikiContext);
             siteName = TextUtil.replaceEntities( siteName );
             
@@ -64,10 +57,9 @@ public class FeedDiscoveryTag
                                        siteName+"\" href=\""+atomPostURL+"\" />\n");
             */
             // FIXME: This does not work always, as plugins are not initialized until the first fetch
-            if( "true".equals(page.getAttribute(WeblogPlugin.ATTR_ISWEBLOG)) )
-            {
-                String blogFeedURL = engine.getURL(WikiContext.NONE,"rss.jsp","page="+encodedName,true);
-                String atomFeedURL = engine.getURL(WikiContext.NONE,"rss.jsp","page="+encodedName+"&amp;type=atom",true);
+            if( "true".equals( page.getAttribute( WeblogPlugin.ATTR_ISWEBLOG ) ) ) {
+                final String blogFeedURL = engine.getURL( WikiContext.NONE,"rss.jsp","page="+encodedName );
+                final String atomFeedURL = engine.getURL( WikiContext.NONE,"rss.jsp","page="+encodedName+"&amp;type=atom" );
         
                 pageContext.getOut().print("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS feed for weblog "+
                                            siteName+".\" href=\""+blogFeedURL+"\" />\n");
@@ -79,4 +71,5 @@ public class FeedDiscoveryTag
 
         return SKIP_BODY;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java
index ec2bc91..ab096a7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java
@@ -29,7 +29,6 @@ import org.apache.wiki.parser.LinkParsingOperations;
 import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.util.TextUtil;
 
-import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.JspWriter;
 import javax.servlet.jsp.tagext.BodyContent;
 import javax.servlet.jsp.tagext.BodyTag;
@@ -38,13 +37,10 @@ import java.util.Iterator;
 import java.util.Map;
 
 /**
- *  Provides a generic link tag for all kinds of linking
- *  purposes.
+ *  Provides a generic link tag for all kinds of linking purposes.
  *  <p>
- *  If parameter <i>jsp</i> is defined, constructs a URL pointing
- *  to the specified JSP page, under the baseURL known by the WikiEngine.
- *  Any ParamTag name-value pairs contained in the body are added to this
- *  URL to provide support for arbitrary JSP calls.
+ *  If parameter <i>jsp</i> is defined, constructs a URL pointing to the specified JSP page, under the baseURL known by the WikiEngine.
+ *  Any ParamTag name-value pairs contained in the body are added to this URL to provide support for arbitrary JSP calls.
  *  <p>
  *  @since 2.3.50
  */
@@ -74,27 +70,25 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
 
     private BodyContent m_bodyContent;
 
-    public void initTag()
-    {
+    public void initTag() {
         super.initTag();
         m_version = m_cssClass = m_style = m_title = m_target = m_compareToVersion = m_rel = m_jsp = m_ref = m_accesskey = m_templatefile = null;
         m_context = WikiContext.VIEW;
-        m_containedParams = new HashMap<String, String>();
+        m_containedParams = new HashMap<>();
         m_absolute = false;
     }
 
-    public void setTemplatefile( String key )
+    public void setTemplatefile( final String key )
     {
         m_templatefile = key;
     }
 
-    public void setAccessKey( String key )
+    public void setAccessKey( final String key )
     {
         m_accesskey = key;
     }
 
-    public void setAbsolute( String arg )
-    {
+    public void setAbsolute( final String arg ) {
         m_overrideAbsolute = true;
         m_absolute = TextUtil.isPositive( arg );
     }
@@ -104,57 +98,57 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
         return m_version;
     }
 
-    public void setVersion( String arg )
+    public void setVersion( final String arg )
     {
         m_version = arg;
     }
 
-    public void setCssClass( String arg )
+    public void setCssClass( final String arg )
     {
         m_cssClass = arg;
     }
 
-    public void setStyle( String style )
+    public void setStyle( final String style )
     {
         m_style = style;
     }
 
-    public void setTitle( String title )
+    public void setTitle( final String title )
     {
         m_title = title;
     }
 
-    public void setTarget( String target )
+    public void setTarget( final String target )
     {
         m_target = target;
     }
 
-    public void setTabindex( String tabindex )
+    public void setTabindex( final String tabindex )
     {
         m_tabindex = tabindex;
     }
 
-    public void setCompareToVersion( String ver )
+    public void setCompareToVersion( final String ver )
     {
         m_compareToVersion = ver;
     }
 
-    public void setRel( String rel )
+    public void setRel( final String rel )
     {
         m_rel = rel;
     }
 
-    public void setRef( String ref )
+    public void setRef( final String ref )
     {
         m_ref = ref;
     }
 
-    public void setJsp( String jsp )
+    public void setJsp( final String jsp )
     {
         m_jsp = jsp;
     }
 
-    public void setContext( String context )
+    public void setContext( final String context )
     {
         m_context = context;
     }
@@ -162,13 +156,10 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
     /**
      * Support for ParamTag supplied parameters in body.
      */
-    public void setContainedParameter( String name, String value )
-    {
-        if( name != null )
-        {
-            if( m_containedParams == null )
-            {
-                m_containedParams = new HashMap<String, String>();
+    public void setContainedParameter( final String name, final String value ) {
+        if( name != null ) {
+            if( m_containedParams == null ) {
+                m_containedParams = new HashMap<>();
             }
             m_containedParams.put( name, value );
         }
@@ -176,260 +167,189 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
 
 
     /**
-     *  This method figures out what kind of an URL should be output.  It mirrors heavily
-     *  on JSPWikiMarkupParser.handleHyperlinks();
+     *  This method figures out what kind of an URL should be output.  It mirrors heavily on JSPWikiMarkupParser.handleHyperlinks();
      *
      * @return the URL
      * @throws ProviderException
      */
-    private String figureOutURL()
-        throws ProviderException
-    {
+    private String figureOutURL() throws ProviderException {
         String url = null;
-        WikiEngine engine = m_wikiContext.getEngine();
-
-        if( m_pageName == null )
-        {
-            WikiPage page = m_wikiContext.getPage();
+        final WikiEngine engine = m_wikiContext.getEngine();
 
-            if( page != null )
-            {
+        if( m_pageName == null ) {
+            final WikiPage page = m_wikiContext.getPage();
+            if( page != null ) {
                 m_pageName = page.getName();
             }
         }
 
-        if( m_templatefile != null )
-        {
-            String params = addParamsForRecipient( null, m_containedParams );
-            String template = engine.getTemplateDir();
-            url = engine.getURL( WikiContext.NONE, "templates/"+template+"/"+m_templatefile, params, false );
-        }
-        else if( m_jsp != null )
-        {
-            String params = addParamsForRecipient( null, m_containedParams );
+        if( m_templatefile != null ) {
+            final String params = addParamsForRecipient( null, m_containedParams );
+            final String template = engine.getTemplateDir();
+            url = engine.getURL( WikiContext.NONE, "templates/"+template+"/"+m_templatefile, params );
+        } else if( m_jsp != null ) {
+            final String params = addParamsForRecipient( null, m_containedParams );
             //url = m_wikiContext.getURL( WikiContext.NONE, m_jsp, params );
-            url = engine.getURL( WikiContext.NONE, m_jsp, params, m_absolute );
-        }
-        else if( m_ref != null )
-        {
-            int interwikipoint;
-
-            if( new LinkParsingOperations( m_wikiContext ).isExternalLink(m_ref) )
-            {
+            url = engine.getURL( WikiContext.NONE, m_jsp, params );
+        } else if( m_ref != null ) {
+            final int interwikipoint;
+            if( new LinkParsingOperations( m_wikiContext ).isExternalLink(m_ref) ) {
                 url = m_ref;
-            }
-            else if( (interwikipoint = m_ref.indexOf(":")) != -1 )
-            {
-                String extWiki = m_ref.substring( 0, interwikipoint );
-                String wikiPage = m_ref.substring( interwikipoint+1 );
+            } else if( ( interwikipoint = m_ref.indexOf( ":" ) ) != -1 ) {
+                final String extWiki = m_ref.substring( 0, interwikipoint );
+                final String wikiPage = m_ref.substring( interwikipoint+1 );
 
                 url = engine.getInterWikiURL( extWiki );
-
-                if( url != null )
-                {
+                if( url != null ) {
                     url = TextUtil.replaceString( url, "%s", wikiPage );
                 }
-            }
-            else if( m_ref.startsWith("#") )
-            {
+            } else if( m_ref.startsWith("#") ) {
                 // Local link
-            }
-            else if( TextUtil.isNumber(m_ref) )
-            {
+            } else if( TextUtil.isNumber(m_ref) ) {
                 // Reference
-            }
-            else
-            {
-                int hashMark = -1;
+            } else {
+                final int hashMark;
 
-                String parms = (m_version != null) ? "version="+getVersion() : null;
+                final String parms = (m_version != null) ? "version="+getVersion() : null;
 
                 //
                 //  Internal wiki link, but is it an attachment link?
                 //
-                WikiPage p = engine.getPageManager().getPage( m_pageName );
+                final WikiPage p = engine.getPageManager().getPage( m_pageName );
 
-                if( p instanceof Attachment )
-                {
+                if( p instanceof Attachment ) {
                     url = m_wikiContext.getURL( WikiContext.ATTACH, m_pageName );
-                }
-                else if( (hashMark = m_ref.indexOf('#')) != -1 )
-                {
+                } else if( (hashMark = m_ref.indexOf('#')) != -1 ) {
                     // It's an internal Wiki link, but to a named section
 
-                    String namedSection = m_ref.substring( hashMark+1 );
+                    final String namedSection = m_ref.substring( hashMark+1 );
                     String reallink     = m_ref.substring( 0, hashMark );
-
                     reallink = MarkupParser.cleanLink( reallink );
 
                     String matchedLink;
                     String sectref = "";
-                    if( (matchedLink = engine.getFinalPageName( reallink )) != null )
-                    {
-                        sectref = "section-"+engine.encodeName(matchedLink)+"-"+namedSection;
-                        sectref = "#"+sectref.replace('%', '_');
-                    }
-                    else
-                    {
+                    if( ( matchedLink = engine.getFinalPageName( reallink ) ) != null ) {
+                        sectref = "section-" + engine.encodeName( matchedLink ) + "-" + namedSection;
+                        sectref = "#" + sectref.replace( '%', '_' );
+                    } else {
                         matchedLink = reallink;
                     }
 
                     url = makeBasicURL( m_context, matchedLink, parms, m_absolute ) + sectref;
-                }
-                else
-                {
-                    String reallink = MarkupParser.cleanLink( m_ref );
-
+                } else {
+                    final String reallink = MarkupParser.cleanLink( m_ref );
                     url = makeBasicURL( m_context, reallink, parms, m_absolute );
                 }
             }
-        }
-        else if( m_pageName != null && m_pageName.length() > 0 )
-        {
-            WikiPage p = engine.getPageManager().getPage( m_pageName );
+        } else if( m_pageName != null && m_pageName.length() > 0 ) {
+            final WikiPage p = engine.getPageManager().getPage( m_pageName );
 
             String parms = (m_version != null) ? "version="+getVersion() : null;
 
             parms = addParamsForRecipient( parms, m_containedParams );
 
-            if( p instanceof Attachment )
-            {
+            if( p instanceof Attachment ) {
                 String ctx = m_context;
                 // Switch context appropriately when attempting to view an
                 // attachment, but don't override the context setting otherwise
-                if( m_context == null || m_context.equals( WikiContext.VIEW ) )
-                {
+                if( m_context == null || m_context.equals( WikiContext.VIEW ) ) {
                     ctx = WikiContext.ATTACH;
                 }
-                url = engine.getURL( ctx, m_pageName, parms, m_absolute );
+                url = engine.getURL( ctx, m_pageName, parms );
                 //url = m_wikiContext.getURL( ctx, m_pageName, parms );
-            }
-            else
-            {
+            } else {
                 url = makeBasicURL( m_context, m_pageName, parms, m_absolute );
             }
-        }
-        else
-        {
-            String page = engine.getFrontPage();
+        } else {
+            final String page = engine.getFrontPage();
             url = makeBasicURL( m_context, page, null, m_absolute );
         }
 
         return url;
     }
 
-    private String addParamsForRecipient( String addTo, Map< String, String > params )
-    {
-        if( params == null || params.size() == 0 )
-        {
+    private String addParamsForRecipient( final String addTo, final Map< String, String > params ) {
+        if( params == null || params.size() == 0 ) {
             return addTo;
         }
-        StringBuilder buf = new StringBuilder();
-        Iterator< Map.Entry< String, String > > it = params.entrySet().iterator();
-        while( it.hasNext() )
-        {
-            Map.Entry< String, String > e = it.next();
-            String n = e.getKey();
-            String v = e.getValue();
+        final StringBuilder buf = new StringBuilder();
+        final Iterator< Map.Entry< String, String > > it = params.entrySet().iterator();
+        while( it.hasNext() ) {
+            final Map.Entry< String, String > e = it.next();
+            final String n = e.getKey();
+            final String v = e.getValue();
             buf.append( n );
             buf.append( "=" );
             buf.append( v );
-            if( it.hasNext() )
-            {
+            if( it.hasNext() ) {
                 buf.append( "&amp;" );
             }
         }
-        if( addTo == null )
-        {
+        if( addTo == null ) {
             return buf.toString();
         }
-        if( !addTo.endsWith( "&amp;" ) )
-        {
+        if( !addTo.endsWith( "&amp;" ) ) {
             return addTo + "&amp;" + buf.toString();
         }
         return addTo + buf.toString();
     }
 
-    private String makeBasicURL( String context, String page, String parms, boolean absolute )
-    {
-        String url;
-        WikiEngine engine = m_wikiContext.getEngine();
+    private String makeBasicURL( final String context, final String page, String parms, final boolean absolute ) {
+        final WikiEngine engine = m_wikiContext.getEngine();
 
-        if( context.equals( WikiContext.DIFF ) )
-        {
-            int r1 = 0;
-            int r2 = 0;
+        if( context.equals( WikiContext.DIFF ) ) {
+            int r1;
+            int r2;
 
-            if( DiffLinkTag.VER_LATEST.equals(getVersion()) )
-            {
-                WikiPage latest = engine.getPageManager().getPage( page, WikiProvider.LATEST_VERSION );
+            if( DiffLinkTag.VER_LATEST.equals( getVersion() ) ) {
+                final WikiPage latest = engine.getPageManager().getPage( page, WikiProvider.LATEST_VERSION );
 
                 r1 = latest.getVersion();
-            }
-            else if( DiffLinkTag.VER_PREVIOUS.equals(getVersion()) )
-            {
+            } else if( DiffLinkTag.VER_PREVIOUS.equals(getVersion()) ) {
                 r1 = m_wikiContext.getPage().getVersion() - 1;
-                r1 = (r1 < 1 ) ? 1 : r1;
-            }
-            else if( DiffLinkTag.VER_CURRENT.equals(getVersion()) )
-            {
+                r1 = Math.max( r1, 1 );
+            } else if( DiffLinkTag.VER_CURRENT.equals(getVersion()) ) {
                 r1 = m_wikiContext.getPage().getVersion();
-            }
-            else
-            {
+            } else {
                 r1 = Integer.parseInt( getVersion() );
             }
 
-            if( DiffLinkTag.VER_LATEST.equals(m_compareToVersion) )
-            {
-                WikiPage latest = engine.getPageManager().getPage( page, WikiProvider.LATEST_VERSION );
+            if( DiffLinkTag.VER_LATEST.equals(m_compareToVersion) ) {
+                final WikiPage latest = engine.getPageManager().getPage( page, WikiProvider.LATEST_VERSION );
 
                 r2 = latest.getVersion();
-            }
-            else if( DiffLinkTag.VER_PREVIOUS.equals(m_compareToVersion) )
-            {
+            } else if( DiffLinkTag.VER_PREVIOUS.equals(m_compareToVersion) ) {
                 r2 = m_wikiContext.getPage().getVersion() - 1;
-                r2 = (r2 < 1 ) ? 1 : r2;
-            }
-            else if( DiffLinkTag.VER_CURRENT.equals(m_compareToVersion) )
-            {
+                r2 = Math.max( r2, 1 );
+            } else if( DiffLinkTag.VER_CURRENT.equals(m_compareToVersion) ) {
                 r2 = m_wikiContext.getPage().getVersion();
-            }
-            else
-            {
+            } else {
                 r2 = Integer.parseInt( m_compareToVersion );
             }
 
             parms = "r1="+r1+"&amp;r2="+r2;
         }
 
-        //url = m_wikiContext.getURL( m_context, m_pageName, parms );
-        url = engine.getURL( m_context, m_pageName, parms, m_absolute );
-
-        return url;
+        return engine.getURL( m_context, m_pageName, parms );
     }
 
-    public int doWikiStartTag() throws Exception
-    {
+    public int doWikiStartTag() throws Exception {
         return EVAL_BODY_BUFFERED;
     }
 
-    public int doEndTag()
-    {
-        try
-        {
-            WikiEngine engine = m_wikiContext.getEngine();
+    public int doEndTag() {
+        try {
+            final WikiEngine engine = m_wikiContext.getEngine();
 
-            if( !m_overrideAbsolute )
-            {
+            if( !m_overrideAbsolute ) {
                 // TODO: see WikiContext.getURL(); this check needs to be specified somewhere.
                 m_absolute = "absolute".equals( engine.getWikiProperties().getProperty( WikiEngine.PROP_REFSTYLE ) );
             }
 
-            JspWriter out = pageContext.getOut();
-            String url = figureOutURL();
+            final JspWriter out = pageContext.getOut();
+            final String url = figureOutURL();
 
-            StringBuilder sb = new StringBuilder( 20 );
+            final StringBuilder sb = new StringBuilder( 20 );
 
             sb.append( (m_cssClass != null)   ? "class=\""+m_cssClass+"\" " : "" );
             sb.append( (m_style != null)   ? "style=\""+m_style+"\" " : "" );
@@ -439,13 +359,11 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
             sb.append( (m_accesskey != null) ? "accesskey=\""+m_accesskey+"\" " : "" );
             sb.append( (m_tabindex != null) ? "tabindex=\""+m_tabindex+"\" " : "" );
 
-            if( engine.getPageManager().getPage( m_pageName ) instanceof Attachment )
-            {
+            if( engine.getPageManager().getPage( m_pageName ) instanceof Attachment ) {
                 sb.append( engine.getAttachmentManager().forceDownload( m_pageName ) ? "download " : "" );
             }
 
-            switch( m_format )
-            {
+            switch( m_format ) {
               case URL:
                 out.print( url );
                 break;
@@ -455,19 +373,15 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
                 break;
             }
 
-            // Add any explicit body content. This is not the intended use
-            // of LinkTag, but happens to be the way it has worked previously.
-            if( m_bodyContent != null )
-            {
-                String linktext = m_bodyContent.getString().trim();
+            // Add any explicit body content. This is not the intended use of LinkTag, but happens to be the way it has worked previously.
+            if( m_bodyContent != null ) {
+                final String linktext = m_bodyContent.getString().trim();
                 out.write( linktext );
             }
 
             //  Finish off by closing opened anchor
             if( m_format == ANCHOR ) out.print("</a>");
-        }
-        catch( Exception e )
-        {
+        } catch( final Exception e ) {
             // Yes, we want to catch all exceptions here, including RuntimeExceptions
             log.error( "Tag failed", e );
         }
@@ -475,12 +389,12 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
         return EVAL_PAGE;
     }
 
-    public void setBodyContent( BodyContent bc )
+    public void setBodyContent( final BodyContent bc )
     {
         m_bodyContent = bc;
     }
 
-    public void doInitBody() throws JspException
-    {
+    public void doInitBody() {
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java b/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java
index 7aee63c..3ec7cb3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java
@@ -65,7 +65,7 @@ public class SaveUserProfileTask extends Task {
                                                  profile.getLoginName(),
                                                  profile.getFullname(),
                                                  profile.getEmail(),
-                                                 m_engine.getURL( WikiContext.LOGIN, null, null, true ) );
+                                                 m_engine.getURL( WikiContext.LOGIN, null, null ) );
                 MailUtil.sendMessage( m_engine.getWikiProperties(), to, subject, content);
             } catch ( final AddressException e) {
                 LOG.debug( e.getMessage(), e );
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 64f965e..0e68e70 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
@@ -271,8 +271,7 @@ public final class CommandResolver {
     public String getSpecialPageReference( final String page ) {
         final Command command = m_specialPages.get( page );
         if ( command != null ) {
-            return m_engine.getURLConstructor()
-                           .makeURL( command.getRequestContext(), command.getURLPattern(), true, null );
+            return m_engine.getURLConstructor().makeURL( command.getRequestContext(), command.getURLPattern(), null );
         }
 
         return null;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
index bf2a206..c40db82 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
@@ -110,7 +110,7 @@ public class MetaWeblogHandler implements WikiRPCHandler {
     }
 
     private String getURL( final String page ) {
-        return m_context.getEngine().getURL( WikiContext.VIEW, page,null, true ); // Force absolute urls
+        return m_context.getEngine().getURL( WikiContext.VIEW, page,null );
     }
 
     /**
@@ -259,7 +259,7 @@ public class MetaWeblogHandler implements WikiRPCHandler {
             att.setAuthor( username );
             attmgr.storeAttachment( att, new ByteArrayInputStream( data ) );
 
-            url = engine.getURL( WikiContext.ATTACH, att.getName(), null, true );
+            url = engine.getURL( WikiContext.ATTACH, att.getName(), null );
         } catch( final Exception e ) {
             log.error( "Failed to upload attachment", e );
             throw new XmlRpcException( 0, "Failed to upload media object: "+e.getMessage() );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
index ecc3b2a..cfed1dd 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
@@ -131,7 +131,7 @@ public class SearchManagerTest {
 
         Assertions.assertEquals( 0, res.size(), "empty results" );
 
-        res = m_mgr.findPages( "Babylon", ctx );
+        Awaitility.await( "testSimpleSearch3" ).until( findsResultsFor( res,"Babylon" ) );
         Assertions.assertNotNull( res, "null result" );
         Assertions.assertEquals( 1, res.size(), "no pages" );
         Assertions.assertEquals( "TestPage", res.iterator().next().getPage().getName(), "page" );


[jspwiki] 14/32: JSPWIKI-120: remove WikiEngine#getRedirectURL(..) use same method on WikiContext

Posted by ju...@apache.org.
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 d3f4bd334217df532ae0a32de64ede59dcb28b11
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Jan 20 22:10:16 2020 +0100

    JSPWIKI-120: remove WikiEngine#getRedirectURL(..) use same method on WikiContext
    
    Also, moved WikiEngine#createContext as proper Constructor on WikiContext, and propagate the change
---
 .../src/main/java/org/apache/wiki/WikiContext.java |  19 +++
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  45 ++-----
 .../apache/wiki/attachment/AttachmentServlet.java  | 127 +++++++-------------
 .../java/org/apache/wiki/search/SearchManager.java |  71 +++++------
 .../java/org/apache/wiki/xmlrpc/RPCServlet.java    | 132 ++++++++-------------
 .../org/apache/wiki/search/SearchManagerTest.java  |   6 +-
 6 files changed, 154 insertions(+), 246 deletions(-)

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 150cb6f..939a843 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -194,6 +194,9 @@ public class WikiContext implements Cloneable, Command {
         if ( engine == null || command == null ) {
             throw new IllegalArgumentException( "Parameter engine and command must not be null." );
         }
+        if( !engine.isConfigured() ) {
+            throw new InternalWikiException( "WikiEngine has not been properly started.  It is likely that the configuration is faulty.  Please check all logs for the possible reason." );
+        }
 
         m_engine = engine;
         m_request = request;
@@ -247,6 +250,22 @@ public class WikiContext implements Cloneable, Command {
     }
 
     /**
+     *  Creates a new WikiContext from a supplied HTTP request, using a default wiki context.
+     *
+     *  @param engine The WikiEngine that is handling the request
+     *  @param request the HTTP request
+     *  @param requestContext the default context to use
+     *  @return a new WikiContext object.
+     *
+     *  @see org.apache.wiki.ui.CommandResolver
+     *  @see org.apache.wiki.ui.Command
+     *  @since 2.1.15.
+     */
+    public WikiContext( final WikiEngine engine, final HttpServletRequest request, final String requestContext ) {
+        this( engine, request, engine.getCommandResolver().findCommand( request, requestContext ) );
+    }
+
+    /**
      * {@inheritDoc}
      * @see org.apache.wiki.ui.Command#getContentTemplate()
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index e3c6dd7..a2846ac 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -46,7 +46,6 @@ import org.apache.wiki.rss.RSSGenerator;
 import org.apache.wiki.rss.RSSThread;
 import org.apache.wiki.search.SearchManager;
 import org.apache.wiki.tasks.TasksManager;
-import org.apache.wiki.ui.Command;
 import org.apache.wiki.ui.CommandResolver;
 import org.apache.wiki.ui.EditorManager;
 import org.apache.wiki.ui.TemplateManager;
@@ -60,7 +59,6 @@ import org.apache.wiki.workflow.WorkflowManager;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
 import java.io.File;
 import java.io.UnsupportedEncodingException;
 import java.net.MalformedURLException;
@@ -563,6 +561,15 @@ public class WikiEngine  {
     }
 
     /**
+     * check if the WikiEngine has been configured.
+     *
+     * @return {@code true} if it has, {@code false} otherwise.
+     */
+    public boolean isConfigured() {
+        return m_isConfigured;
+    }
+
+    /**
      * Checks if the template directory specified in the wiki's properties actually exists. If it doesn't, then {@code m_templateDir} is
      * set to {@link #DEFAULT_TEMPLATE_NAME}.
      * <p>
@@ -1007,40 +1014,6 @@ public class WikiEngine  {
     }
 
     /**
-     *  Figure out to which page we are really going to.  Considers special page names from the jspwiki.properties, and possible aliases.
-     *  This method delgates requests to {@link org.apache.wiki.WikiContext#getRedirectURL()}.
-     *
-     *  @param context The Wiki Context in which the request is being made.
-     *  @return A complete URL to the new page to redirect to
-     *  @since 2.2
-     */
-    public String getRedirectURL( final WikiContext context ) {
-        return context.getRedirectURL();
-    }
-
-    /**
-     *  Shortcut to create a WikiContext from a supplied HTTP request, using a default wiki context.
-     *
-     *  @param request the HTTP request
-     *  @param requestContext the default context to use
-     *  @return a new WikiContext object.
-     *
-     *  @see org.apache.wiki.ui.CommandResolver
-     *  @see org.apache.wiki.ui.Command
-     *  @since 2.1.15.
-     */
-    // FIXME: We need to have a version which takes a fixed page name as well, or check it elsewhere.
-    public WikiContext createContext( final HttpServletRequest request, final String requestContext ) {
-        if( !m_isConfigured ) {
-            throw new InternalWikiException( "WikiEngine has not been properly started.  It is likely that the configuration is faulty.  Please check all logs for the possible reason." );
-        }
-
-        // Build the wiki context
-        final Command command = m_commandResolver.findCommand( request, requestContext );
-        return new WikiContext( this, request, command );
-    }
-
-    /**
      *  Returns the root path.  The root path is where the WikiEngine is located in the file system.
      *
      *  @since 2.2
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
index 7c449d8..2bb0053 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
@@ -194,7 +194,7 @@ public class AttachmentServlet extends HttpServlet {
      */
     // FIXME: Messages would need to be localized somehow.
     public void doGet( final HttpServletRequest  req, final HttpServletResponse res ) throws IOException {
-        final WikiContext context = m_engine.createContext( req, WikiContext.ATTACH );
+        final WikiContext context = new WikiContext( m_engine, req, WikiContext.ATTACH );
         final AttachmentManager mgr = m_engine.getAttachmentManager();
         final AuthorizationManager authmgr = m_engine.getAuthorizationManager();
 
@@ -373,15 +373,12 @@ public class AttachmentServlet extends HttpServlet {
      * content of the file.
      *
      */
-    public void doPost( HttpServletRequest  req, HttpServletResponse res ) throws IOException {
-        try
-        {
-            String nextPage = upload( req );
+    public void doPost( final HttpServletRequest req, final HttpServletResponse res ) throws IOException {
+        try {
+            final String nextPage = upload( req );
             req.getSession().removeAttribute("msg");
             res.sendRedirect( nextPage );
-        }
-        catch( RedirectException e )
-        {
+        } catch( final RedirectException e ) {
             WikiSession session = WikiSession.getWikiSession( m_engine, req );
             session.addMessage( e.getMessage() );
 
@@ -420,12 +417,12 @@ public class AttachmentServlet extends HttpServlet {
      *  @throws IOException If upload fails
      * @throws FileUploadException
      */
-    protected String upload( HttpServletRequest req ) throws RedirectException, IOException {
+    protected String upload( final HttpServletRequest req ) throws RedirectException, IOException {
         String msg     = "";
-        String attName = "(unknown)";
-        String errorPage = m_engine.getURL( WikiContext.ERROR, "", null, false ); // If something bad happened, Upload should be able to take care of most stuff
+        final String attName = "(unknown)";
+        final String errorPage = m_engine.getURL( WikiContext.ERROR, "", null, false ); // If something bad happened, Upload should be able to take care of most stuff
         String nextPage = errorPage;
-        String progressId = req.getParameter( "progressid" );
+        final String progressId = req.getParameter( "progressid" );
 
         // Check that we have a file upload request
         if( !ServletFileUpload.isMultipartContent(req) ) {
@@ -433,18 +430,16 @@ public class AttachmentServlet extends HttpServlet {
         }
 
         try {
-            FileItemFactory factory = new DiskFileItemFactory();
+            final FileItemFactory factory = new DiskFileItemFactory();
 
-            // Create the context _before_ Multipart operations, otherwise
-            // strict servlet containers may fail when setting encoding.
-            WikiContext context = m_engine.createContext( req, WikiContext.ATTACH );
-
-            UploadListener pl = new UploadListener();
+            // Create the context _before_ Multipart operations, otherwise strict servlet containers may fail when setting encoding.
+            final WikiContext context = new WikiContext( m_engine, req, WikiContext.ATTACH );
+            final UploadListener pl = new UploadListener();
 
             m_engine.getProgressManager().startProgress( pl, progressId );
 
-            ServletFileUpload upload = new ServletFileUpload(factory);
-            upload.setHeaderEncoding("UTF-8");
+            final ServletFileUpload upload = new ServletFileUpload( factory );
+            upload.setHeaderEncoding( "UTF-8" );
             if( !context.hasAdminPermissions() ) {
                 upload.setFileSizeMax( m_maxSize );
             }
@@ -456,12 +451,11 @@ public class AttachmentServlet extends HttpServlet {
             //FileItem actualFile = null;
             List<FileItem> fileItems = new ArrayList<>();
 
-            for( FileItem item : items ) {
+            for( final FileItem item : items ) {
                 if( item.isFormField() ) {
                     if( item.getFieldName().equals("page") ) {
                         //
-                        // FIXME: Kludge alert.  We must end up with the parent page name,
-                        //        if this is an upload of a new revision
+                        // FIXME: Kludge alert.  We must end up with the parent page name, if this is an upload of a new revision
                         //
 
                         wikipage = item.getString("UTF-8");
@@ -494,18 +488,18 @@ public class AttachmentServlet extends HttpServlet {
                 }
             }
 
-        } catch( ProviderException e ) {
+        } catch( final ProviderException e ) {
             msg = "Upload failed because the provider failed: "+e.getMessage();
             log.warn( msg + " (attachment: " + attName + ")", e );
 
-            throw new IOException(msg);
-        } catch( IOException e ) {
+            throw new IOException( msg );
+        } catch( final IOException e ) {
             // Show the submit page again, but with a bit more intimidating output.
             msg = "Upload failure: " + e.getMessage();
             log.warn( msg + " (attachment: " + attName + ")", e );
 
             throw e;
-        } catch (FileUploadException e) {
+        } catch( final FileUploadException e ) {
             // Show the submit page again, but with a bit more intimidating output.
             msg = "Upload failure: " + e.getMessage();
             log.warn( msg + " (attachment: " + attName + ")", e );
@@ -543,12 +537,9 @@ public class AttachmentServlet extends HttpServlet {
     {
         boolean created = false;
 
-        try
-        {
+        try {
             filename = AttachmentManager.validateFileName( filename );
-        }
-        catch( WikiException e )
-        {
+        } catch( final WikiException e ) {
             // this is a kludge, the exception that is caught here contains the i18n key
             // here we have the context available, so we can internationalize it properly :
             throw new RedirectException (Preferences.getBundle( context, InternationalizationManager.CORE_BUNDLE )
@@ -561,34 +552,25 @@ public class AttachmentServlet extends HttpServlet {
         //  before we receive the file, due to the stupid constructor of MultipartRequest.
         //
 
-        if( !context.hasAdminPermissions() )
-        {
-            if( contentLength > m_maxSize )
-            {
+        if( !context.hasAdminPermissions() ) {
+            if( contentLength > m_maxSize ) {
                 // FIXME: Does not delete the received files.
-                throw new RedirectException( "File exceeds maximum size ("+m_maxSize+" bytes)",
-                        errorPage );
+                throw new RedirectException( "File exceeds maximum size ("+m_maxSize+" bytes)", errorPage );
             }
 
-            if( !isTypeAllowed(filename) )
-            {
-                throw new RedirectException( "Files of this type may not be uploaded to this wiki",
-                        errorPage );
+            if( !isTypeAllowed(filename) ) {
+                throw new RedirectException( "Files of this type may not be uploaded to this wiki", errorPage );
             }
         }
 
-        Principal user    = context.getCurrentUser();
-
-        AttachmentManager mgr = m_engine.getAttachmentManager();
+        final Principal user    = context.getCurrentUser();
+        final AttachmentManager mgr = m_engine.getAttachmentManager();
 
         log.debug("file="+filename);
 
-        if( data == null )
-        {
+        if( data == null ) {
             log.error("File could not be opened.");
-
-            throw new RedirectException("File could not be opened.",
-                    errorPage);
+            throw new RedirectException("File could not be opened.", errorPage);
         }
 
         //
@@ -604,8 +586,7 @@ public class AttachmentServlet extends HttpServlet {
 
         Attachment att = mgr.getAttachmentInfo( context.getPage().getName() );
 
-        if( att == null )
-        {
+        if( att == null ) {
             att = new Attachment( m_engine, parentPage, filename );
             created = true;
         }
@@ -615,37 +596,26 @@ public class AttachmentServlet extends HttpServlet {
         //  Check if we're allowed to do this?
         //
 
-        Permission permission = PermissionFactory.getPagePermission( att, "upload" );
-        if( m_engine.getAuthorizationManager().checkPermission( context.getWikiSession(),
-                permission ) )
-        {
-            if( user != null )
-            {
+        final Permission permission = PermissionFactory.getPagePermission( att, "upload" );
+        if( m_engine.getAuthorizationManager().checkPermission( context.getWikiSession(), permission ) ) {
+            if( user != null ) {
                 att.setAuthor( user.getName() );
             }
 
-            if( changenote != null && changenote.length() > 0 )
-            {
+            if( changenote != null && changenote.length() > 0 ) {
                 att.setAttribute( WikiPage.CHANGENOTE, changenote );
             }
 
-            try
-            {
+            try {
                 m_engine.getAttachmentManager().storeAttachment( att, data );
-            }
-            catch( ProviderException pe )
-            {
+            } catch( final ProviderException pe ) {
                 // this is a kludge, the exception that is caught here contains the i18n key
                 // here we have the context available, so we can internationalize it properly :
-                throw new ProviderException( Preferences.getBundle( context, InternationalizationManager.CORE_BUNDLE )
-                        .getString( pe.getMessage() ) );
+                throw new ProviderException( Preferences.getBundle( context, InternationalizationManager.CORE_BUNDLE ).getString( pe.getMessage() ) );
             }
 
-            log.info( "User " + user + " uploaded attachment to " + parentPage +
-                    " called "+filename+", size " + att.getSize() );
-        }
-        else
-        {
+            log.info( "User " + user + " uploaded attachment to " + parentPage + " called "+filename+", size " + att.getSize() );
+        } else {
             throw new RedirectException( "No permission to upload a file", errorPage );
         }
 
@@ -656,22 +626,17 @@ public class AttachmentServlet extends HttpServlet {
      *  Provides tracking for upload progress.
      *
      */
-    private static class UploadListener
-            extends    ProgressItem
-            implements ProgressListener
-    {
+    private static class UploadListener extends ProgressItem implements ProgressListener {
         public long m_currentBytes;
         public long m_totalBytes;
 
-        public void update(long recvdBytes, long totalBytes, int item)
-        {
+        public void update( final long recvdBytes, final long totalBytes, final int item) {
             m_currentBytes = recvdBytes;
             m_totalBytes   = totalBytes;
         }
 
-        public int getProgress()
-        {
-            return (int) (((float)m_currentBytes / m_totalBytes) * 100 + 0.5);
+        public int getProgress() {
+            return ( int )( ( ( float )m_currentBytes / m_totalBytes ) * 100 + 0.5 );
         }
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
index 247d08d..ac256fe 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
@@ -132,11 +132,11 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
     				log.debug("Calling getSuggestions() DONE. "+callResults.size());
     				result = AjaxUtil.toJson(callResults);
     			} else if (actionName.equals(AJAX_ACTION_PAGES)) {
-    				List<Map<String,Object>> callResults = new ArrayList<>();
+    				final List< Map< String, Object > > callResults;
     				log.debug("Calling findPages() START");
-    				WikiContext wikiContext = m_engine.createContext(req, WikiContext.VIEW);
-    				if (wikiContext == null) {
-    					throw new ServletException("Could not create a WikiContext from the request "+req);
+    				final WikiContext wikiContext = new WikiContext( m_engine, req, WikiContext.VIEW );
+    				if( wikiContext == null ) {
+    					throw new ServletException( "Could not create a WikiContext from the request " + req );
     				}
     				callResults = findPages(itemId, maxResults, wikiContext);
     				log.debug("Calling findPages() DONE. "+callResults.size());
@@ -148,45 +148,37 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
     	}
 
         /**
-         *  Provides a list of suggestions to use for a page name.
-         *  Currently the algorithm just looks into the value parameter,
+         *  Provides a list of suggestions to use for a page name. Currently the algorithm just looks into the value parameter,
          *  and returns all page names from that.
          *
          *  @param wikiName the page name
          *  @param maxLength maximum number of suggestions
          *  @return the suggestions
          */
-        public List<String> getSuggestions( String wikiName, int maxLength )
-        {
-            StopWatch sw = new StopWatch();
+        public List<String> getSuggestions( String wikiName, final int maxLength ) {
+            final StopWatch sw = new StopWatch();
             sw.start();
-            List<String> list = new ArrayList<>(maxLength);
+            final List< String > list = new ArrayList<>( maxLength );
 
-            if( wikiName.length() > 0 )
-            {
+            if( wikiName.length() > 0 ) {
 
                 // split pagename and attachment filename
                 String filename = "";
                 int pos = wikiName.indexOf("/");
-                if( pos >= 0 )
-                {
+                if( pos >= 0 ) {
                     filename = wikiName.substring( pos ).toLowerCase();
                     wikiName = wikiName.substring( 0, pos );
                 }
 
-                String cleanWikiName = MarkupParser.cleanLink(wikiName).toLowerCase() + filename;
-
-                String oldStyleName = MarkupParser.wikifyLink(wikiName).toLowerCase() + filename;
-
-                Set< String > allPages = m_engine.getReferenceManager().findCreated();
+                final String cleanWikiName = MarkupParser.cleanLink(wikiName).toLowerCase() + filename;
+                final String oldStyleName = MarkupParser.wikifyLink(wikiName).toLowerCase() + filename;
+                final Set< String > allPages = m_engine.getReferenceManager().findCreated();
 
                 int counter = 0;
-                for( Iterator< String > i = allPages.iterator(); i.hasNext() && counter < maxLength; )
-                {
-                    String p = i.next();
-                    String pp = p.toLowerCase();
-                    if( pp.startsWith( cleanWikiName) || pp.startsWith( oldStyleName ) )
-                    {
+                for( Iterator< String > i = allPages.iterator(); i.hasNext() && counter < maxLength; ) {
+                    final String p = i.next();
+                    final String pp = p.toLowerCase();
+                    if( pp.startsWith( cleanWikiName) || pp.startsWith( oldStyleName ) ) {
                         list.add( p );
                         counter++;
                     }
@@ -194,7 +186,9 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
             }
 
             sw.stop();
-            if( log.isDebugEnabled() ) log.debug("Suggestion request for "+wikiName+" done in "+sw);
+            if( log.isDebugEnabled() ) {
+                log.debug( "Suggestion request for " + wikiName + " done in " + sw );
+            }
             return list;
         }
 
@@ -252,23 +246,13 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
      * @throws FilterException if the search provider failed to initialize
      */
     @Override
-    public void initialize(WikiEngine engine, Properties properties)
-        throws FilterException
-    {
+    public void initialize( final WikiEngine engine, final Properties properties ) throws FilterException {
         m_engine = engine;
-
         loadSearchProvider(properties);
 
-        try
-        {
-            m_searchProvider.initialize(engine, properties);
-        }
-        catch (NoRequiredPropertyException e)
-        {
-            log.error( e.getMessage(), e );
-        }
-        catch (IOException e)
-        {
+        try {
+            m_searchProvider.initialize( engine, properties );
+        } catch( final NoRequiredPropertyException | IOException e ) {
             log.error( e.getMessage(), e );
         }
     }
@@ -280,14 +264,13 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
         final String providerClassName = properties.getProperty( PROP_SEARCHPROVIDER, DEFAULT_SEARCHPROVIDER );
 
         try {
-            Class<?> providerClass = ClassUtil.findClass( "org.apache.wiki.search", providerClassName );
+            final Class<?> providerClass = ClassUtil.findClass( "org.apache.wiki.search", providerClassName );
             m_searchProvider = (SearchProvider)providerClass.newInstance();
-        } catch( ClassNotFoundException | InstantiationException | IllegalAccessException e ) {
+        } catch( final ClassNotFoundException | InstantiationException | IllegalAccessException e ) {
             log.warn("Failed loading SearchProvider, will use BasicSearchProvider.", e);
         }
 
-        if( null == m_searchProvider )
-        {
+        if( null == m_searchProvider ) {
             // FIXME: Make a static with the default search provider
             m_searchProvider = new BasicSearchProvider();
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java
index ef23d4c..29ec933 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java
@@ -18,18 +18,6 @@
  */
 package org.apache.wiki.xmlrpc;
 
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.util.Vector;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -39,6 +27,17 @@ import org.apache.xmlrpc.XmlRpcContext;
 import org.apache.xmlrpc.XmlRpcHandlerMapping;
 import org.apache.xmlrpc.XmlRpcServer;
 
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.util.Vector;
+
 /**
  *  Handles all incoming servlet requests for XML-RPC calls.
  *  <P>
@@ -62,149 +61,120 @@ public class RPCServlet extends HttpServlet
     private WikiEngine       m_engine;
     private XmlRpcServer     m_xmlrpcServer = new XmlRpcServer();
 
-    static Logger log = Logger.getLogger( RPCServlet.class );
+    private static final Logger log = Logger.getLogger( RPCServlet.class );
 
-    public void initHandler( String prefix, String handlerName )
-        throws ClassNotFoundException,
-               InstantiationException,
-               IllegalAccessException
-    {
+    public void initHandler( final String prefix, final String handlerName ) throws ClassNotFoundException {
         /*
         Class handlerClass = Class.forName( handlerName );
         WikiRPCHandler rpchandler = (WikiRPCHandler) handlerClass.newInstance();
         rpchandler.initialize( m_engine );
         m_xmlrpcServer.addHandler( prefix, rpchandler );
         */
-        Class< ? > handlerClass = Class.forName( handlerName );
+        final Class< ? > handlerClass = Class.forName( handlerName );
         m_xmlrpcServer.addHandler( prefix, new LocalHandler(handlerClass) );
     }
 
     /**
      *  Initializes the servlet.
      */
-    public void init( ServletConfig config )
-        throws ServletException
-    {
+    public void init( final ServletConfig config ) throws ServletException {
         m_engine = WikiEngine.getInstance( config );
 
         String handlerName = config.getInitParameter( "handler" );
         String prefix      = config.getInitParameter( "prefix" );
 
-        if( handlerName == null ) handlerName = "org.apache.wiki.xmlrpc.RPCHandler";
-        if( prefix == null )      prefix = XMLRPC_PREFIX;
+        if( handlerName == null ) {
+            handlerName = "org.apache.wiki.xmlrpc.RPCHandler";
+        }
+        if( prefix == null ) {
+            prefix = XMLRPC_PREFIX;
+        }
 
-        try
-        {
+        try {
             initHandler( prefix, handlerName );
 
             //
             // FIXME: The metaweblog API should be possible to turn off.
             //
-            initHandler( "metaWeblog",
-                         "org.apache.wiki.xmlrpc.MetaWeblogHandler" );
-        }
-        catch( Exception e )
-        {
+            initHandler( "metaWeblog", "org.apache.wiki.xmlrpc.MetaWeblogHandler" );
+        } catch( final Exception e ) {
             log.fatal("Unable to start RPC interface: ", e);
             throw new ServletException( "No RPC interface", e );
         }
     }
 
     /**
-     *  Handle HTTP POST.  This is an XML-RPC call, and we'll just forward
-     *  the query to an XmlRpcServer.
+     *  Handle HTTP POST.  This is an XML-RPC call, and we'll just forward the query to an XmlRpcServer.
      */
-    public void doPost( HttpServletRequest request, HttpServletResponse response )
-        throws ServletException
-    {
+    public void doPost( final HttpServletRequest request, final HttpServletResponse response ) throws ServletException {
         log.debug("Received POST to RPCServlet");
 
-        try
-        {
-            WikiContext ctx = m_engine.createContext( request, WikiContext.NONE );
-
-            XmlRpcContext xmlrpcContext = new WikiXmlRpcContext( m_xmlrpcServer.getHandlerMapping(),
-                                                                 ctx );
-
-            byte[] result = m_xmlrpcServer.execute( request.getInputStream(), xmlrpcContext );
+        try {
+            final WikiContext ctx = new WikiContext( m_engine, request, WikiContext.NONE );
+            final XmlRpcContext xmlrpcContext = new WikiXmlRpcContext( m_xmlrpcServer.getHandlerMapping(), ctx );
+            final byte[] result = m_xmlrpcServer.execute( request.getInputStream(), xmlrpcContext );
 
             //
-            //  I think it's safe to write the output as UTF-8:
-            //  The XML-RPC standard never creates other than USASCII
-            //  (which is UTF-8 compatible), and our special UTF-8
-            //  hack just creates UTF-8.  So in all cases our butt
+            //  I think it's safe to write the output as UTF-8: The XML-RPC standard never creates other than USASCII
+            //  (which is UTF-8 compatible), and our special UTF-8 hack just creates UTF-8.  So in all cases our butt
             //  should be covered.
             //
             response.setContentType( "text/xml; charset=utf-8" );
             response.setContentLength( result.length );
 
-            OutputStream out = response.getOutputStream();
+            final OutputStream out = response.getOutputStream();
             out.write( result );
             out.flush();
 
             // log.debug("Result = "+new String(result) );
-        }
-        catch( IOException e )
-        {
+        } catch( final IOException e ) {
             throw new ServletException("Failed to build RPC result", e);
         }
     }
 
     /**
-     *  Handles HTTP GET.  However, we do not respond to GET requests,
-     *  other than to show an explanatory text.
+     *  Handles HTTP GET.  However, we do not respond to GET requests, other than to show an explanatory text.
      */
-    public void doGet( HttpServletRequest request, HttpServletResponse response )
-        throws ServletException
-    {
+    public void doGet( final HttpServletRequest request, final HttpServletResponse response ) throws ServletException {
         log.debug("Received HTTP GET to RPCServlet");
 
-        try
-        {
-            String msg = "We do not support HTTP GET here.  Sorry.";
+        try {
+            final String msg = "We do not support HTTP GET here.  Sorry.";
             response.setContentType( "text/plain" );
             response.setContentLength( msg.length() );
 
-            PrintWriter writer = new PrintWriter( new OutputStreamWriter( response.getOutputStream() ) );
+            final PrintWriter writer = new PrintWriter( new OutputStreamWriter( response.getOutputStream() ) );
 
             writer.println( msg );
             writer.flush();
-        }
-        catch( IOException e )
-        {
+        } catch( final IOException e ) {
             throw new ServletException("Failed to build RPC result", e);
         }
     }
 
-    private static class LocalHandler
-        implements ContextXmlRpcHandler
-    {
+    private static class LocalHandler implements ContextXmlRpcHandler {
         private Class< ? > m_clazz;
 
-        public LocalHandler( Class< ? > clazz )
+        public LocalHandler( final Class< ? > clazz )
         {
             m_clazz = clazz;
         }
 
-        public Object execute(String method, Vector params, XmlRpcContext context) throws Exception
-        {
-            WikiRPCHandler rpchandler = (WikiRPCHandler) m_clazz.newInstance();
+        public Object execute( final String method, final Vector params, final XmlRpcContext context ) throws Exception {
+            final WikiRPCHandler rpchandler = (WikiRPCHandler) m_clazz.newInstance();
             rpchandler.initialize( ((WikiXmlRpcContext)context).getWikiContext() );
 
-            Invoker invoker = new Invoker( rpchandler );
-
+            final Invoker invoker = new Invoker( rpchandler );
             return invoker.execute( method, params );
         }
     }
 
-    private static class WikiXmlRpcContext
-        implements XmlRpcContext
-    {
+    private static class WikiXmlRpcContext implements XmlRpcContext {
+
         private XmlRpcHandlerMapping m_mapping;
         private WikiContext m_context;
 
-        public WikiXmlRpcContext( XmlRpcHandlerMapping map, WikiContext ctx )
-        {
+        public WikiXmlRpcContext( final XmlRpcHandlerMapping map, final WikiContext ctx ) {
             m_mapping = map;
             m_context = ctx;
         }
@@ -214,14 +184,12 @@ public class RPCServlet extends HttpServlet
             return m_mapping;
         }
 
-        public String getPassword()
-        {
+        public String getPassword() {
             // TODO Auto-generated method stub
             return null;
         }
 
-        public String getUserName()
-        {
+        public String getUserName() {
             // TODO Auto-generated method stub
             return null;
         }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
index 9944ed4..ecc3b2a 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
@@ -78,7 +78,7 @@ public class SearchManagerTest {
     Callable< Boolean > findsResultsFor( final Collection< SearchResult > res, final String text ) {
         return () -> {
             final MockHttpServletRequest request = m_engine.newHttpRequest();
-            final WikiContext ctx = m_engine.createContext( request, WikiContext.EDIT );
+            final WikiContext ctx = new WikiContext( m_engine, request, WikiContext.EDIT );
             final Collection< SearchResult > search = m_mgr.findPages( text, ctx );
             if( search != null && search.size() > 0 ) {
                 // debugSearchResults( search );
@@ -121,7 +121,7 @@ public class SearchManagerTest {
         final String txt = "It was the dawn of the third age of mankind, ten years after the Earth-Minbari War.";
         final MockHttpServletRequest request = m_engine.newHttpRequest();
         request.getParameterMap().put( "page", new String[]{ "TestPage" } );
-        final WikiContext ctx = m_engine.createContext( request, WikiContext.EDIT );
+        final WikiContext ctx = new WikiContext( m_engine, request, WikiContext.EDIT );
         m_engine.getPageManager().saveText( ctx, txt );
         m_engine.getPageManager().saveText( ctx, "The Babylon Project was a dream given form. Its goal: to prevent another war by creating a place where humans and aliens could work out their differences peacefully." );
 
@@ -143,7 +143,7 @@ public class SearchManagerTest {
         final String txt = "It was the dawn of the third age of mankind, ten years after the Earth-Minbari War.";
         final MockHttpServletRequest request = m_engine.newHttpRequest();
         request.getParameterMap().put( "page", new String[]{ "TestPage" } );
-        final WikiContext ctx = m_engine.createContext( request, WikiContext.EDIT );
+        final WikiContext ctx = new WikiContext( m_engine, request, WikiContext.EDIT );
         m_engine.getPageManager().saveText( ctx, txt );
 
         Collection< SearchResult > res = new ArrayList<>();


[jspwiki] 02/32: add unit test for WikiEngine#getViewURL fix

Posted by ju...@apache.org.
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 9329f14c96a809e0223adf99289b9cf066d78252
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 18 00:20:24 2020 +0100

    add unit test for WikiEngine#getViewURL fix
---
 jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
index 69d3f0e..c3ea115 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -322,4 +322,9 @@ public class WikiEngineTest {
         Assertions.assertNull( p3.getAttribute( WikiPage.CHANGENOTE ) );
     }
 
+    @Test
+    public void testGetViewURL() {
+        Assertions.assertEquals( "/test/Wiki.jsp?page=" + NAME1, m_engine.getViewURL( NAME1 ) );
+    }
+
 }


[jspwiki] 17/32: JSPWIKI-1127: remove getViewURL from WikiEngine + remove absolute parameter from url constructors

Posted by ju...@apache.org.
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 21c46bb89311a2c3662ab866236f2991f29e7968
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 22 23:21:44 2020 +0100

    JSPWIKI-1127: remove getViewURL from WikiEngine + remove absolute parameter from url constructors
---
 .../src/main/java/org/apache/wiki/WikiContext.java |   4 +-
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  20 +--
 .../org/apache/wiki/url/DefaultURLConstructor.java |  38 ++--
 .../org/apache/wiki/url/ShortURLConstructor.java   | 200 ++++++++-------------
 .../apache/wiki/url/ShortViewURLConstructor.java   |  82 +++------
 .../java/org/apache/wiki/url/URLConstructor.java   |   3 +-
 .../test/java/org/apache/wiki/WikiEngineTest.java  |   5 -
 .../apache/wiki/url/DefaultURLConstructorTest.java |  30 ++--
 .../apache/wiki/url/ShortURLConstructorTest.java   |  30 ++--
 .../wiki/url/ShortViewURLConstructorTest.java      |  30 ++--
 10 files changed, 164 insertions(+), 278 deletions(-)

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 6fa1dab..13a2d11 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -576,10 +576,8 @@ public class WikiContext implements Cloneable, Command {
      *  @return An URL to the given context and page.
      */
     public String getURL( final String context, final String page, final String params ) {
-        final boolean absolute = "absolute".equals(m_engine.getVariableManager().getVariable( this, WikiEngine.PROP_REFSTYLE ));
-
         // FIXME: is rather slow
-        return m_engine.getURL( context, page, params, absolute );
+        return m_engine.getURL( context, page, params );
     }
 
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index a2846ac..67c1d4d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -706,34 +706,18 @@ public class WikiEngine  {
     }
 
     /**
-     * <p>Returns the basic absolute URL to a page, without any modifications. You may add any parameters to this.</p>
-     * <p>Since 2.3.90 it is safe to call this method with {@code null} pageName, in which case it will default to the front page.</p>
-     *
-     * @since 2.0.3
-     * @param pageName The name of the page.  May be null, in which case defaults to the front page.
-     * @return An absolute URL to the page.
-     */
-    public String getViewURL( String pageName ) {
-        if( pageName == null ) {
-            pageName = getFrontPage();
-        }
-        return getURLConstructor().makeURL( WikiContext.VIEW, pageName, true, null );
-    }
-
-    /**
      *  Returns an URL if a WikiContext is not available.
      *
      *  @param context The WikiContext (VIEW, EDIT, etc...)
      *  @param pageName Name of the page, as usual
      *  @param params List of parameters. May be null, if no parameters.
-     *  @param absolute If true, will generate an absolute URL regardless of properties setting.
      *  @return An URL (absolute or relative).
      */
-    public String getURL( final String context, String pageName, final String params, final boolean absolute ) {
+    public String getURL( final String context, String pageName, final String params ) {
         if( pageName == null ) {
             pageName = getFrontPage();
         }
-        return m_urlConstructor.makeURL( context, pageName, absolute, params );
+        return m_urlConstructor.makeURL( context, pageName, params );
     }
 
     /**
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 9a72a4d..f35200e 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
@@ -29,9 +29,9 @@ import javax.servlet.http.HttpServletRequest;
 import java.nio.charset.Charset;
 import java.util.Properties;
 
+
 /**
- *  Implements the default URL constructor using links directly to the
- *  JSP pages.  This is what JSPWiki by default is using.  For example,
+ *  Implements the default URL constructor using links directly to the JSP pages.  This is what JSPWiki by default is using.  For example,
  *  WikiContext.VIEW points at "Wiki.jsp", etc.
  *
  *  @since 2.2
@@ -41,8 +41,7 @@ public class DefaultURLConstructor implements URLConstructor {
     protected WikiEngine m_engine;
 
     /**
-     *  Contains the absolute path of the JSPWiki Web application without the
-     *  actual servlet (which is the m_urlPrefix).
+     *  Contains the absolute path of the JSPWiki Web application without the actual servlet (which is the m_urlPrefix).
      */
     protected String m_pathPrefix = "";
 
@@ -59,8 +58,7 @@ public class DefaultURLConstructor implements URLConstructor {
      *  Does replacement of some particular variables.  The variables are:
      *
      *  <ul>
-     *  <li> "%u" - inserts either the base URL (when absolute is required), or the base path
-     *       (which is an absolute path without the host name).
+     *  <li> "%u" - inserts either the base URL (when absolute is required), or the base path (which is an absolute path without the host name).
      *  <li> "%U" - always inserts the base URL
      *  <li> "%p" - always inserts the base path
      *  <li> "%n" - inserts the page name
@@ -68,16 +66,10 @@ public class DefaultURLConstructor implements URLConstructor {
      *
      * @param baseptrn  The pattern to use
      * @param name The page name
-     * @param absolute If true, %u is always the entire base URL, otherwise it depends on
-     *                 the setting in jspwiki.properties.
      * @return A replacement.
      */
-    protected final String doReplacement( String baseptrn, final String name, final boolean absolute ) {
-        String baseurl = m_pathPrefix;
-
-        if( absolute ) {
-            baseurl = m_engine.getBaseURL() + "/";
-        }
+    protected final String doReplacement( String baseptrn, final String name ) {
+        final String baseurl = m_pathPrefix;
 
         baseptrn = TextUtil.replaceString( baseptrn, "%u", baseurl );
         baseptrn = TextUtil.replaceString( baseptrn, "%U", m_engine.getBaseURL() );
@@ -88,8 +80,7 @@ public class DefaultURLConstructor implements URLConstructor {
     }
 
     /**
-     *  URLEncoder returns pluses, when we want to have the percent
-     *  encoding.  See http://issues.apache.org/bugzilla/show_bug.cgi?id=39278
+     *  URLEncoder returns pluses, when we want to have the percent encoding.  See http://issues.apache.org/bugzilla/show_bug.cgi?id=39278
      *  for more info.
      *
      *  We also convert any %2F's back to slashes to make nicer-looking URLs.
@@ -124,8 +115,8 @@ public class DefaultURLConstructor implements URLConstructor {
     /**
      *  Constructs the actual URL based on the context.
      */
-    private String makeURL( final String context, final String name, final boolean absolute ) {
-        return doReplacement( getURLPattern(context,name), name, absolute );
+    private String makeURL( final String context, final String name ) {
+        return doReplacement( getURLPattern( context, name ), name );
     }
 
     /**
@@ -134,7 +125,7 @@ public class DefaultURLConstructor implements URLConstructor {
      *
      *  {@inheritDoc}
      */
-    public String makeURL( final String context, final String name, final boolean absolute, String parameters ) {
+    public String makeURL( final String context, final String name, String parameters ) {
         if( parameters != null && parameters.length() > 0 ) {
             if( context.equals(WikiContext.ATTACH) ) {
                 parameters = "?"+parameters;
@@ -146,12 +137,11 @@ public class DefaultURLConstructor implements URLConstructor {
         } else {
             parameters = "";
         }
-        return makeURL( context, name, absolute ) + parameters;
+        return makeURL( context, name ) + parameters;
     }
 
     /**
-     *  Should parse the "page" parameter from the actual
-     *  request.
+     *  Should parse the "page" parameter from the actual request.
      *
      *  {@inheritDoc}
      */
@@ -165,9 +155,7 @@ public class DefaultURLConstructor implements URLConstructor {
     }
 
     /**
-     *  Takes the name of the page from the request URI.
-     *  The initial slash is also removed.  If there is no page,
-     *  returns null.
+     *  Takes the name of the page from the request URI. The initial slash is also removed.  If there is no page, returns null.
      *
      *  @param request The request to parse
      *  @param encoding The encoding to use
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
index f686d50..7b988f6 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
@@ -32,38 +32,30 @@ import java.util.Properties;
 /**
  *  Provides a way to do short URLs of the form /wiki/PageName.
  *
- *
  *  @since 2.2
  */
-public class ShortURLConstructor
-    extends DefaultURLConstructor
-{
+public class ShortURLConstructor extends DefaultURLConstructor {
+    
     private static final String DEFAULT_PREFIX = "wiki/";
-
-    static Logger log = Logger.getLogger( ShortURLConstructor.class );
+    private static final Logger log = Logger.getLogger( ShortURLConstructor.class );
     
-    /**
-     *  Contains the path part after the JSPWiki base URL
-     */
+    /** Contains the path part after the JSPWiki base URL */
     protected String m_urlPrefix = "";
     
     /**
-     *  This corresponds to your WikiServlet path.  By default, it is assumed to
-     *  be "wiki/", but you can set it to whatever you like - including an empty
-     *  name.
+     *  This corresponds to your WikiServlet path.  By default, it is assumed to be "wiki/", but you can set it to whatever you
+     *  like - including an empty name.
      */
     public static final String PROP_PREFIX = "jspwiki.shortURLConstructor.prefix";
     
     /** {@inheritDoc} */
-    public void initialize( WikiEngine engine, 
-                            Properties properties )
-    {
+    @Override
+    public void initialize( final WikiEngine engine, final Properties properties ) {
         super.initialize( engine, properties );
         
         m_urlPrefix = TextUtil.getStringProperty( properties, PROP_PREFIX, null );
         
-        if( m_urlPrefix == null )
-        {
+        if( m_urlPrefix == null ) {
             m_urlPrefix = DEFAULT_PREFIX;
         }
 
@@ -73,131 +65,82 @@ public class ShortURLConstructor
     /**
      *  Constructs the actual URL based on the context.
      */
-    private String makeURL( String context,
-                            String name,
-                            boolean absolute )
-    {
-        String viewurl = "%p"+m_urlPrefix+"%n";
-
-        if( absolute ) 
-            viewurl = "%u"+m_urlPrefix+"%n";
+    private String makeURL( final String context, final String name ) {
+        final String viewurl = "%p" + m_urlPrefix + "%n";
 
-        if( context.equals(WikiContext.VIEW) )
-        {
-            if( name == null ) return doReplacement("%u","",absolute);
-            return doReplacement( viewurl, name, absolute );
-        }
-        else if( context.equals(WikiContext.PREVIEW) )
-        {
-            if( name == null ) return doReplacement("%u","",absolute);
-            return doReplacement( viewurl+"?do=Preview", name, absolute);
-        }
-        else if( context.equals(WikiContext.EDIT) )
-        {
-            return doReplacement( viewurl+"?do=Edit", name, absolute );
-        }
-        else if( context.equals(WikiContext.ATTACH) )
-        {
-            return doReplacement( "%uattach/%n", name, absolute );
-        }
-        else if( context.equals(WikiContext.INFO) )
-        {
-            return doReplacement( viewurl+"?do=PageInfo", name, absolute );
-        }
-        else if( context.equals(WikiContext.DIFF) )
-        {
-            return doReplacement( viewurl+"?do=Diff", name, absolute );
-        }
-        else if( context.equals(WikiContext.NONE) )
-        {
-            return doReplacement( "%u%n", name, absolute );
-        }
-        else if( context.equals(WikiContext.UPLOAD) )
-        {
-            return doReplacement( viewurl+"?do=Upload", name, absolute ); 
-        }
-        else if( context.equals(WikiContext.COMMENT) )
-        {
-            return doReplacement( viewurl+"?do=Comment", name, absolute ); 
-        }
-        else if( context.equals(WikiContext.LOGIN) )
-        {
-            String loginUrl = absolute ? "%uLogin.jsp?redirect=%n" : "%pLogin.jsp?redirect=%n";
-            return doReplacement( loginUrl, name, absolute ); 
-        }
-        else if( context.equals(WikiContext.DELETE) )
-        {
-            return doReplacement( viewurl+"?do=Delete", name, absolute ); 
-        }
-        else if( context.equals(WikiContext.CONFLICT) )
-        {
-            return doReplacement( viewurl+"?do=PageModified", name, absolute ); 
-        }
-        else if( context.equals(WikiContext.PREFS) )
-        {
-            return doReplacement( viewurl+"?do=UserPreferences", name, absolute ); 
-        }
-        else if( context.equals(WikiContext.FIND) )
-        {
-            return doReplacement( viewurl+"?do=Search", name, absolute ); 
-        }
-        else if( context.equals(WikiContext.ERROR) )
-        {
-            return doReplacement( "%uError.jsp", name, absolute );
-        }
-        else if( context.equals(WikiContext.CREATE_GROUP) )
-        {
-            return doReplacement( viewurl+"?do=NewGroup", name, absolute );
-        }
-        else if( context.equals(WikiContext.DELETE_GROUP) )
-        {
-            return doReplacement( viewurl+"?do=DeleteGroup", name, absolute );
-        }        
-        else if( context.equals(WikiContext.EDIT_GROUP) )
-        {
-            return doReplacement( viewurl+"?do=EditGroup", name, absolute );
-        }
-        else if( context.equals(WikiContext.VIEW_GROUP) )
-        {
-            return doReplacement( viewurl+"?do=Group&group=%n", name, absolute );
+        if( context.equals( WikiContext.VIEW ) ) {
+            if( name == null ) {
+                return doReplacement("%u","" );
+            }
+            return doReplacement( viewurl, name );
+        } else if( context.equals( WikiContext.PREVIEW ) ) {
+            if( name == null ) {
+                return doReplacement("%u","" );
+            }
+            return doReplacement( viewurl + "?do=Preview", name );
+        } else if( context.equals( WikiContext.EDIT ) ) {
+            return doReplacement( viewurl + "?do=Edit", name );
+        } else if( context.equals( WikiContext.ATTACH ) ) {
+            return doReplacement( "%uattach/%n", name );
+        } else if( context.equals( WikiContext.INFO ) ) {
+            return doReplacement( viewurl + "?do=PageInfo", name );
+        } else if( context.equals( WikiContext.DIFF ) ) {
+            return doReplacement( viewurl + "?do=Diff", name );
+        } else if( context.equals( WikiContext.NONE ) ) {
+            return doReplacement( "%u%n", name );
+        } else if( context.equals( WikiContext.UPLOAD ) ) {
+            return doReplacement( viewurl + "?do=Upload", name ); 
+        } else if( context.equals( WikiContext.COMMENT ) ) {
+            return doReplacement( viewurl + "?do=Comment", name ); 
+        } else if( context.equals( WikiContext.LOGIN ) ) {
+            final String loginUrl = "%pLogin.jsp?redirect=%n";
+            return doReplacement( loginUrl, name ); 
+        } else if( context.equals( WikiContext.DELETE ) ) {
+            return doReplacement( viewurl + "?do=Delete", name ); 
+        } else if( context.equals( WikiContext.CONFLICT ) ) {
+            return doReplacement( viewurl + "?do=PageModified", name ); 
+        } else if( context.equals( WikiContext.PREFS ) ) {
+            return doReplacement( viewurl + "?do=UserPreferences", name ); 
+        } else if( context.equals( WikiContext.FIND ) ) {
+            return doReplacement( viewurl + "?do=Search", name ); 
+        } else if( context.equals( WikiContext.ERROR ) ) {
+            return doReplacement( "%uError.jsp", name );
+        } else if( context.equals( WikiContext.CREATE_GROUP ) ) {
+            return doReplacement( viewurl + "?do=NewGroup", name );
+        } else if( context.equals( WikiContext.DELETE_GROUP ) ) {
+            return doReplacement( viewurl + "?do=DeleteGroup", name );
+        } else if( context.equals( WikiContext.EDIT_GROUP ) ) {
+            return doReplacement( viewurl + "?do=EditGroup", name );
+        } else if( context.equals( WikiContext.VIEW_GROUP ) ) {
+            return doReplacement( viewurl + "?do=Group&group=%n", name );
         }
         
-        throw new InternalWikiException("Requested unsupported context "+context);
+        throw new InternalWikiException( "Requested unsupported context " + context );
     }
 
     /**
      *  {@inheritDoc}
      */
-    public String makeURL( String context,
-                           String name,
-                           boolean absolute,
-                           String parameters )
-    {
-        if( parameters != null && parameters.length() > 0 )
-        {            
-            if( context.equals(WikiContext.ATTACH) || context.equals(WikiContext.VIEW) )
-            {
-                parameters = "?"+parameters;
-            }
-            else if( context.equals(WikiContext.NONE) )
-            {
+    @Override
+    public String makeURL( final String context, final String name, String parameters ) {
+        if( parameters != null && parameters.length() > 0 ) {
+            if( context.equals( WikiContext.ATTACH ) || context.equals( WikiContext.VIEW ) ) {
+                parameters = "?" + parameters;
+            } else if( context.equals(WikiContext.NONE) ) {
                 parameters = (name.indexOf('?') != -1 ) ? "&amp;" : "?" + parameters;
-            }
-            else
-            {
+            } else {
                 parameters = "&amp;"+parameters;
             }
-        }
-        else
-        {
+        } else {
             parameters = "";
         }
-        return makeURL( context, name, absolute )+parameters;
+        return makeURL( context, name )+parameters;
     }
 
     /**
      * {@inheritDoc}
      */
+    @Override
     public String parsePage( final String context, final HttpServletRequest request, final Charset encoding ) {
         final String pagereq = request.getParameter( "page" );
         if( pagereq == null ) {
@@ -210,11 +153,14 @@ public class ShortURLConstructor
     /**
      *  {@inheritDoc}
      */
-    public String getForwardPage( HttpServletRequest req )
-    {
+    @Override
+    public String getForwardPage( final HttpServletRequest req ) {
         String jspPage = req.getParameter( "do" );
-        if( jspPage == null ) jspPage = "Wiki";
+        if( jspPage == null ) {
+            jspPage = "Wiki";
+        }
     
         return jspPage+".jsp";
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java
index 3215290..8265c31 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java
@@ -18,91 +18,67 @@
  */
 package org.apache.wiki.url;
 
-import java.util.Properties;
-
-import javax.servlet.http.HttpServletRequest;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.Properties;
+
 /**
- *  A specific URL constructor that returns easy-to-grok URLs for
- *  VIEW and ATTACH contexts, but goes through JSP pages otherwise.
+ *  A specific URL constructor that returns easy-to-grok URLs for VIEW and ATTACH contexts, but goes through JSP pages otherwise.
  * 
- *
  *  @since 2.2
  */
-public class ShortViewURLConstructor 
-    extends ShortURLConstructor
-{
+public class ShortViewURLConstructor extends ShortURLConstructor {
+
     /**
      *  {@inheritDoc}
      */
-    public void initialize( WikiEngine engine, 
-                            Properties properties )
-    {
+    public void initialize( final WikiEngine engine, final Properties properties ) {
         super.initialize( engine, properties );
     }
     
-    private String makeURL( String context,
-                            String name,
-                            boolean absolute )
-    {
-        String viewurl = "%p"+m_urlPrefix+"%n";
-
-        if( absolute ) 
-            viewurl = "%u"+m_urlPrefix+"%n";
-
-        if( context.equals(WikiContext.VIEW) )
-        {
-            if( name == null ) return doReplacement("%u","",absolute);
-            return doReplacement( viewurl, name, absolute );
+    private String makeURL( final String context, final String name ) {
+        final String viewurl = "%p" + m_urlPrefix + "%n";
+        if( context.equals( WikiContext.VIEW ) ) {
+            if( name == null ) {
+                return doReplacement("%u","" );
+            }
+            return doReplacement( viewurl, name );
         }
 
-        return doReplacement( DefaultURLConstructor.getURLPattern(context,name),
-                              name,
-                              absolute );
+        return doReplacement( DefaultURLConstructor.getURLPattern( context, name ), name );
     }
 
     /**
      * {@inheritDoc}
      */
-    public String makeURL( String context,
-                           String name,
-                           boolean absolute,
-                           String parameters )
-    {
-        if( parameters != null && parameters.length() > 0 )
-        {            
-            if( context.equals(WikiContext.ATTACH) || context.equals(WikiContext.VIEW) || name == null )
-            {
-                parameters = "?"+parameters;
-            }
-            else if( context.equals(WikiContext.NONE) )
-            {
+    @Override
+    public String makeURL( final String context, final String name, String parameters ) {
+        if( parameters != null && parameters.length() > 0 ) {
+            if( context.equals( WikiContext.ATTACH ) || context.equals( WikiContext.VIEW ) || name == null ) {
+                parameters = "?" + parameters;
+            } else if( context.equals(WikiContext.NONE) ) {
                 parameters = (name.indexOf('?') != -1 ) ? "&amp;" : "?" + parameters;
+            } else {
+                parameters = "&amp;" + parameters;
             }
-            else
-            {
-                parameters = "&amp;"+parameters;
-            }
-        }
-        else
-        {
+        } else {
             parameters = "";
         }
-        return makeURL( context, name, absolute )+parameters;
+        return makeURL( context, name ) + parameters;
     }
     
     /**
-     *   Since we're only called from WikiServlet, where we get the VIEW requests,
-     *   we can safely return this.
+     *   Since we're only called from WikiServlet, where we get the VIEW requests, we can safely return this.
      *   
      * @param request The HTTP Request that was used to end up in this page.
      * @return always returns "Wiki.jsp"
      */
-    public String getForwardPage( HttpServletRequest request )
+    @Override
+    public String getForwardPage( final HttpServletRequest request )
     {        
         return "Wiki.jsp";
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
index 67c7da5..6035750 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
@@ -51,11 +51,10 @@ public interface URLConstructor {
      *  @param context The request context (@see WikiContext) that you want the URL for
      *  @param name The page name (or in case of WikiContext.NONE, the auxiliary JSP page
      *              or resource you want to point at).  This must be URL encoded.  Null is NOT safe.
-     *  @param absolute True, if you need an absolute URL.  False, if both relative and absolute URLs are fine.
      *  @param parameters An URL parameter string (these must be URL-encoded, and separated with &amp;amp;)
      *  @return An URL pointing to the resource.  Must never return null - throw an InternalWikiException  if something goes wrong.
      */
-    String makeURL( String context, String name, boolean absolute, String parameters );
+    String makeURL( String context, String name, String parameters );
 
     /**
      *  Should parse the "page" parameter from the actual request. This is essentially the reverse of makeURL() - whenever
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
index c3ea115..69d3f0e 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -322,9 +322,4 @@ public class WikiEngineTest {
         Assertions.assertNull( p3.getAttribute( WikiPage.CHANGENOTE ) );
     }
 
-    @Test
-    public void testGetViewURL() {
-        Assertions.assertEquals( "/test/Wiki.jsp?page=" + NAME1, m_engine.getViewURL( NAME1 ) );
-    }
-
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java b/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java
index c6c9764..c08ee80 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/url/DefaultURLConstructorTest.java
@@ -22,14 +22,14 @@
  */
 package org.apache.wiki.url;
 
-import java.util.Properties;
-
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
+import java.util.Properties;
+
 
 public class DefaultURLConstructorTest
 {
@@ -56,7 +56,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor("wiki/" );
 
-        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -65,7 +65,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( null );
 
-        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -74,7 +74,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( null );
 
-        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -83,7 +83,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( null );
 
-        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",false,null) );
+        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -92,7 +92,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( "" );
 
-        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -101,7 +101,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( null );
 
-        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -110,7 +110,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( "view/" );
 
-        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/Wiki.jsp?page=Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -119,7 +119,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( null );
 
-        Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",true,null) );
+        Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",null) );
     }
 
     @Test
@@ -128,7 +128,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( null );
 
-        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",true,null) );
+        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) );
     }
 
     @Test
@@ -137,7 +137,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( null );
 
-        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",false,null) );
+        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) );
     }
 
     @Test
@@ -146,7 +146,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( null );
 
-        Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",true,null) );
+        Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",null) );
     }
 
     @Test
@@ -155,7 +155,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( null );
 
-        Assertions.assertEquals( "/test/foo.jsp?a=1&amp;b=2", c.makeURL(WikiContext.NONE,"foo.jsp",true,"a=1&amp;b=2") );
+        Assertions.assertEquals( "/test/foo.jsp?a=1&amp;b=2", c.makeURL(WikiContext.NONE,"foo.jsp","a=1&amp;b=2") );
     }
 
     @Test
@@ -164,7 +164,7 @@ public class DefaultURLConstructorTest
     {
         URLConstructor c = getConstructor( null );
 
-        Assertions.assertEquals( "/test/Wiki.jsp?page=", c.makeURL(WikiContext.VIEW,"",true,null) );
+        Assertions.assertEquals( "/test/Wiki.jsp?page=", c.makeURL(WikiContext.VIEW,"",null) );
     }
 
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java
index 3443bb2..fd0a1c9 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortURLConstructorTest.java
@@ -22,14 +22,14 @@
  */
 package org.apache.wiki.url;
 
-import java.util.Properties;
-
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
+import java.util.Properties;
+
 
 public class ShortURLConstructorTest
 {
@@ -56,7 +56,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor("wiki/" );
 
-        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -65,7 +65,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -74,7 +74,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -83,7 +83,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",false,null) );
+        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -92,7 +92,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor("" );
 
-        Assertions.assertEquals( "/test/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -101,7 +101,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -110,7 +110,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor("view/" );
 
-        Assertions.assertEquals( "/test/view/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/view/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -119,7 +119,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/wiki/Main?do=Edit", c.makeURL(WikiContext.EDIT,"Main",true,null) );
+        Assertions.assertEquals( "/test/wiki/Main?do=Edit", c.makeURL(WikiContext.EDIT,"Main",null) );
     }
 
     @Test
@@ -128,7 +128,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",true,null) );
+        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) );
     }
 
     @Test
@@ -137,7 +137,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",false,null) );
+        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) );
     }
 
     @Test
@@ -146,7 +146,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",true,null) );
+        Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",null) );
     }
 
     @Test
@@ -155,7 +155,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/foo.jsp?a=1&amp;b=2", c.makeURL(WikiContext.NONE,"foo.jsp",true,"a=1&amp;b=2") );
+        Assertions.assertEquals( "/test/foo.jsp?a=1&amp;b=2", c.makeURL(WikiContext.NONE,"foo.jsp","a=1&amp;b=2") );
     }
 
     @Test
@@ -164,7 +164,7 @@ public class ShortURLConstructorTest
     {
         URLConstructor c = getConstructor("wiki/" );
 
-        Assertions.assertEquals( "/test/wiki/", c.makeURL(WikiContext.VIEW,"",true,null) );
+        Assertions.assertEquals( "/test/wiki/", c.makeURL(WikiContext.VIEW,"",null) );
     }
 
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java
index bef9155..3f9b763 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/url/ShortViewURLConstructorTest.java
@@ -22,14 +22,14 @@
  */
 package org.apache.wiki.url;
 
-import java.util.Properties;
-
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
+import java.util.Properties;
+
 
 public class ShortViewURLConstructorTest
 {
@@ -56,7 +56,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor("wiki/" );
 
-        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -65,7 +65,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -74,7 +74,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -83,7 +83,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",false,null) );
+        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -92,7 +92,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor("" );
 
-        Assertions.assertEquals( "/test/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -101,7 +101,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/wiki/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -110,7 +110,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor("view/" );
 
-        Assertions.assertEquals( "/test/view/Main", c.makeURL(WikiContext.VIEW,"Main",true,null) );
+        Assertions.assertEquals( "/test/view/Main", c.makeURL(WikiContext.VIEW,"Main",null) );
     }
 
     @Test
@@ -119,7 +119,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",true,null) );
+        Assertions.assertEquals( "/test/Edit.jsp?page=Main", c.makeURL(WikiContext.EDIT,"Main",null) );
     }
 
     @Test
@@ -128,7 +128,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",true,null) );
+        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) );
     }
 
     @Test
@@ -137,7 +137,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",false,null) );
+        Assertions.assertEquals( "/test/attach/Main/foo.txt", c.makeURL(WikiContext.ATTACH,"Main/foo.txt",null) );
     }
 
     @Test
@@ -146,7 +146,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",true,null) );
+        Assertions.assertEquals( "/test/foo.jsp", c.makeURL(WikiContext.NONE,"foo.jsp",null) );
     }
 
     @Test
@@ -155,7 +155,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor(null );
 
-        Assertions.assertEquals( "/test/foo.jsp?a=1&amp;b=2", c.makeURL(WikiContext.NONE,"foo.jsp",true,"a=1&amp;b=2") );
+        Assertions.assertEquals( "/test/foo.jsp?a=1&amp;b=2", c.makeURL(WikiContext.NONE,"foo.jsp","a=1&amp;b=2") );
     }
 
     @Test
@@ -164,7 +164,7 @@ public class ShortViewURLConstructorTest
     {
         URLConstructor c = getConstructor("wiki/" );
 
-        Assertions.assertEquals( "/test/wiki/", c.makeURL(WikiContext.VIEW,"",true,null) );
+        Assertions.assertEquals( "/test/wiki/", c.makeURL(WikiContext.VIEW,"",null) );
     }
 
 }


[jspwiki] 15/32: WikiEngine init'd check must be done only on new constructor

Posted by ju...@apache.org.
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 b6465dd5428d4f6b6cd251ceb2a028e37262d66c
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Jan 20 22:17:14 2020 +0100

    WikiEngine init'd check must be done only on new constructor
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

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 939a843..6fa1dab 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -194,9 +194,6 @@ public class WikiContext implements Cloneable, Command {
         if ( engine == null || command == null ) {
             throw new IllegalArgumentException( "Parameter engine and command must not be null." );
         }
-        if( !engine.isConfigured() ) {
-            throw new InternalWikiException( "WikiEngine has not been properly started.  It is likely that the configuration is faulty.  Please check all logs for the possible reason." );
-        }
 
         m_engine = engine;
         m_request = request;
@@ -263,6 +260,9 @@ public class WikiContext implements Cloneable, Command {
      */
     public WikiContext( final WikiEngine engine, final HttpServletRequest request, final String requestContext ) {
         this( engine, request, engine.getCommandResolver().findCommand( request, requestContext ) );
+        if( !engine.isConfigured() ) {
+            throw new InternalWikiException( "WikiEngine has not been properly started.  It is likely that the configuration is faulty.  Please check all logs for the possible reason." );
+        }
     }
 
     /**


[jspwiki] 06/32: add @SuppressWarnings("unchecked") to getAttribute( String )

Posted by ju...@apache.org.
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 3e00cb1ca4990e8324626ea2d51e38464317aa36
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 18 15:29:51 2020 +0100

    add @SuppressWarnings("unchecked") to getAttribute( String )
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 83f4cdc..5014218 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -1280,8 +1280,9 @@ public class WikiEngine  {
      *  @param key the attribute name
      *  @return the value
      */
-    public <T> T getAttribute( final String key ) {
-        return (T)m_attributes.get( key );
+    @SuppressWarnings( "unchecked" )
+    public < T > T getAttribute( final String key ) {
+        return ( T )m_attributes.get( key );
     }
 
     /**


[jspwiki] 10/32: apply formatting fixes suggested by intellij

Posted by ju...@apache.org.
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 c88e155747fd918ed0427741eedc3a82bf107337
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Jan 19 22:45:22 2020 +0100

    apply formatting fixes suggested by intellij
---
 .../src/main/java/org/apache/wiki/WikiContext.java |   6 +-
 .../java/org/apache/wiki/ui/AbstractCommand.java   | 133 +++---
 .../src/main/java/org/apache/wiki/ui/Command.java  | 121 ++----
 .../java/org/apache/wiki/ui/CommandResolver.java   | 403 +++++++----------
 .../java/org/apache/wiki/ui/EditorManager.java     | 160 +++----
 .../org/apache/wiki/ui/GenericHTTPHandler.java     |  12 +-
 .../main/java/org/apache/wiki/ui/GroupCommand.java |  90 ++--
 .../java/org/apache/wiki/ui/InputValidator.java    | 135 +++---
 .../main/java/org/apache/wiki/ui/Installer.java    | 180 +++-----
 .../main/java/org/apache/wiki/ui/PageCommand.java  |  62 ++-
 .../java/org/apache/wiki/ui/RedirectCommand.java   |  64 ++-
 .../java/org/apache/wiki/ui/TemplateManager.java   | 478 ++++++++-------------
 .../main/java/org/apache/wiki/ui/WikiCommand.java  |  70 ++-
 .../java/org/apache/wiki/ui/WikiJSPFilter.java     | 233 ++++------
 .../org/apache/wiki/ui/WikiRequestWrapper.java     | 103 ++---
 .../java/org/apache/wiki/ui/WikiServletFilter.java |   8 +-
 16 files changed, 862 insertions(+), 1396 deletions(-)

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 4b9a1d6..150cb6f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -531,8 +531,7 @@ public class WikiContext implements Cloneable, Command {
      *  @param page The page to which to link.
      *  @return An URL to the page.  This honours the current absolute/relative setting.
      */
-    public String getViewURL( final String page )
-    {
+    public String getViewURL( final String page ) {
         return getURL( VIEW, page, null );
     }
 
@@ -569,8 +568,7 @@ public class WikiContext implements Cloneable, Command {
      *
      * @return the command
      */
-    public Command getCommand()
-    {
+    public Command getCommand() {
         return m_command;
     }
 
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 6f233fa..777a5ad 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
@@ -22,12 +22,12 @@ import org.apache.wiki.util.TextUtil;
 
 
 /**
- * Abstract, immutable Command implementation class. All of the fields in this
- * class are <code>final</code>. This class is thread-safe.
+ * Abstract, immutable Command implementation class. All of the fields in this class are <code>final</code>. This class is thread-safe.
+ *
  * @since 2.4.22
  */
-public abstract class AbstractCommand implements Command
-{
+public abstract class AbstractCommand implements Command {
+
     private static final Command[] ALL_COMMANDS = new Command[] {
         PageCommand.ATTACH,
         PageCommand.COMMENT,
@@ -59,98 +59,68 @@ public abstract class AbstractCommand implements Command
         RedirectCommand.REDIRECT
     };
 
-    private static final String    HTTPS = "HTTPS://";
-
-    private static final String    HTTP = "HTTP://";
-
-    private final String           m_jsp;
-
-    private final String           m_jspFriendlyName;
-
-    private final String           m_urlPattern;
-
-    private final String           m_requestContext;
-
-    private final String           m_contentTemplate;
+    private static final String HTTPS = "HTTPS://";
+    private static final String HTTP = "HTTP://";
 
-    private final Object           m_target;
+    private final String m_jsp;
+    private final String m_jspFriendlyName;
+    private final String m_urlPattern;
+    private final String m_requestContext;
+    private final String m_contentTemplate;
+    private final Object m_target;
 
     /**
-     * Constructs a new Command with a specified wiki context, URL pattern,
-     * content template and target. The URL pattern is used to derive
-     * the JSP; if it is a "local" JSP (that is, it does not contain
-     * the <code>http://</code> or <code>https://</code> prefixes),
-     * then the JSP will be a cleansed version of the URL pattern;
-     * symbols (such as <code>%u</code>) will removed. If it the supplied
-     * URL pattern points to a non-local destination, the JSP will be set
-     * to the value supplied, unmodified.
+     * Constructs a new Command with a specified wiki context, URL pattern, content template and target. The URL pattern is used to derive
+     * the JSP; if it is a "local" JSP (that is, it does not contain the <code>http://</code> or <code>https://</code> prefixes),
+     * then the JSP will be a cleansed version of the URL pattern; symbols (such as <code>%u</code>) will removed. If it the supplied
+     * URL pattern points to a non-local destination, the JSP will be set to the value supplied, unmodified.
+     *
      * @param requestContext the request context
      * @param urlPattern the URL pattern
      * @param contentTemplate the content template; may be <code>null</code>
-     * @param target the target of the command, such as a WikiPage; may be
-     *            <code>null</code>
-     * @throws IllegalArgumentException if the request content or URL pattern is
-     *             <code>null</code>
+     * @param target the target of the command, such as a WikiPage; may be <code>null</code>
+     * @throws IllegalArgumentException if the request content or URL pattern is <code>null</code>
      */
-    protected AbstractCommand( String requestContext, String urlPattern, String contentTemplate, Object target )
-    {
-        if ( requestContext == null || urlPattern == null )
-        {
+    protected AbstractCommand( final String requestContext, final String urlPattern, final String contentTemplate, final Object target ) {
+        if( requestContext == null || urlPattern == null ) {
             throw new IllegalArgumentException( "Request context, URL pattern and type must not be null." );
         }
 
         m_requestContext = requestContext;
-
-        if ( urlPattern.toUpperCase().startsWith( HTTP ) ||
-             urlPattern.toUpperCase().endsWith( HTTPS ) )
-        {
+        if ( urlPattern.toUpperCase().startsWith( HTTP ) || urlPattern.toUpperCase().endsWith( HTTPS ) ) {
             // For an HTTP/HTTPS url, pass it through without modification
             m_jsp = urlPattern;
             m_jspFriendlyName = "Special Page";
-        }
-        else
-        {
-            // For local JSPs, take everything to the left of ?, then
-            // delete all variable substitutions
+        } else {
+            // For local JSPs, take everything to the left of ?, then delete all variable substitutions
             String jsp = urlPattern;
-            int qPosition = urlPattern.indexOf( '?' );
-            if ( qPosition != -1 )
-            {
+            final int qPosition = urlPattern.indexOf( '?' );
+            if ( qPosition != -1 ) {
                 jsp = jsp.substring( 0, qPosition );
             }
             m_jsp = removeSubstitutions(jsp);
 
             // Calculate the "friendly name" for the JSP
-            if ( m_jsp.toUpperCase().endsWith( ".JSP" ) )
-            {
+            if ( m_jsp.toUpperCase().endsWith( ".JSP" ) ) {
                 m_jspFriendlyName = TextUtil.beautifyString( m_jsp.substring( 0, m_jsp.length() - 4 ) );
-            }
-            else
-            {
+            } else {
                 m_jspFriendlyName = m_jsp;
             }
         }
-
         m_urlPattern = urlPattern;
-
         m_contentTemplate = contentTemplate;
-
         m_target = target;
     }
 
     //
-    //  This is just *so* much faster than doing String.replaceAll().  It would, in fact,
-    //  be worth to cache this value.
+    //  This is just *so* much faster than doing String.replaceAll().  It would, in fact, be worth to cache this value.
     //
-    private String removeSubstitutions(String jsp)
-    {
+    private String removeSubstitutions( final String jsp ) {
         //return jsp.replaceAll( "\u0025[a-z|A-Z]", "" );
-    	StringBuilder newjsp = new StringBuilder( jsp.length() );
-        for( int i = 0; i < jsp.length(); i++ )
-        {
-            char c = jsp.charAt(i);
-            if( c == '%' && i < jsp.length()-1 && Character.isLetterOrDigit( jsp.charAt(i+1) ) )
-            {
+        final StringBuilder newjsp = new StringBuilder( jsp.length() );
+        for( int i = 0; i < jsp.length(); i++ ) {
+            final char c = jsp.charAt(i);
+            if( c == '%' && i < jsp.length() - 1 && Character.isLetterOrDigit( jsp.charAt( i + 1 ) ) ) {
                 i++;
                 continue;
             }
@@ -160,33 +130,30 @@ public abstract class AbstractCommand implements Command
     }
 
     /**
-     * Returns a defensively-created array of all
-     * static Commands.
+     * Returns a defensively-created array of all static Commands.
+     *
      * @return the array of commands
      */
-    public static final Command[] allCommands()
-    {
+    public static Command[] allCommands() {
         return ALL_COMMANDS.clone();
     }
 
     /**
      * @see org.apache.wiki.ui.Command#targetedCommand(Object)
      */
-    public abstract Command targetedCommand( Object target );
+    public abstract Command targetedCommand( final Object target );
 
     /**
      * @see org.apache.wiki.ui.Command#getContentTemplate()
      */
-    public final String getContentTemplate()
-    {
+    public final String getContentTemplate() {
         return m_contentTemplate;
     }
 
     /**
      * @see org.apache.wiki.ui.Command#getJSP()
      */
-    public final String getJSP()
-    {
+    public final String getJSP() {
         return m_jsp;
     }
 
@@ -198,43 +165,39 @@ public abstract class AbstractCommand implements Command
     /**
      * @see org.apache.wiki.ui.Command#getRequestContext()
      */
-    public final String getRequestContext()
-    {
+    public final String getRequestContext() {
         return m_requestContext;
     }
 
     /**
      * @see org.apache.wiki.ui.Command#getTarget()
      */
-    public final Object getTarget()
-    {
+    public final Object getTarget() {
         return m_target;
     }
 
     /**
      * @see org.apache.wiki.ui.Command#getURLPattern()
      */
-    public final String getURLPattern()
-    {
+    public final String getURLPattern() {
         return m_urlPattern;
     }
 
     /**
-     * Returns the "friendly name" for this command's JSP, namely
-     * a beatified version of the JSP's name without the .jsp suffix.
+     * Returns the "friendly name" for this command's JSP, namely a beatified version of the JSP's name without the .jsp suffix.
+     *
      * @return the friendly name
      */
-    protected final String getJSPFriendlyName()
-    {
+    protected final String getJSPFriendlyName() {
         return m_jspFriendlyName;
     }
 
     /**
      * Returns a String representation of the Command.
+     *
      * @see java.lang.Object#toString()
      */
-    public final String toString()
-    {
+    public final String toString() {
         return "Command" +
                "[context=" + m_requestContext + "," +
                "urlPattern=" + m_urlPattern + "," +
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
index 032d643..5a40e6a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/Command.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/Command.java
@@ -21,39 +21,23 @@ 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>
+ * <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 &#8212;
- * 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 properites 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>
+ * <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 &#8212; 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>
+ * <p> Concrete implementations of Command include: </p>
  * <ul>
- * <li><strong>PageCommand</strong>: commands for editing, renaming, and
- * viewing pages</li>
+ * <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
@@ -62,30 +46,21 @@ import java.security.Permission;
  * 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>
+ * 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
-{
+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).
+     * 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
@@ -93,65 +68,59 @@ public interface Command
     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
+     * 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.
+     * 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.
+     * 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
+     * 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
+     * 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.
+     * 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 5c7af48..64f965e 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
@@ -31,104 +31,82 @@ import org.apache.wiki.util.TextUtil;
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.Properties;
 
 /**
- * <p>Resolves special pages, JSPs and Commands on behalf of a
- * WikiEngine. CommandResolver will automatically resolve page names
- * with singular/plural variants. It can also detect the correct Command
- * based on parameters supplied in an HTTP request, or due to the
+ * <p>Resolves special pages, JSPs and Commands on behalf of a WikiEngine. CommandResolver will automatically resolve page names
+ * with singular/plural variants. It can also detect the correct Command based on parameters supplied in an HTTP request, or due to the
  * JSP being accessed.</p>
  * <p>
- * <p>CommandResolver's static {@link #findCommand(String)} method is
- * the simplest method; it looks up and returns the Command matching
- * a supplied wiki context. For example, looking up the request context
- * <code>view</code> returns {@link PageCommand#VIEW}. Use this method
- * to obtain static Command instances that aren't targeted at a particular
- * page or group.</p>
- * <p>For more complex lookups in which the caller supplies an HTTP
- * request, {@link #findCommand(HttpServletRequest, String)} will
- * look up and return the correct Command. The String parameter
- * <code>defaultContext</code> supplies the request context to use
- * if it cannot be detected. However, note that the default wiki
- * context may be over-ridden if the request was for a "special page."</p>
- * <p>For example, suppose the WikiEngine's properties specify a
- * special page called <code>UserPrefs</code>
- * that redirects to <code>UserPreferences.jsp</code>. The ordinary
- * lookup method {@linkplain #findCommand(String)} using a supplied
- * context <code>view</code> would return {@link PageCommand#VIEW}. But
- * the {@linkplain #findCommand(HttpServletRequest, String)} method,
- * when passed the same context (<code>view</code>) and an HTTP request
- * containing the page parameter value <code>UserPrefs</code>,
- * will instead return {@link WikiCommand#PREFS}.</p>
+ * <p>CommandResolver's static {@link #findCommand(String)} method is the simplest method; it looks up and returns the Command matching
+ * a supplied wiki context. For example, looking up the request context <code>view</code> returns {@link PageCommand#VIEW}. Use this method
+ * to obtain static Command instances that aren't targeted at a particular page or group.</p>
+ * <p>For more complex lookups in which the caller supplies an HTTP request, {@link #findCommand(HttpServletRequest, String)} will
+ * look up and return the correct Command. The String parameter <code>defaultContext</code> supplies the request context to use
+ * if it cannot be detected. However, note that the default wiki context may be overridden if the request was for a "special page."</p>
+ * <p>For example, suppose the WikiEngine's properties specify a special page called <code>UserPrefs</code> that redirects to
+ * <code>UserPreferences.jsp</code>. The ordinary lookup method {@linkplain #findCommand(String)} using a supplied context <code>view</code>
+ * would return {@link PageCommand#VIEW}. But the {@linkplain #findCommand(HttpServletRequest, String)} method, when passed the same context
+ * (<code>view</code>) and an HTTP request containing the page parameter value <code>UserPrefs</code>, will instead return
+ * {@link WikiCommand#PREFS}.</p>
+ *
  * @since 2.4.22
  */
-public final class CommandResolver
-{
+public final class CommandResolver {
     /** Prefix in jspwiki.properties signifying special page keys. */
     private static final String PROP_SPECIALPAGE = "jspwiki.specialPage.";
 
     /** Private map with request contexts as keys, Commands as values */
-    private static final Map<String, Command>    CONTEXTS;
+    private static final Map< String, Command > CONTEXTS;
 
     /** Private map with JSPs as keys, Commands as values */
-    private static final Map<String, Command>    JSPS;
-
-    /** Store the JSP-to-Command and context-to-Command mappings */
-    static
-    {
-        CONTEXTS = new HashMap<String, Command>();
-        JSPS = new HashMap<String, Command>();
-        Command[] commands = AbstractCommand.allCommands();
-        for( int i = 0; i < commands.length; i++ )
-        {
-            JSPS.put( commands[i].getJSP(), commands[i] );
-            CONTEXTS.put( commands[i].getRequestContext(), commands[i] );
+    private static final Map< String, Command > JSPS;
+
+    /* Store the JSP-to-Command and context-to-Command mappings */
+    static {
+        CONTEXTS = new HashMap<>();
+        JSPS = new HashMap<>();
+        final Command[] commands = AbstractCommand.allCommands();
+        for( final Command command : commands ) {
+            JSPS.put( command.getJSP(), command );
+            CONTEXTS.put( command.getRequestContext(), command );
         }
     }
 
-    private final Logger        m_log = Logger.getLogger( CommandResolver.class );
+    private static final Logger LOG = Logger.getLogger( CommandResolver.class );
 
-    private final WikiEngine    m_engine;
+    private final WikiEngine m_engine;
 
     /** If true, we'll also consider english plurals (+s) a match. */
-    private final boolean       m_matchEnglishPlurals;
+    private final boolean m_matchEnglishPlurals;
 
     /** Stores special page names as keys, and Commands as values. */
     private final Map<String, Command> m_specialPages;
 
     /**
-     * Constructs a CommandResolver for a given WikiEngine. This constructor
-     * will extract the special page references for this wiki and store them in
-     * a cache used for resolution.
+     * Constructs a CommandResolver for a given WikiEngine. This constructor will extract the special page references for this wiki and
+     * store them in a cache used for resolution.
+     *
      * @param engine the wiki engine
      * @param properties the properties used to initialize the wiki
      */
-    public CommandResolver( WikiEngine engine, Properties properties )
-    {
+    public CommandResolver( final WikiEngine engine, final Properties properties ) {
         m_engine = engine;
-        m_specialPages = new HashMap<String, Command>();
-
-        // Skim through the properties and look for anything with
-        // the "special page" prefix. Create maps that allow us
-        // look up the correct Command based on special page name.
-        // If a matching command isn't found, create a RedirectCommand.
-        for(String key : properties.stringPropertyNames())
-        {
-            if ( key.startsWith( PROP_SPECIALPAGE ) )
-            {
+        m_specialPages = new HashMap<>();
+
+        // Skim through the properties and look for anything with the "special page" prefix. Create maps that allow us look up
+        // the correct Command based on special page name. If a matching command isn't found, create a RedirectCommand.
+        for( final String key : properties.stringPropertyNames() ) {
+            if ( key.startsWith( PROP_SPECIALPAGE ) ) {
                 String specialPage = key.substring( PROP_SPECIALPAGE.length() );
-                String jsp = (String) properties.getProperty(key);
-                if ( specialPage != null && jsp != null )
-                {
+                String jsp = properties.getProperty( key );
+                if ( jsp != null ) {
                     specialPage = specialPage.trim();
                     jsp = jsp.trim();
                     Command command = JSPS.get( jsp );
-                    if ( command == null )
-                    {
-                        Command redirect = RedirectCommand.REDIRECT;
+                    if ( command == null ) {
+                        final Command redirect = RedirectCommand.REDIRECT;
                         command = redirect.targetedCommand( jsp );
                     }
                     m_specialPages.put( specialPage, command );
@@ -141,61 +119,42 @@ public final class CommandResolver
     }
 
     /**
-     * Attempts to locate a wiki command for a supplied request context.
-     * The resolution technique is simple: we examine the list of
-     * Commands returned by {@link AbstractCommand#allCommands()} and
-     * return the one whose <code>requestContext</code> matches the
-     * supplied context. If the supplied context does not resolve to a known
-     * Command, this method throws an {@link IllegalArgumentException}.
+     * Attempts to locate a wiki command for a supplied request context. The resolution technique is simple: we examine the list of
+     * Commands returned by {@link AbstractCommand#allCommands()} and return the one whose <code>requestContext</code> matches the
+     * supplied context. If the supplied context does not resolve to a known Command, this method throws an {@link IllegalArgumentException}.
+     *
      * @param context the request context
      * @return the resolved context
      */
-    public static Command findCommand( String context )
-    {
-        Command command = CONTEXTS.get( context );
-        if ( command == null )
-        {
+    public static Command findCommand( final String context ) {
+        final Command command = CONTEXTS.get( context );
+        if ( command == null ) {
             throw new IllegalArgumentException( "Unsupported wiki context: " + context + "." );
         }
         return command;
     }
 
     /**
-     * <p>
-     * Attempts to locate a Command for a supplied wiki context and HTTP
-     * request, incorporating the correct WikiPage into the command if reqiured.
-     * This method will first determine what page the user requested by
-     * delegating to {@link #extractPageFromParameter(String, HttpServletRequest)}. If
-     * this page equates to a special page, we return the Command
-     * corresponding to that page. Otherwise, this method simply returns the
-     * Command for the supplied request context.
-     * </p>
-     * <p>
-     * The reason this method attempts to resolve against special pages is
-     * because some of them resolve to contexts that may be different from the
-     * one supplied. For example, a VIEW request context for the special page
-     * "UserPreferences" should return a PREFS context instead.
-     * </p>
-     * <p>
-     * When the caller supplies a request context and HTTP request that
-     * specifies an actual wiki page (rather than a special page), this method
-     * will return a "targeted" Command that includes the resolved WikiPage
-     * as the target. (See {@link #resolvePage(HttpServletRequest, String)}
-     * for the resolution algorithm). Specifically, the Command will
-     * return a non-<code>null</code> value for its {@link AbstractCommand#getTarget()} method.
-     * </p>
-     * <p><em>Note: if this method determines that the Command is the VIEW PageCommand,
-     * then the Command returned will always be targeted to the front page.</em></p>
-     * @param request the HTTP request; if <code>null</code>, delegates
-     * to {@link #findCommand(String)}
+     * <p>Attempts to locate a Command for a supplied wiki context and HTTP request, incorporating the correct WikiPage into the command
+     * if required. This method will first determine what page the user requested by delegating to {@link #extractPageFromParameter(String, HttpServletRequest)}.
+     * If this page equates to a special page, we return the Command corresponding to that page. Otherwise, this method simply returns the
+     * Command for the supplied request context.</p>
+     * <p>The reason this method attempts to resolve against special pages is because some of them resolve to contexts that may be different
+     * from the one supplied. For example, a VIEW request context for the special page "UserPreferences" should return a PREFS context instead.</p>
+     * <p>When the caller supplies a request context and HTTP request that specifies an actual wiki page (rather than a special page),
+     * this method will return a "targeted" Command that includes the resolved WikiPage as the target. (See {@link #resolvePage(HttpServletRequest, String)}
+     * for the resolution algorithm). Specifically, the Command will return a non-<code>null</code> value for
+     * its {@link AbstractCommand#getTarget()} method.</p>
+     * <p><em>Note: if this method determines that the Command is the VIEW PageCommand, then the Command returned will always be targeted to
+     * the front page.</em></p>
+     *
+     * @param request the HTTP request; if <code>null</code>, delegates to {@link #findCommand(String)}
      * @param defaultContext the request context to use by default
      * @return the resolved wiki command
      */
-    public Command findCommand( HttpServletRequest request, String defaultContext )
-    {
+    public Command findCommand( final HttpServletRequest request, final String defaultContext ) {
         // Corner case if request is null
-        if ( request == null )
-        {
+        if ( request == null ) {
             return findCommand( defaultContext );
         }
 
@@ -205,62 +164,49 @@ public final class CommandResolver
         String pageName = extractPageFromParameter( defaultContext, request );
 
         // Can we find a special-page command matching the extracted page?
-        if ( pageName != null )
-        {
+        if ( pageName != null ) {
             command = m_specialPages.get( pageName );
         }
 
-        // If we haven't found a matching command yet, extract the JSP path
-        // and compare to our list of special pages
-        if ( command == null )
-        {
+        // If we haven't found a matching command yet, extract the JSP path and compare to our list of special pages
+        if ( command == null ) {
             command = extractCommandFromPath( request );
 
             // Otherwise: use the default context
-            if ( command == null )
-            {
+            if ( command == null ) {
                 command = CONTEXTS.get( defaultContext );
-                if ( command == null )
-                {
+                if ( command == null ) {
                     throw new IllegalArgumentException( "Wiki context " + defaultContext + " is illegal." );
                 }
             }
         }
 
         // For PageCommand.VIEW, default to front page if a page wasn't supplied
-        if( PageCommand.VIEW.equals( command ) && pageName == null )
-        {
+        if( PageCommand.VIEW.equals( command ) && pageName == null ) {
             pageName = m_engine.getFrontPage();
         }
 
         // These next blocks handle targeting requirements
 
         // If we were passed a page parameter, try to resolve it
-        if ( command instanceof PageCommand && pageName != null )
-        {
+        if ( command instanceof PageCommand && pageName != null ) {
             // If there's a matching WikiPage, "wrap" the command
-            WikiPage page = resolvePage( request, pageName );
-            if ( page != null )
-            {
-                return command.targetedCommand( page );
-            }
+            final WikiPage page = resolvePage( request, pageName );
+            return command.targetedCommand( page );
         }
 
         // If "create group" command, target this wiki
-        String wiki = m_engine.getApplicationName();
-        if ( WikiCommand.CREATE_GROUP.equals( command ) )
-        {
+        final String wiki = m_engine.getApplicationName();
+        if ( WikiCommand.CREATE_GROUP.equals( command ) ) {
             return WikiCommand.CREATE_GROUP.targetedCommand( wiki );
         }
 
         // If group command, see if we were passed a group name
-        if ( command instanceof GroupCommand )
-        {
+        if( command instanceof GroupCommand ) {
             String groupName = request.getParameter( "group" );
             groupName = TextUtil.replaceEntities( groupName );
-            if ( groupName != null && groupName.length() > 0 )
-            {
-                GroupPrincipal group = new GroupPrincipal( groupName );
+            if ( groupName != null && groupName.length() > 0 ) {
+                final GroupPrincipal group = new GroupPrincipal( groupName );
                 return command.targetedCommand( group );
             }
         }
@@ -270,59 +216,40 @@ public final class CommandResolver
     }
 
     /**
-     * <p>
-     * Returns the correct page name, or <code>null</code>, if no such page can be found.
-     * Aliases are considered.
-     * </p>
-     * <p>
-     * In some cases, page names can refer to other pages. For example, when you
-     * have matchEnglishPlurals set, then a page name "Foobars" will be
-     * transformed into "Foobar", should a page "Foobars" not exist, but the
-     * page "Foobar" would. This method gives you the correct page name to refer
-     * to.
-     * </p>
-     * <p>
-     * This facility can also be used to rewrite any page name, for example, by
-     * using aliases. It can also be used to check the existence of any page.
-     * </p>
+     * <p>Returns the correct page name, or <code>null</code>, if no such page can be found. Aliases are considered.</p>
+     * <p>In some cases, page names can refer to other pages. For example, when you have matchEnglishPlurals set, then a page name
+     * "Foobars" will be transformed into "Foobar", should a page "Foobars" not exist, but the page "Foobar" would. This method gives
+     * you the correct page name to refer to. </p>
+     * <p>This facility can also be used to rewrite any page name, for example, by using aliases. It can also be used to check the
+     * existence of any page.</p>
+     *
      * @since 2.4.20
      * @param page the page name.
      * @return The rewritten page name, or <code>null</code>, if the page does not exist.
-     * @throws ProviderException if the underlyng page provider that locates pages
-     * throws an exception
+     * @throws ProviderException if the underlyng page provider that locates pages throws an exception
      */
-    public String getFinalPageName( String page ) throws ProviderException
-    {
+    public String getFinalPageName( final String page ) throws ProviderException {
         boolean isThere = simplePageExists( page );
         String  finalName = page;
 
-        if ( !isThere && m_matchEnglishPlurals )
-        {
-            if ( page.endsWith( "s" ) )
-            {
+        if ( !isThere && m_matchEnglishPlurals ) {
+            if ( page.endsWith( "s" ) ) {
                 finalName = page.substring( 0, page.length() - 1 );
-            }
-            else
-            {
+            } else {
                 finalName += "s";
             }
 
             isThere = simplePageExists( finalName );
         }
 
-        if( !isThere )
-        {
+        if( !isThere ) {
             finalName = MarkupParser.wikifyLink( page );
             isThere = simplePageExists(finalName);
 
-            if( !isThere && m_matchEnglishPlurals )
-            {
-                if( finalName.endsWith( "s" ) )
-                {
+            if( !isThere && m_matchEnglishPlurals ) {
+                if( finalName.endsWith( "s" ) ) {
                     finalName = finalName.substring( 0, finalName.length() - 1 );
-                }
-                else
-                {
+                } else {
                     finalName += "s";
                 }
 
@@ -334,74 +261,56 @@ public final class CommandResolver
     }
 
     /**
-     * <p>
-     * If the page is a special page, this method returns a direct URL to that
-     * page; otherwise, it returns <code>null</code>.
-     * </p>
-     * <p>
-     * Special pages are non-existant references to other pages. For example,
-     * you could define a special page reference "RecentChanges" which would
-     * always be redirected to "RecentChanges.jsp" instead of trying to find a
-     * Wiki page called "RecentChanges".
-     * </p>
+     * <p>If the page is a special page, this method returns a direct URL to that page; otherwise, it returns <code>null</code>.</p>
+     * <p>Special pages are non-existant references to other pages. For example, you could define a special page reference "RecentChanges"
+     * which would always be redirected to "RecentChanges.jsp" instead of trying to find a Wiki page called "RecentChanges".</p>
+     *
      * @param page the page name ro search for
      * @return the URL of the special page, if the supplied page is one, or <code>null</code>
      */
-    public String getSpecialPageReference( String page )
-    {
-        Command command = m_specialPages.get( page );
-
-        if ( command != null )
-        {
+    public String getSpecialPageReference( final String page ) {
+        final Command command = m_specialPages.get( page );
+        if ( command != null ) {
             return m_engine.getURLConstructor()
-                    .makeURL( command.getRequestContext(), command.getURLPattern(), true, null );
+                           .makeURL( command.getRequestContext(), command.getURLPattern(), true, null );
         }
 
         return null;
     }
 
     /**
-     * Extracts a Command based on the JSP path of an HTTP request.
-     * If the JSP requested matches a Command's <code>getJSP()</code>
+     * Extracts a Command based on the JSP path of an HTTP request. If the JSP requested matches a Command's <code>getJSP()</code>
      * value, that Command is returned.
+     *
      * @param request the HTTP request
      * @return the resolved Command, or <code>null</code> if not found
      */
-    protected Command extractCommandFromPath( HttpServletRequest request )
-    {
+    protected Command extractCommandFromPath( final HttpServletRequest request ) {
         String jsp = request.getServletPath();
 
         // Take everything to right of initial / and left of # or ?
-        int hashMark = jsp.indexOf( '#' );
-        if ( hashMark != -1 )
-        {
+        final int hashMark = jsp.indexOf( '#' );
+        if ( hashMark != -1 ) {
             jsp = jsp.substring( 0, hashMark );
         }
-        int questionMark = jsp.indexOf( '?' );
-        if ( questionMark != -1 )
-        {
+        final int questionMark = jsp.indexOf( '?' );
+        if ( questionMark != -1 ) {
             jsp = jsp.substring( 0, questionMark );
         }
-        if ( jsp.startsWith( "/" ) )
-        {
+        if ( jsp.startsWith( "/" ) ) {
             jsp = jsp.substring( 1 );
         }
 
         // Find special page reference?
-        for( Iterator< Map.Entry< String, Command > > i = m_specialPages.entrySet().iterator(); i.hasNext(); )
-        {
-            Map.Entry< String, Command > entry = i.next();
-            Command specialCommand = entry.getValue();
-            if ( specialCommand.getJSP().equals( jsp ) )
-            {
+        for( final Map.Entry< String, Command > entry : m_specialPages.entrySet() ) {
+            final Command specialCommand = entry.getValue();
+            if( specialCommand.getJSP().equals( jsp ) ) {
                 return specialCommand;
             }
         }
 
-        // Still haven't found a matching command?
-        // Ok, see if we match against our standard list of JSPs
-        if ( jsp.length() > 0 && JSPS.containsKey( jsp ) )
-        {
+        // Still haven't found a matching command? Ok, see if we match against our standard list of JSPs
+        if ( jsp.length() > 0 && JSPS.containsKey( jsp ) ) {
             return JSPS.get( jsp );
         }
 
@@ -409,35 +318,27 @@ public final class CommandResolver
     }
 
     /**
-     * Determines the correct wiki page based on a supplied request context and
-     * HTTP request. This method attempts to determine the page requested by a
-     * user, taking into acccount special pages. The resolution algorithm will:
+     * Determines the correct wiki page based on a supplied request context and HTTP request. This method attempts to determine the page
+     * requested by a user, taking into acccount special pages. The resolution algorithm will:
      * <ul>
-     * <li>Extract the page name from the URL according to the rules for the
-     * current {@link org.apache.wiki.url.URLConstructor}. If a page name was
-     * passed in the request, return the correct name after taking into account
-     * potential plural matches.</li>
-     * <li>If the extracted page name is <code>null</code>, attempt to see
-     * if a "special page" was intended by examining the servlet path. For
-     * example, the request path "/UserPreferences.jsp" will resolve to
-     * "UserPreferences."</li>
-     * <li>If neither of these methods work, this method returns
-     * <code>null</code></li>
+     * <li>Extract the page name from the URL according to the rules for the current {@link org.apache.wiki.url.URLConstructor}. If a
+     * page name was passed in the request, return the correct name after taking into account potential plural matches.</li>
+     * <li>If the extracted page name is <code>null</code>, attempt to see if a "special page" was intended by examining the servlet path.
+     * For example, the request path "/UserPreferences.jsp" will resolve to "UserPreferences."</li>
+     * <li>If neither of these methods work, this method returns <code>null</code></li>
      * </ul>
+     *
      * @param requestContext the request context
      * @param request the HTTP request
      * @return the resolved page name
      */
     protected String extractPageFromParameter( final String requestContext, final HttpServletRequest request ) {
-        String page;
-
         // Extract the page name from the URL directly
         try {
-            page = m_engine.getURLConstructor().parsePage( requestContext, request, m_engine.getContentEncoding() );
+            String page = m_engine.getURLConstructor().parsePage( requestContext, request, m_engine.getContentEncoding() );
             if ( page != null ) {
                 try {
-                    // Look for singular/plural variants; if one
-                    // not found, take the one the user supplied
+                    // Look for singular/plural variants; if one not found, take the one the user supplied
                     final String finalPage = getFinalPageName( page );
                     if ( finalPage != null ) {
                         page = finalPage;
@@ -448,8 +349,8 @@ public final class CommandResolver
                 return page;
             }
         } catch( final IOException e ) {
-            m_log.error( "Unable to create context", e );
-            throw new InternalWikiException( "Big internal booboo, please check logs." , e);
+            LOG.error( "Unable to create context", e );
+            throw new InternalWikiException( "Big internal booboo, please check logs." , e );
         }
 
         // Didn't resolve; return null
@@ -457,39 +358,28 @@ public final class CommandResolver
     }
 
     /**
-     * Looks up and returns the correct, versioned WikiPage based on a supplied
-     * page name and optional <code>version</code> parameter passed in an HTTP
-     * request. If the <code>version</code> parameter does not exist in the
-     * request, the latest version is returned.
+     * Looks up and returns the correct, versioned WikiPage based on a supplied page name and optional <code>version</code> parameter
+     * passed in an HTTP request. If the <code>version</code> parameter does not exist in the request, the latest version is returned.
+     *
      * @param request the HTTP request
      * @param page the name of the page to look up; this page <em>must</em> exist
      * @return the wiki page
      */
-    protected WikiPage resolvePage( HttpServletRequest request, String page )
-    {
+    protected WikiPage resolvePage( final HttpServletRequest request, String page ) {
         // See if the user included a version parameter
-        WikiPage wikipage;
         int version = WikiProvider.LATEST_VERSION;
-        String rev = request.getParameter( "version" );
-
-        if ( rev != null )
-        {
-            try
-            {
+        final String rev = request.getParameter( "version" );
+        if ( rev != null ) {
+            try {
                 version = Integer.parseInt( rev );
-            }
-            catch( NumberFormatException e )
-            {
-                // This happens a lot with bots or other guys who are trying
-                // to test if we are vulnerable to e.g. XSS attacks.  We catch
+            } catch( final NumberFormatException e ) {
+                // This happens a lot with bots or other guys who are trying to test if we are vulnerable to e.g. XSS attacks.  We catch
                 // it here so that the admin does not get tons of mail.
             }
         }
 
-        wikipage = m_engine.getPageManager().getPage( page, version );
-
-        if ( wikipage == null )
-        {
+        WikiPage wikipage = m_engine.getPageManager().getPage( page, version );
+        if ( wikipage == null ) {
             page = MarkupParser.cleanLink( page );
             wikipage = new WikiPage( m_engine, page );
         }
@@ -497,18 +387,15 @@ public final class CommandResolver
     }
 
     /**
-     * Determines whether a "page" exists by examining the list of special pages
-     * and querying the page manager.
+     * Determines whether a "page" exists by examining the list of special pages and querying the page manager.
+     *
      * @param page the page to seek
-     * @return <code>true</code> if the page exists, <code>false</code>
-     *         otherwise
+     * @return <code>true</code> if the page exists, <code>false</code> otherwise
      * @throws ProviderException if the underlyng page provider that locates pages
      * throws an exception
      */
-    protected boolean simplePageExists( String page ) throws ProviderException
-    {
-        if ( m_specialPages.containsKey( page ) )
-        {
+    protected boolean simplePageExists( final String page ) throws ProviderException {
+        if ( m_specialPages.containsKey( page ) ) {
             return true;
         }
         return m_engine.getPageManager().pageExists( page );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
index c66e810..217c1bd 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
@@ -31,7 +31,6 @@ import org.jdom2.Element;
 import javax.servlet.jsp.PageContext;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
@@ -60,32 +59,30 @@ import java.util.Set;
  */
 public class EditorManager extends ModuleManager {
 
-    /** The property name for setting the editor.  Current value is "jspwiki.editor" */
-    /* not used anymore -- replaced by defaultpref.template.editor */
-    public static final String       PROP_EDITORTYPE = "jspwiki.editor";
+    /** The property name for setting the editor. Current value is "jspwiki.editor" - not used anymore: replaced by defaultpref.template.editor */
+    public static final String PROP_EDITORTYPE = "jspwiki.editor";
 
     /** Parameter for changing editors at run-time */
-    public static final String       PARA_EDITOR     = "editor";
+    public static final String PARA_EDITOR = "editor";
 
     /** Known name for the plain wikimarkup editor. */
-    public static final String       EDITOR_PLAIN    = "plain";
+    public static final String EDITOR_PLAIN = "plain";
 
     /** Known name for the preview editor component. */
-    public static final String       EDITOR_PREVIEW  = "preview";
+    public static final String EDITOR_PREVIEW = "preview";
 
     /** Known attribute name for storing the user edited text inside a HTTP parameter. */
-    public static final String       REQ_EDITEDTEXT  = "_editedtext";
+    public static final String REQ_EDITEDTEXT = "_editedtext";
 
     /** Known attribute name for storing the user edited text inside a session or a page context */
-    public static final String       ATTR_EDITEDTEXT = REQ_EDITEDTEXT;
+    public static final String ATTR_EDITEDTEXT = REQ_EDITEDTEXT;
 
-    private             Map<String, WikiEditorInfo>  m_editors;
+    private Map< String, WikiEditorInfo > m_editors;
 
-    private static      Logger       log             = Logger.getLogger( EditorManager.class );
+    private static final Logger log = Logger.getLogger( EditorManager.class );
 
-    public EditorManager( WikiEngine engine )
-    {
-        super(engine);
+    public EditorManager( final WikiEngine engine ) {
+        super( engine );
     }
 
     /**
@@ -93,8 +90,7 @@ public class EditorManager extends ModuleManager {
      *
      *  @param props  Properties for setup.
      */
-    public void initialize( Properties props )
-    {
+    public void initialize( final Properties props ) {
         registerEditors();
     }
 
@@ -112,14 +108,12 @@ public class EditorManager extends ModuleManager {
         //
         // Get all resources of all modules
         //
-        List< Element > editors = XmlUtil.parse( PLUGIN_RESOURCE_LOCATION, "/modules/editor" );
+        final List< Element > editors = XmlUtil.parse( PLUGIN_RESOURCE_LOCATION, "/modules/editor" );
+        for( final Element pluginEl : editors ) {
+            final String name = pluginEl.getAttributeValue( "name" );
+            final WikiEditorInfo info = WikiEditorInfo.newInstance( name, pluginEl );
 
-        for( Iterator< Element > i = editors.iterator(); i.hasNext(); ) {
-            Element pluginEl = i.next();
-            String name = pluginEl.getAttributeValue( "name" );
-            WikiEditorInfo info = WikiEditorInfo.newInstance( name, pluginEl );
-
-            if( checkCompatibility(info) ) {
+            if( checkCompatibility( info ) ) {
                 m_editors.put( name, info );
                 log.debug( "Registered editor " + name );
             } else {
@@ -129,10 +123,8 @@ public class EditorManager extends ModuleManager {
     }
 
     /**
-     *  Returns an editor for the current context.  The editor names are matched in
-     *  a case insensitive manner.  At the moment, the only place that this method
-     *  looks in is the property file, but in the future this will also look at
-     *  user preferences.
+     *  Returns an editor for the current context.  The editor names are matched in a case insensitive manner.  At the moment, the only
+     *  place that this method looks in is the property file, but in the future this will also look at user preferences.
      *  <p>
      *  Determines the editor to use by the following order of conditions:
      *  1. Editor set in User Preferences
@@ -141,41 +133,30 @@ public class EditorManager extends ModuleManager {
      *  For the PREVIEW context, this method returns the "preview" editor.
      *
      * @param context The context that is chosen.
-     * @return The name of the chosen editor.  If no match could be found, will
-     *         revert to the default "plain" editor.
+     * @return The name of the chosen editor. If no match could be found, will revert to the default "plain" editor.
      */
-    public String getEditorName( WikiContext context )
-    {
-        if( context.getRequestContext().equals(WikiContext.PREVIEW) )
+    public String getEditorName( final WikiContext context ) {
+        if( context.getRequestContext().equals( WikiContext.PREVIEW ) ) {
             return EDITOR_PREVIEW;
-
-        String editor = null;
+        }
 
         // User has set an editor in preferences
-        editor = Preferences.getPreference( context, PARA_EDITOR );
+        String editor = Preferences.getPreference( context, PARA_EDITOR );
 
         /* FIXME: actual default 'editor' property is read by the Preferences class */
-        if (editor == null)
-        {
+        if( editor == null ) {
             // or use the default editor in jspwiki.properties
-            try
-            {
+            try {
                 editor = m_engine.getVariableManager().getValue( context, PROP_EDITORTYPE );
-            }
-            catch( NoSuchVariableException e ) {} // This is fine
+            } catch( final NoSuchVariableException e ) {} // This is fine
         }
 
-        if (editor != null)
-        {
-            String[] editorlist = getEditorList();
-
+        if( editor != null ) {
+            final String[] editorlist = getEditorList();
             editor = editor.trim();
-
-            for( int i = 0; i < editorlist.length; i++ )
-            {
-                if( editorlist[i].equalsIgnoreCase(editor))
-                {
-                    return editorlist[i];
+            for( final String s : editorlist ) {
+                if( s.equalsIgnoreCase( editor ) ) {
+                    return s;
                 }
             }
         }
@@ -188,11 +169,9 @@ public class EditorManager extends ModuleManager {
      *
      *  @return the list of available editors
      */
-    public String[] getEditorList()
-    {
-        String[] editors = new String[m_editors.size()];
-
-        Set<String> keys = m_editors.keySet();
+    public String[] getEditorList() {
+        final String[] editors = new String[ m_editors.size() ];
+        final Set< String > keys = m_editors.keySet();
 
         return keys.toArray( editors );
     }
@@ -200,23 +179,16 @@ public class EditorManager extends ModuleManager {
     /**
      *  Convenience method for getting the path to the editor JSP file.
      *
-     *  @param context
+     *  @param context WikiContext from where the editor name is retrieved.
      *  @return e.g. "editors/plain.jsp"
      */
-    public String getEditorPath( WikiContext context )
-    {
-        String path = null;
-
-        String editor = getEditorName( context );
-
-        WikiEditorInfo ed = m_editors.get( editor );
-
-        if( ed != null )
-        {
+    public String getEditorPath( final WikiContext context ) {
+        final String editor = getEditorName( context );
+        final WikiEditorInfo ed = m_editors.get( editor );
+        final String path;
+        if( ed != null ) {
             path = ed.getPath();
-        }
-        else
-        {
+        } else {
             path = "editors/"+editor+".jsp";
         }
 
@@ -224,56 +196,44 @@ public class EditorManager extends ModuleManager {
     }
 
     /**
-     *  Convenience function which examines the current context and attempts to figure
-     *  out whether the edited text is in the HTTP request parameters or somewhere in
-     *  the session.
+     *  Convenience function which examines the current context and attempts to figure out whether the edited text is in the HTTP
+     *  request parameters or somewhere in the session.
      *
      *  @param ctx the JSP page context
      *  @return the edited text, if present in the session page context or as a parameter
      */
-    public static String getEditedText( PageContext ctx )
-    {
+    public static String getEditedText( final PageContext ctx ) {
         String usertext = ctx.getRequest().getParameter( REQ_EDITEDTEXT );
-
-        if( usertext == null )
-        {
-            usertext = (String)ctx.findAttribute( ATTR_EDITEDTEXT );
+        if( usertext == null ) {
+            usertext = ( String )ctx.findAttribute( ATTR_EDITEDTEXT );
         }
 
         return usertext;
     }
 
-    /**
-     *  Contains info about an editor.
-     *
-     */
-    private static final class WikiEditorInfo
-        extends WikiModuleInfo
-    {
+    /**  Contains info about an editor. */
+    private static final class WikiEditorInfo extends WikiModuleInfo {
         private String m_path;
 
-        protected static WikiEditorInfo newInstance( String name, Element el )
-        {
-            if( name == null || name.length() == 0 ) return null;
-            WikiEditorInfo info = new WikiEditorInfo( name );
-
+        protected static WikiEditorInfo newInstance( final String name, final Element el ) {
+            if( name == null || name.length() == 0 ) {
+                return null;
+            }
+            final WikiEditorInfo info = new WikiEditorInfo( name );
             info.initializeFromXML( el );
             return info;
         }
 
-        protected void initializeFromXML( Element el )
-        {
+        protected void initializeFromXML( final Element el ) {
             super.initializeFromXML( el );
             m_path = el.getChildText("path");
         }
 
-        private WikiEditorInfo( String name )
-        {
-            super(name);
+        private WikiEditorInfo( final String name ) {
+            super( name );
         }
 
-        public String getPath()
-        {
+        public String getPath() {
             return m_path;
         }
     }
@@ -290,8 +250,8 @@ public class EditorManager extends ModuleManager {
      *  {@inheritDoc}
      */
     @Override
-    public WikiEditorInfo getModuleInfo(String moduleName) {
-        return m_editors.get(moduleName);
+    public WikiEditorInfo getModuleInfo( final String moduleName ) {
+        return m_editors.get( moduleName );
     }
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/GenericHTTPHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/GenericHTTPHandler.java
index 66f77b4..f6b3abe 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/GenericHTTPHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/GenericHTTPHandler.java
@@ -22,15 +22,12 @@ import org.apache.wiki.WikiContext;
 
 /**
  *  Provides a generic HTTP handler interface.
- *  
  *
  */
-public interface GenericHTTPHandler
-{
+public interface GenericHTTPHandler {
     
     /**
-     *  Get an identifier for this particular AdminBean.  This id MUST
-     *  conform to URI rules.  The ID must also be unique across all HTTPHandlers.
+     *  Get an identifier for this particular AdminBean. This id MUST conform to URI rules. The ID must also be unique across all HTTPHandlers.
      *  
      *  @return the identifier for the bean
      */
@@ -39,15 +36,16 @@ public interface GenericHTTPHandler
     /**
      *  Return basic HTML.
      *  
-     *  @param context
+     *  @param context associated WikiContext
      *  @return the HTML for the bean
      */
     String doGet( WikiContext context );
     
     /**
      *  Handles a POST response.
-     *  @param context
+     *  @param context associated WikiContext
      *  @return the response string resulting from the POST
      */
     String doPost( WikiContext context );
+
 }
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 f7af946..2466236 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,105 +18,105 @@
  */
 package org.apache.wiki.ui;
 
-import java.security.Permission;
-
 import org.apache.wiki.auth.GroupPrincipal;
 import org.apache.wiki.auth.permissions.GroupPermission;
 
+import java.security.Permission;
+
 /**
- * <p>Defines Commands for viewing, editing and deleting wiki groups.
- * GroupCommands can be combined with GroupPrincipals to produce
+ * <p>Defines Commands for viewing, editing and deleting wiki groups. GroupCommands can be combined with GroupPrincipals to produce
  * targeted Commands.</p>
- * <p>This class is not <code>final</code>; it may be extended in
- * the future.</p>
+ * <p>This class is not <code>final</code>; it may be extended in the future.</p>
  * @since 2.4.22
  */
-public final class GroupCommand extends AbstractCommand
-{
+public final class GroupCommand extends AbstractCommand {
 
     /** GroupCommand for deleting a group. */
-    public static final Command DELETE_GROUP 
-        = new GroupCommand( "deleteGroup", "%uDeleteGroup.jsp?group=%n", null, null, GroupPermission.DELETE_ACTION );
+    public static final Command DELETE_GROUP = new GroupCommand( "deleteGroup",
+                                                       "%uDeleteGroup.jsp?group=%n",
+                                                  null,
+                                                          null,
+                                                                 GroupPermission.DELETE_ACTION );
 
     /** GroupCommand for editing a group. */
-       public static final Command EDIT_GROUP   
-        = new GroupCommand( "editGroup", "%uEditGroup.jsp?group=%n", "EditGroupContent.jsp", null, GroupPermission.EDIT_ACTION );
+       public static final Command EDIT_GROUP = new GroupCommand( "editGroup",
+                                                        "%uEditGroup.jsp?group=%n",
+                                                   "EditGroupContent.jsp",
+                                                            null,
+                                                                 GroupPermission.EDIT_ACTION );
 
        /** GroupCommand for viewing a group. */
-    public static final Command VIEW_GROUP   
-        = new GroupCommand( "viewGroup", "%uGroup.jsp?group=%n", "GroupContent.jsp", null, GroupPermission.VIEW_ACTION );
+    public static final Command VIEW_GROUP = new GroupCommand( "viewGroup",
+                                                     "%uGroup.jsp?group=%n",
+                                                "GroupContent.jsp",
+                                                        null,
+                                                               GroupPermission.VIEW_ACTION );
 
     private final String m_action;
     
     private final Permission m_permission;
     
     /**
-     * Constructs a new Command with a specified wiki context, URL pattern,
-     * type, and content template. The WikiPage for this command is initialized
-     * to <code>null</code>.
+     * Constructs a new Command with a specified wiki context, URL pattern, type, and content template. The WikiPage for this command is
+     * initialized to <code>null</code>.
+     *
      * @param requestContext the request context
      * @param urlPattern the URL pattern
      * @param target the target of this command (a GroupPrincipal representing a Group); may be <code>null</code>
      * @param action the action used to construct a suitable GroupPermission
      * @param contentTemplate the content template; may be <code>null</code>
-     * @throws IllegalArgumentException if the request content, URL pattern, or
-     *         type is <code>null</code>
+     * @throws IllegalArgumentException if the request content, URL pattern, or type is <code>null</code>
      */
-    private GroupCommand( String requestContext, String urlPattern, String contentTemplate, GroupPrincipal target, String action )
-    {
+    private GroupCommand( final String requestContext,
+                          final String urlPattern,
+                          final String contentTemplate,
+                          final GroupPrincipal target,
+                          final String action ) {
         super( requestContext, urlPattern, contentTemplate, target );
         m_action = action;
-        if ( target == null || m_action == null )
-        {
+        if ( target == null || m_action == null ) {
             m_permission = null;
-        }
-        else
-        {
+        } else {
             m_permission = new GroupPermission( target.getName(), action );
         }
     }
 
     /**
-     * Creates and returns a targeted Command by combining a GroupPrincipal 
-     * with this Command. The supplied <code>target</code> object 
-     * must be non-<code>null</code> and of type GroupPrincipal.
-     * If the target is not of the correct type, this method throws an
+     * Creates and returns a targeted Command by combining a GroupPrincipal with this Command. The supplied <code>target</code> object
+     * must be non-<code>null</code> and of type GroupPrincipal. If the target is not of the correct type, this method throws an
      * {@link IllegalArgumentException}.
+     *
      * @param target the GroupPrincipal to combine into the current Command
      * @return the new, targeted command
      */
-    public Command targetedCommand( Object target )
-    {
-        if ( !( target != null && target instanceof GroupPrincipal ) )
-        {
+    public Command targetedCommand( final Object target ) {
+        if( !( target instanceof GroupPrincipal ) ) {
             throw new IllegalArgumentException( "Target must non-null and of type GroupPrincipal." );
         }
-        return new GroupCommand( getRequestContext(), getURLPattern(), getContentTemplate(), (GroupPrincipal)target, m_action );
+        return new GroupCommand( getRequestContext(), getURLPattern(), getContentTemplate(), ( GroupPrincipal )target, m_action );
     }
     
     /**
-     * Returns the name of the command, which will either be
-     * the target (if specified), or the "friendly name" for the JSP.
+     * 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()
      */
-    public String getName()
-    {
-        Object target = getTarget();
-        if ( target == null )
-        {
+    public String getName() {
+        final Object target = getTarget();
+        if ( target == null ) {
             return getJSPFriendlyName();
         }
-        return ( (GroupPrincipal) target ).getName();
+        return ( ( GroupPrincipal ) target ).getName();
     }
 
     /**
      * Returns the permission required to execute this GroupCommand.
+     *
      * @return the permission
      * @see org.apache.wiki.ui.Command#requiredPermission()
      */
-    public Permission requiredPermission()
-    {
+    public Permission requiredPermission() {
         return m_permission;
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
index ea71b53..65534b9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
@@ -18,34 +18,32 @@
  */
 package org.apache.wiki.ui;
 
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiSession;
+import org.apache.wiki.i18n.InternationalizationManager;
+import org.apache.wiki.preferences.Preferences;
+
 import java.text.MessageFormat;
 import java.util.ResourceBundle;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
-import org.apache.wiki.*;
-import org.apache.wiki.i18n.InternationalizationManager;
-import org.apache.wiki.preferences.Preferences;
-
 /**
- * Provides basic validation services for HTTP parameters. Three standard
- * validators are provided: email address, identifier and standard input. Standard input
- * validator will reject any HTML-like input, and any of a number of special
- * characters.  ID validator rejects HTML and quoted strings, and a couple of special characters.
+ * Provides basic validation services for HTTP parameters. Three standard validators are provided: email address, identifier and
+ * standard input. Standard input validator will reject any HTML-like input, and any of a number of special characters. ID validator
+ * rejects HTML and quoted strings, and a couple of special characters.
+ *
  * @since 2.3.54
  */
-public final class InputValidator
-{
+public final class InputValidator {
     /** Standard input validator. */
-    public static final int        STANDARD       = 0;
+    public static final int STANDARD       = 0;
 
     /** Input validator for e-mail addresses. **/
-    public static final int        EMAIL          = 1;
+    public static final int EMAIL          = 1;
 
-    /**
-     * @since 2.4.82
-     */
-    public static final int        ID             = 2;
+    /** @since 2.4.82 */
+    public static final int ID             = 2;
 
     protected static final Pattern EMAIL_PATTERN  = Pattern.compile( "^[0-9a-zA-Z-_\\.\\+]+@([0-9a-zA-Z-_]+\\.)+[a-zA-Z]+$" );
 
@@ -62,111 +60,94 @@ public final class InputValidator
     private final WikiContext      m_context;
 
     /**
-     * Constructs a new input validator for a specific form and wiki session.
-     * When validation errors are detected, they will be added to the wiki
-     * session's messages.
-     * @param form the ID or name of the form this validator should be
-     * associated with
+     * Constructs a new input validator for a specific form and wiki session. When validation errors are detected, they will be added to
+     * the wiki session's messages.
+     *
+     * @param form the ID or name of the form this validator should be associated with
      * @param context the wiki context
      */
-    public InputValidator( String form, WikiContext context )
-    {
+    public InputValidator( final String form, final WikiContext context ) {
         m_form = form;
         m_context = context;
         m_session = context.getWikiSession();
     }
 
     /**
-     * Validates a string against the {@link #STANDARD} validator and
-     * additionally checks that the value is not <code>null</code> or blank.
+     * Validates a string against the {@link #STANDARD} validator and additionally checks that the value is not <code>null</code> or blank.
+     *
      * @param input the string to validate
      * @param label the label for the string or field ("E-mail address")
-     * @return returns <code>true</code> if valid, <code>false</code>
-     * otherwise
+     * @return returns <code>true</code> if valid, <code>false</code> otherwise
      */
-    public boolean validateNotNull( String input, String label )
-    {
+    public boolean validateNotNull( final String input, final String label ) {
         return validateNotNull( input, label, STANDARD );
     }
 
     /**
-     * Validates a string against a particular pattern type and additionally
-     * checks that the value is not <code>null</code> or blank. Delegates to
-     * {@link #validate(String, String, int)}.
+     * Validates a string against a particular pattern type and additionally checks that the value is not <code>null</code> or blank.
+     * Delegates to {@link #validate(String, String, int)}.
+     *
      * @param input the string to validate
      * @param label the label for the string or field ("E-mail address")
      * @param type the pattern type to use (<em>e.g.</em>, {@link #STANDARD}, {@link #EMAIL}.
-     * @return returns <code>true</code> if valid, <code>false</code>
-     * otherwise
+     * @return returns <code>true</code> if valid, <code>false</code> otherwise
      */
-    public boolean validateNotNull( String input, String label, int type )
-    {
-        if ( isBlank( input ) )
-        {
-            ResourceBundle rb = Preferences.getBundle( m_context, InternationalizationManager.CORE_BUNDLE );
-
-            m_session.addMessage( m_form, MessageFormat.format( rb.getString("validate.cantbenull"),
-                                                                label ) );
+    public boolean validateNotNull( final String input, final String label, final int type ) {
+        if ( isBlank( input ) ) {
+            final ResourceBundle rb = Preferences.getBundle( m_context, InternationalizationManager.CORE_BUNDLE );
+            m_session.addMessage( m_form, MessageFormat.format( rb.getString("validate.cantbenull"), label ) );
             return false;
         }
         return validate( input, label, type ) && !isBlank( input );
     }
 
     /**
-     * Validates a string against a particular pattern type: e-mail address,
-     * standard HTML input, etc. Note that a blank or null string will
+     * Validates a string against a particular pattern type: e-mail address, standard HTML input, etc. Note that a blank or null string will
      * always validate.
+     *
      * @param input the string to validate
      * @param label the label for the string or field ("E-mail address")
-     * @param type the target pattern to validate against ({@link #STANDARD},
-     * {@link #EMAIL})
-     * @return returns <code>true</code> if valid, <code>false</code>
-     * otherwise
+     * @param type the target pattern to validate against ({@link #STANDARD}, {@link #EMAIL})
+     * @return returns <code>true</code> if valid, <code>false</code> otherwise
      */
-    public boolean validate( String input, String label, int type )
-    {
+    public boolean validate( final String input, final String label, final int type ) {
         // If blank, it's valid
-        if ( isBlank( input ) )
-        {
+        if ( isBlank( input ) ) {
             return true;
         }
 
-        ResourceBundle rb = Preferences.getBundle( m_context, InternationalizationManager.CORE_BUNDLE );
+        final ResourceBundle rb = Preferences.getBundle( m_context, InternationalizationManager.CORE_BUNDLE );
 
         // Otherwise, see if it matches the pattern for the target type
-        Matcher matcher;
-        boolean valid;
-        switch( type )
-        {
+        final Matcher matcher;
+        final boolean valid;
+        switch( type ) {
         case STANDARD:
             matcher = UNSAFE_PATTERN.matcher( input );
             valid = !matcher.find();
-            if ( !valid )
-            {
-                //MessageTag already invokes replaceEntities()
-                //Object[] args = { label, "&quot;&#39;&lt;&gt;;&amp;[]#\\@{}%$" };
-                Object[] args = { label, "\'\"<>;&[]#\\@{}%$" };
-                m_session.addMessage( m_form, MessageFormat.format( rb.getString("validate.unsafechars"), args ) );
+            if ( !valid ) {
+                // MessageTag already invokes replaceEntities()
+                // Object[] args = { label, "&quot;&#39;&lt;&gt;;&amp;[]#\\@{}%$" };
+                final Object[] args = { label, "\'\"<>;&[]#\\@{}%$" };
+                m_session.addMessage( m_form, MessageFormat.format( rb.getString( "validate.unsafechars" ), args ) );
             }
             return valid;
         case EMAIL:
             matcher = EMAIL_PATTERN.matcher( input );
             valid = matcher.matches();
-            if ( !valid )
-            {
-                Object[] args = { label };
-                m_session.addMessage( m_form, MessageFormat.format( rb.getString("validate.invalidemail"), args ) );
+            if ( !valid ) {
+                final Object[] args = { label };
+                m_session.addMessage( m_form, MessageFormat.format( rb.getString( "validate.invalidemail" ), args ) );
             }
             return valid;
         case ID:
             matcher = ID_PATTERN.matcher( input );
             valid = !matcher.find();
-            if ( !valid )
-            {
-                //MessageTag already invokes replaceEntities()
-                //Object[] args = { label, "&quot;&#39;&lt;&gt;;&amp;{}" };
-                Object[] args = { label, "\'\"<>;&{}" };
-                m_session.addMessage( m_form, MessageFormat.format( rb.getString("validate.unsafechars"), args ) );
+            if ( !valid ) {
+                // MessageTag already invokes replaceEntities()
+                // Object[] args = { label, "&quot;&#39;&lt;&gt;;&amp;{}" };
+                final Object[] args = { label, "\'\"<>;&{}" };
+                m_session.addMessage( m_form, MessageFormat.format( rb.getString( "validate.unsafechars" ), args ) );
             }
             return valid;
          default:
@@ -177,12 +158,12 @@ public final class InputValidator
 
     /**
      * Returns <code>true</code> if a supplied string is null or blank
+     *
      * @param input the string to check
-     * @return <code>true</code> if <code>null</code> or blank (zero-length);
-     * <code>false</code> otherwise
+     * @return <code>true</code> if <code>null</code> or blank (zero-length); <code>false</code> otherwise
      */
-    public static boolean isBlank( String input )
-    {
+    public static boolean isBlank( final String input ) {
         return input == null || input.trim().length() < 1;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
index f39a10f..243a67b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
@@ -1,4 +1,4 @@
-/* 
+/*
     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
@@ -18,18 +18,6 @@
  */
 package org.apache.wiki.ui;
 
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.text.MessageFormat;
-import java.util.Properties;
-import java.util.ResourceBundle;
-import java.util.Set;
-
-import javax.servlet.ServletConfig;
-import javax.servlet.http.HttpServletRequest;
-
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.auth.NoSuchPrincipalException;
@@ -46,14 +34,25 @@ import org.apache.wiki.providers.BasicAttachmentProvider;
 import org.apache.wiki.providers.FileSystemProvider;
 import org.apache.wiki.util.TextUtil;
 
+import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpServletRequest;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.text.MessageFormat;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.Set;
+
 /**
- * Manages JSPWiki installation on behalf of <code>admin/Install.jsp</code>.
- * The contents of this class were previously part of <code>Install.jsp</code>.
+ * Manages JSPWiki installation on behalf of <code>admin/Install.jsp</code>. The contents of this class were previously part of
+ * <code>Install.jsp</code>.
  *
  * @since 2.4.20
  */
-public class Installer
-{
+public class Installer {
+
     public static final String ADMIN_ID = "admin";
     public static final String ADMIN_NAME = "Administrator";
     public static final String INSTALL_INFO = "Installer.Info";
@@ -73,7 +72,7 @@ public class Installer
     private HttpServletRequest m_request;
     private boolean m_validated;
     
-    public Installer( HttpServletRequest request, ServletConfig config ) throws IOException {
+    public Installer( final HttpServletRequest request, final ServletConfig config ) {
         // Get wiki session for this user
         m_engine = WikiEngine.getInstance( config );
         m_session = WikiSession.getWikiSession( m_engine, request );
@@ -88,59 +87,47 @@ public class Installer
     }
     
     /**
-     * Returns <code>true</code> if the administrative user had
-     * been created previously.
+     * Returns <code>true</code> if the administrative user had been created previously.
+     *
      * @return the result
      */
-    public boolean adminExists()
-    {
+    public boolean adminExists() {
         // See if the admin user exists already
-        UserManager userMgr = m_engine.getUserManager();
-        UserDatabase userDb = userMgr.getUserDatabase();
-        
-        try
-        {
+        final UserManager userMgr = m_engine.getUserManager();
+        final UserDatabase userDb = userMgr.getUserDatabase();
+        try {
             userDb.findByLoginName( ADMIN_ID );
             return true;
-        }
-        catch ( NoSuchPrincipalException e )
-        {
+        } catch ( final NoSuchPrincipalException e ) {
             return false;
         }
     }
     
     /**
-     * Creates an administrative user and returns the new password.
-     * If the admin user exists, the password will be <code>null</code>.
+     * Creates an administrative user and returns the new password. If the admin user exists, the password will be <code>null</code>.
+     *
      * @return the password
-     * @throws WikiSecurityException
      */
-    public String createAdministrator() throws WikiSecurityException
-    {
-        if ( !m_validated )
-        {
+    public String createAdministrator() throws WikiSecurityException {
+        if ( !m_validated ) {
             throw new WikiSecurityException( "Cannot create administrator because one or more of the installation settings are invalid." );
         }
         
-        if ( adminExists() )
-        {
+        if ( adminExists() ) {
             return null;
         }
         
         // See if the admin user exists already
-        UserManager userMgr = m_engine.getUserManager();
-        UserDatabase userDb = userMgr.getUserDatabase();
+        final UserManager userMgr = m_engine.getUserManager();
+        final UserDatabase userDb = userMgr.getUserDatabase();
         String password = null;
         
-        try
-        {
+        try {
             userDb.findByLoginName( ADMIN_ID );
-        }
-        catch ( NoSuchPrincipalException e )
-        {
+        } catch( final NoSuchPrincipalException e ) {
             // Create a random 12-character password
             password = TextUtil.generateRandomPassword();
-            UserProfile profile = userDb.newProfile();
+            final UserProfile profile = userDb.newProfile();
             profile.setLoginName( ADMIN_ID );
             profile.setFullname( ADMIN_NAME );
             profile.setPassword( password );
@@ -148,15 +135,12 @@ public class Installer
         }
         
         // Create a new admin group
-        GroupManager groupMgr = m_engine.getGroupManager();
-        Group group = null;
-        try
-        {
+        final GroupManager groupMgr = m_engine.getGroupManager();
+        Group group;
+        try {
             group = groupMgr.getGroup( ADMIN_GROUP );
             group.add( new WikiPrincipal( ADMIN_NAME ) );
-        }
-        catch ( NoSuchPrincipalException e )
-        {
+        } catch( final NoSuchPrincipalException e ) {
             group = groupMgr.parseGroup( ADMIN_GROUP, ADMIN_NAME, true );
         }
         groupMgr.setGroup( m_session, group );
@@ -168,18 +152,16 @@ public class Installer
      * Returns the properties as a "key=value" string separated by newlines
      * @return the string
      */
-    public String getPropertiesList()
-    {
-        StringBuilder result = new StringBuilder();
-        Set<String> keys = m_props.stringPropertyNames();
-        for (String key:keys) {
-            result.append(key + " = " + m_props.getProperty(key) + "\n");
+    public String getPropertiesList() {
+        final StringBuilder result = new StringBuilder();
+        final Set< String > keys = m_props.stringPropertyNames();
+        for( final String key : keys ) {
+            result.append(key ).append( " = " ).append( m_props.getProperty( key ) ).append( "\n" );
         }
         return result.toString();
     }
 
-    public String getPropertiesPath()
-    {
+    public String getPropertiesPath() {
         return m_propertyFile.getAbsolutePath();
     }
 
@@ -188,17 +170,13 @@ public class Installer
      * @param key the property key
      * @return the property value
      */
-    public String getProperty( String key )
-    {
+    public String getProperty( final String key ) {
         return m_props.getProperty( key );
     }
     
-    public void parseProperties () throws Exception
-    {
-        ResourceBundle rb = ResourceBundle.getBundle( InternationalizationManager.CORE_BUNDLE,
-                                                      m_session.getLocale() );
+    public void parseProperties () {
+        final ResourceBundle rb = ResourceBundle.getBundle( InternationalizationManager.CORE_BUNDLE, m_session.getLocale() );
         m_validated = false;
-        
 
         // Get application name
         String nullValue = m_props.getProperty( APP_NAME, rb.getString( "install.installer.default.appname" ) );
@@ -219,85 +197,63 @@ public class Installer
         m_props.setProperty( PageManager.PROP_PAGEPROVIDER, "VersioningFileProvider" );
     }
     
-    public void saveProperties()
-    {
-        ResourceBundle rb = ResourceBundle.getBundle( InternationalizationManager.CORE_BUNDLE, m_session.getLocale() );
+    public void saveProperties() {
+        final ResourceBundle rb = ResourceBundle.getBundle( InternationalizationManager.CORE_BUNDLE, m_session.getLocale() );
         // Write the file back to disk
-        try
-        {
-            OutputStream out = null;
-            try
-            {
-                out = new FileOutputStream( m_propertyFile );
+        try {
+            try( final OutputStream out = new FileOutputStream( m_propertyFile ) ) {
                 m_props.store( out, null );
             }
-            finally
-            {
-                if ( out != null )
-                {
-                    out.close();
-                }
-            }
             m_session.addMessage( INSTALL_INFO, MessageFormat.format(rb.getString("install.installer.props.saved"), m_propertyFile) );
-        }
-        catch( IOException e )
-        {
-            Object[] args = { e.getMessage(), m_props.toString() };
+        } catch( final IOException e ) {
+            final Object[] args = { e.getMessage(), m_props.toString() };
             m_session.addMessage( INSTALL_ERROR, MessageFormat.format( rb.getString( "install.installer.props.notsaved" ), args ) );
         }
     }
     
-    public boolean validateProperties() throws Exception
-    {
-        ResourceBundle rb = ResourceBundle.getBundle( InternationalizationManager.CORE_BUNDLE, m_session.getLocale() );
+    public boolean validateProperties() {
+        final ResourceBundle rb = ResourceBundle.getBundle( InternationalizationManager.CORE_BUNDLE, m_session.getLocale() );
         m_session.clearMessages( INSTALL_ERROR );
         parseProperties();
         validateNotNull( PAGE_DIR, rb.getString( "install.installer.validate.pagedir" ) );
         validateNotNull( APP_NAME, rb.getString( "install.installer.validate.appname" ) );
         validateNotNull( WORK_DIR, rb.getString( "install.installer.validate.workdir" ) );
 
-        if ( m_session.getMessages( INSTALL_ERROR ).length == 0 )
-        {
+        if ( m_session.getMessages( INSTALL_ERROR ).length == 0 ) {
             m_validated = true;
         }
         return m_validated;
     }
         
     /**
-     * Sets a property based on the value of an HTTP request parameter.
-     * If the parameter is not found, a default value is used instead.
+     * Sets a property based on the value of an HTTP request parameter. If the parameter is not found, a default value is used instead.
+     *
      * @param param the parameter containing the value we will extract
-     * @param defaultValue the default to use if the parameter was not passed
-     * in the request
+     * @param defaultValue the default to use if the parameter was not passed in the request
      */
-    private void parseProperty( String param, String defaultValue )
-    {
+    private void parseProperty( final String param, final String defaultValue ) {
         String value = m_request.getParameter( param );
-        if ( value == null )
-        {
+        if( value == null ) {
             value = defaultValue;
         }
-        m_props.put(param, value);
+        m_props.put( param, value );
     }
     
     /**
-     * Simply sanitizes any path which contains backslashes (sometimes Windows
-     * users may have them) by expanding them to double-backslashes
+     * Simply sanitizes any path which contains backslashes (sometimes Windows users may have them) by expanding them to double-backslashes
+     *
      * @param key the key of the property to sanitize
      */
-    private void sanitizePath( String key )
-    {
+    private void sanitizePath( final String key ) {
         String s = m_props.getProperty( key );
         s = TextUtil.replaceString(s, "\\", "\\\\" );
         s = s.trim();
         m_props.put( key, s );
     }
     
-    private void validateNotNull( String key, String message )
-    {
-        String value = m_props.getProperty( key );
-        if ( value == null || value.length() == 0 )
-        {
+    private void validateNotNull( final String key, final String message ) {
+        final String value = m_props.getProperty( key );
+        if ( value == null || value.length() == 0 ) {
             m_session.addMessage( INSTALL_ERROR, message );
         }
     }
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 5da646e..cd0d886 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
@@ -18,22 +18,19 @@
  */
 package org.apache.wiki.ui;
 
-import java.security.Permission;
-
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.auth.permissions.PermissionFactory;
 
+import java.security.Permission;
+
 /**
- * <p>Defines Commands for editing, renaming, and viewing wiki pages.
- * PageCommands can be combined with WikiPages to produce
+ * <p>Defines Commands for editing, renaming, and viewing wiki pages. PageCommands can be combined with WikiPages to produce
  * targeted Commands.</p>
- * <p>This class is not <code>final</code>; it may be extended in
- * the future.</p>
+ *
  * @since 2.4.22
  */
-public final class PageCommand extends AbstractCommand
-{
+public final class PageCommand extends AbstractCommand {
 
     public static final Command ATTACH
         = new PageCommand( "att", "%uattach/%n", null, null, PagePermission.UPLOAD_ACTION );
@@ -81,66 +78,61 @@ public final class PageCommand extends AbstractCommand
     private final Permission m_permission;
     
     /**
-     * Constructs a new Command with a specified wiki context, URL pattern,
-     * type, and content template. The target for this command is initialized to
-     * <code>null</code>.
+     * Constructs a new Command with a specified wiki context, URL pattern, type, and content template. The target for this command is
+     * initialized to <code>null</code>.
+     *
      * @param requestContext the request context
      * @param urlPattern the URL pattern
      * @param target the target of the command (a WikiPage); may be <code>null</code>
      * @param action the action used to construct a suitable PagePermission
      * @param contentTemplate the content template; may be <code>null</code>
-     * @throws IllegalArgumentException if the request content, URL pattern, or
-     *         type is <code>null</code>
+     * @throws IllegalArgumentException if the request content, URL pattern, or type is <code>null</code>
      */
-    private PageCommand( String requestContext, String urlPattern, String contentTemplate, WikiPage target, String action )
-    {
+    private PageCommand( final String requestContext,
+                         final String urlPattern,
+                         final String contentTemplate,
+                         final WikiPage target,
+                         final String action ) {
         super( requestContext, urlPattern, contentTemplate, target );
         m_action = action;
-        if( target == null || m_action == null )
-        {
+        if( target == null || m_action == null ) {
             m_permission = null;
-        }
-        else
-        {
+        } else {
             m_permission = PermissionFactory.getPagePermission( target, action );
         }
     }
 
     /**
-     * Creates and returns a targeted Command by combining a WikiPage 
-     * with this Command. The supplied <code>target</code> object 
+     * Creates and returns a targeted Command by combining a WikiPage with this Command. The supplied <code>target</code> object
      * must be non-<code>null</code> and of type WikiPage.
+     *
      * @param target the WikiPage to combine into the current Command
      * @return the new targeted command
      * @throws IllegalArgumentException if the target is not of the correct type
      */
-    public Command targetedCommand( Object target )
-    {
-        if( !( target != null && target instanceof WikiPage ) )
-        {
+    public Command targetedCommand( final Object target ) {
+        if( !( target instanceof WikiPage ) ) {
             throw new IllegalArgumentException( "Target must non-null and of type WikiPage." );
         }
-        return new PageCommand( getRequestContext(), getURLPattern(), getContentTemplate(), (WikiPage)target, m_action );
+        return new PageCommand( getRequestContext(), getURLPattern(), getContentTemplate(), ( WikiPage )target, m_action );
     }
 
     /**
      * @see org.apache.wiki.ui.Command#getName()
      */
-    public String getName()
-    {
-        Object target = getTarget();
-        if( target == null )
-        {
+    public String getName() {
+        final Object target = getTarget();
+        if( target == null ) {
             return getJSPFriendlyName();
         }
-        return ( (WikiPage) target ).getName();
+        return ( ( WikiPage )target ).getName();
     }
 
     /**
      * @see org.apache.wiki.ui.Command#requiredPermission()
      */
-    public Permission 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 ba71971..cb098c2 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
@@ -21,68 +21,53 @@ package org.apache.wiki.ui;
 import java.security.Permission;
 
 /**
- * <p>Defines Commands for redirections to off-site special pages. 
- * RedirectCommands do not have associated
- * permissions; the {@link #requiredPermission()} method will
- * always return <code>null</code>. When combined with a supplied String
- * url, the {@link #getTarget()} method will return a String, the
- * {@link #getURLPattern()} method will return the supplied target URL,
+ * <p>Defines Commands for redirections to off-site special pages. RedirectCommands do not have associated permissions; the
+ * {@link #requiredPermission()} method will always return <code>null</code>. When combined with a supplied String url,
+ * the {@link #getTarget()} method will return a String, the {@link #getURLPattern()} method will return the supplied target URL,
  * and {@link #getJSP()} method will return the "cleansed" URL.</p>
- * <p>This class is not <code>final</code>; it may be extended in
- * the future.</p>
+ *
  * @since 2.4.22
  */
-public final class RedirectCommand extends AbstractCommand
-{
+public final class RedirectCommand extends AbstractCommand {
 
-    public static final Command REDIRECT
-        = new RedirectCommand( "", "%u%n", null, null );
+    public static final Command REDIRECT = new RedirectCommand( "", "%u%n", null, null );
 
     /**
-     * Constructs a new Command with a specified wiki context, URL pattern,
-     * type, and content template. The WikiPage for this action is initialized
-     * to <code>null</code>.
+     * Constructs a new Command with a specified wiki context, URL pattern, type, and content template. The WikiPage for this action is
+     * initialized to <code>null</code>.
+     *
      * @param requestContext the request context
      * @param urlPattern the URL pattern
      * @param contentTemplate the content template; may be <code>null</code>
      * @param target the target of the command
-     * @throws IllegalArgumentException if the request content, URL pattern, or
-     *         type is <code>null</code>
+     * @throws IllegalArgumentException if the request content, URL pattern, or type is <code>null</code>
      */
-    private RedirectCommand( String requestContext, String urlPattern, String contentTemplate, String target )
-    {
+    private RedirectCommand( final String requestContext, final String urlPattern, final String contentTemplate, final String target ) {
         super( requestContext, urlPattern, contentTemplate, target );
     }
     
     /**
-     * Creates and returns a targeted Command by combining a URL
-     * (as String) with this Command. The supplied <code>target</code>
-     * object must be non-<code>null</code> and of type String.
-     * The URL passed to the constructor is actually an
-     * URL pattern, but it will be converted to a JSP page if it is a partial
-     * URL. If it is a full URL (beginning with <code>http://</code> or
-     * <code>https://</code>), it will be "passed through" without
-     * conversion, and the URL pattern will be <code>null</code>.
+     * Creates and returns a targeted Command by combining a URL (as String) with this Command. The supplied <code>target</code>
+     * object must be non-<code>null</code> and of type String. The URL passed to the constructor is actually an URL pattern, but it
+     * will be converted to a JSP page if it is a partial URL. If it is a full URL (beginning with <code>http://</code> or
+     * <code>https://</code>), it will be "passed through" without conversion, and the URL pattern will be <code>null</code>.
+     *
      * @param target the object to combine
      * @throws IllegalArgumentException if the target is not of the correct type
      */
-    public Command targetedCommand( Object target )
-    {
-        if ( !( target != null && target instanceof String ) )
-        {
+    public Command targetedCommand( final Object target ) {
+        if ( !( target instanceof String ) ) {
             throw new IllegalArgumentException( "Target must non-null and of type String." );
         }
-        return new RedirectCommand( getRequestContext(), (String)target, getContentTemplate(), (String)target );
+        return new RedirectCommand( getRequestContext(), ( String )target, getContentTemplate(), ( String )target );
     }
     
     /**
      * @see org.apache.wiki.ui.Command#getName()
      */
-    public String getName()
-    {
-        Object target = getTarget();
-        if ( target == null )
-        {
+    public String getName() {
+        final Object target = getTarget();
+        if ( target == null ) {
             return getJSPFriendlyName();
         }
         return target.toString();
@@ -90,10 +75,11 @@ public final class RedirectCommand extends AbstractCommand
 
     /**
      * No-op; always returns <code>null</code>.
+     *
      * @see org.apache.wiki.ui.Command#requiredPermission()
      */
-    public Permission requiredPermission()
-    {
+    public Permission requiredPermission() {
         return null;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
index ce5192f..c2db396 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
@@ -56,8 +56,7 @@ import java.util.Vector;
 
 
 /**
- *  This class takes care of managing JSPWiki templates.  This class also provides
- *  the ResourceRequest mechanism.
+ *  This class takes care of managing JSPWiki templates.  This class also provides the ResourceRequest mechanism.
  *
  *  @since 2.1.62
  */
@@ -65,29 +64,19 @@ public class TemplateManager extends ModuleManager {
 
     private static final String SKIN_DIRECTORY = "skins";
 
-    /**
-     * Requests a JavaScript function to be called during window.onload. Value is {@value}.
-     */
+    /** Requests a JavaScript function to be called during window.onload. Value is {@value}. */
     public static final String RESOURCE_JSFUNCTION = "jsfunction";
 
-    /**
-     * Requests a JavaScript associative array with all localized strings.
-     */
+    /** Requests a JavaScript associative array with all localized strings. */
     public static final String RESOURCE_JSLOCALIZEDSTRINGS = "jslocalizedstrings";
 
-    /**
-     * Requests a stylesheet to be inserted. Value is {@value}.
-     */
+    /** Requests a stylesheet to be inserted. Value is {@value}. */
     public static final String RESOURCE_STYLESHEET = "stylesheet";
 
-    /**
-     * Requests a script to be loaded. Value is {@value}.
-     */
+    /** Requests a script to be loaded. Value is {@value}. */
     public static final String RESOURCE_SCRIPT = "script";
 
-    /**
-     * Requests inlined CSS. Value is {@value}.
-     */
+    /** Requests inlined CSS. Value is {@value}. */
     public static final String RESOURCE_INLINECSS = "inlinecss";
 
     /** The default directory for the properties. Value is {@value}. */
@@ -97,41 +86,32 @@ public class TemplateManager extends ModuleManager {
     public static final String DEFAULT_TEMPLATE = "default";
 
     /** Name of the file that contains the properties. */
-
     public static final String PROPERTYFILE = "template.properties";
 
     /** Location of I18N Resource bundles, and path prefix and suffixes */
-
     public static final String I18NRESOURCE_PREFIX = "templates/default_";
 
     public static final String I18NRESOURCE_SUFFIX = ".properties";
 
     /** The default (en) RESOURCE name and id. */
-
     public static final String I18NRESOURCE_EN = "templates/default.properties";
     public static final String I18NRESOURCE_EN_ID = "en";
 
     /** I18N string to mark the default locale */
-
     public static final String I18NDEFAULT_LOCALE = "prefs.user.language.default";
 
     /** I18N string to mark the server timezone */
-
     public static final String I18NSERVER_TIMEZONE = "prefs.user.timezone.server";
 
     /** Prefix of the default timeformat properties. */
-
     public static final String TIMEFORMATPROPERTIES = "jspwiki.defaultprefs.timeformat.";
 
-    /**
-     * The name under which the resource includes map is stored in the
-     * WikiContext.
-     */
+    /** The name under which the resource includes map is stored in the  WikiContext. */
     public static final String RESOURCE_INCLUDES = "jspwiki.resourceincludes";
 
     // private Cache m_propertyCache;
 
-    protected static final Logger log = Logger.getLogger(TemplateManager.class);
+    private static final Logger log = Logger.getLogger( TemplateManager.class );
 
     /** Requests a HTTP header. Value is {@value}. */
     public static final String RESOURCE_HTTPHEADER = "httpheader";
@@ -142,9 +122,8 @@ public class TemplateManager extends ModuleManager {
      *  @param engine The owning engine.
      *  @param properties The property list used to initialize this.
      */
-    public TemplateManager( WikiEngine engine, Properties properties )
-    {
-        super(engine);
+    public TemplateManager( final WikiEngine engine, final Properties properties ) {
+        super( engine );
 
         //
         //  Uses the unlimited cache.
@@ -156,21 +135,20 @@ public class TemplateManager extends ModuleManager {
      *  Check the existence of a template.
      */
     // FIXME: Does not work yet
-    public boolean templateExists( String templateName ) {
-        ServletContext context = m_engine.getServletContext();
+    public boolean templateExists( final String templateName ) {
+        final ServletContext context = m_engine.getServletContext();
         try( final InputStream in = context.getResourceAsStream( getPath( templateName ) + "ViewTemplate.jsp" ) ) {
             if( in != null ) {
                 return true;
             }
-        } catch( IOException e ) {
+        } catch( final IOException e ) {
             log.error( e.getMessage(), e );
         }
         return false;
     }
 
     /**
-     *  Tries to locate a given resource from the template directory. If the
-     *  given resource is not found under the current name, returns the
+     *  Tries to locate a given resource from the template directory. If the given resource is not found under the current name, returns the
      *  path to the corresponding one in the default template.
      *
      *  @param sContext The servlet context
@@ -200,54 +178,47 @@ public class TemplateManager extends ModuleManager {
      * @param name
      * @return the Resource for the given template and name.
      */
-    private static String findResource( ServletContext sContext, String template, String name )
-    {
-        if( name.charAt(0) == '/' )
-        {
+    private static String findResource( final ServletContext sContext, final String template, final String name ) {
+        if( name.charAt(0) == '/' ) {
             // This is already a full path
             return findResource( sContext, name );
         }
-
-        String fullname = makeFullJSPName( template, name );
-
+        final String fullname = makeFullJSPName( template, name );
         return findResource( sContext, fullname );
     }
 
     /**
-     *  An utility method for finding a JSP page.  It searches only under
-     *  either current context or by the absolute name.
+     *  An utility method for finding a JSP page.  It searches only under either current context or by the absolute name.
      *
      *  @param pageContext the JSP PageContext
      *  @param name The name of the JSP page to look for (e.g "Wiki.jsp")
      *  @return The context path to the resource
      */
-    public String findJSP( PageContext pageContext, String name )
-    {
-        ServletContext sContext = pageContext.getServletContext();
-
+    public String findJSP( final PageContext pageContext, final String name ) {
+        final ServletContext sContext = pageContext.getServletContext();
         return findResource( sContext, name );
     }
 
     /**
      *  Removes the template part of a name.
      */
-    private static String removeTemplatePart( String name )
-    {
+    private static String removeTemplatePart( String name ) {
         int idx = 0;
-        if( name.startsWith( "/" ) ) idx = 1;
+        if( name.startsWith( "/" ) ) {
+            idx = 1;
+        }
 
         idx = name.indexOf('/', idx);
-        if( idx != -1 )
-        {
+        if( idx != -1 ) {
             idx = name.indexOf('/', idx+1); // Find second "/"
-
-            if( idx != -1 )
-            {
+            if( idx != -1 ) {
                 name = name.substring( idx+1 );
             }
         }
 
-        if( log.isDebugEnabled() ) log.debug( "Final name = "+name );
+        if( log.isDebugEnabled() ) {
+            log.debug( "Final name = "+name );
+        }
         return name;
     }
 
@@ -258,45 +229,36 @@ public class TemplateManager extends ModuleManager {
      * @param name The name of the resource.
      * @return The full name for a template.
      */
-    private static String makeFullJSPName( String template, String name )
-    {
-        return "/"+DIRECTORY+"/"+template+"/"+name;
+    private static String makeFullJSPName( final String template, final String name ) {
+        return "/" + DIRECTORY + "/" + template + "/" + name;
     }
 
     /**
-     *  Attempts to locate a resource under the given template.  If that template
-     *  does not exist, or the page does not exist under that template, will
-     *  attempt to locate a similarly named file under the default template.
+     *  Attempts to locate a resource under the given template.  If that template does not exist, or the page does not exist under that
+     *  template, will attempt to locate a similarly named file under the default template.
      *  <p>
-     *  Even though the name suggests only JSP files can be located, but in fact
-     *  this method can find also other resources than JSP files.
+     *  Even though the name suggests only JSP files can be located, but in fact this method can find also other resources than JSP files.
      *
      *  @param pageContext The JSP PageContext
      *  @param template From which template we should seek initially?
      *  @param name Which resource are we looking for (e.g. "ViewTemplate.jsp")
      *  @return path to the JSP page; null, if it was not found.
      */
-    public String findJSP( PageContext pageContext, String template, String name )
-    {
-        if( name == null || template == null )
-        {
-            log.fatal("findJSP() was asked to find a null template or name ("+template+","+name+")."+
-                      " JSP page '"+
-                      ((HttpServletRequest)pageContext.getRequest()).getRequestURI()+"'");
-            throw new InternalWikiException("Illegal arguments to findJSP(); please check logs.");
+    public String findJSP( final PageContext pageContext, final String template, final String name ) {
+        if( name == null || template == null ) {
+            log.fatal("findJSP() was asked to find a null template or name (" + template + "," + name + ")." + " JSP page '" +
+                      ( ( HttpServletRequest )pageContext.getRequest() ).getRequestURI() + "'" );
+            throw new InternalWikiException( "Illegal arguments to findJSP(); please check logs." );
         }
 
         return findResource( pageContext.getServletContext(), template, name );
     }
 
     /**
-     *  Attempts to locate a resource under the given template.  This matches the
-     *  functionality findJSP(), but uses the WikiContext as the argument.  If there
-     *  is no servlet context (i.e. this is embedded), will just simply return
-     *  a best-guess.
+     *  Attempts to locate a resource under the given template.  This matches the functionality findJSP(), but uses the WikiContext as
+     *  the argument.  If there is no servlet context (i.e. this is embedded), will just simply return a best-guess.
      *  <p>
-     *  This method is typically used to locate any resource, including JSP pages, images,
-     *  scripts, etc.
+     *  This method is typically used to locate any resource, including JSP pages, images, scripts, etc.
      *
      *  @since 2.6
      *  @param ctx the wiki context
@@ -304,10 +266,8 @@ public class TemplateManager extends ModuleManager {
      *  @param name the name of the resource to fine
      *  @return the path to the resource
      */
-    public String findResource( WikiContext ctx, String template, String name )
-    {
-        if( m_engine.getServletContext() != null )
-        {
+    public String findResource( final WikiContext ctx, final String template, final String name ) {
+        if( m_engine.getServletContext() != null ) {
             return findResource( m_engine.getServletContext(), template, name );
         }
 
@@ -315,8 +275,7 @@ public class TemplateManager extends ModuleManager {
     }
 
     /**
-     *  Returns a property, as defined in the template.  The evaluation
-     *  is lazy, i.e. the properties are not loaded until the template is
+     *  Returns a property, as defined in the template.  The evaluation is lazy, i.e. the properties are not loaded until the template is
      *  actually used for the first time.
      */
     /*
@@ -356,16 +315,13 @@ public class TemplateManager extends ModuleManager {
     /**
      *  Returns an absolute path to a given template.
      */
-    private static String getPath( String template )
-    {
-        return "/"+DIRECTORY+"/"+template+"/";
+    private static String getPath( final String template ) {
+        return "/" + DIRECTORY + "/" + template + "/";
     }
 
     /**
-     *   Lists the skins available under this template.  Returns an
-     *   empty Set, if there are no extra skins available.  Note that
-     *   this method does not check whether there is anything actually
-     *   in the directories, it just lists them.  This may change
+     *   Lists the skins available under this template.  Returns an empty Set, if there are no extra skins available.  Note that
+     *   this method does not check whether there is anything actually in the directories, it just lists them.  This may change
      *   in the future.
      *
      *   @param pageContext the JSP PageContext
@@ -373,33 +329,26 @@ public class TemplateManager extends ModuleManager {
      *   @return Set of Strings with the skin names.
      *   @since 2.3.26
      */
-    public Set< String > listSkins( PageContext pageContext, String template )
-    {
-        String place = makeFullJSPName( template, SKIN_DIRECTORY );
-
-        ServletContext sContext = pageContext.getServletContext();
-
-        Set<String> skinSet = sContext.getResourcePaths( place );
-        TreeSet<String> resultSet = new TreeSet<>();
-
-        if( log.isDebugEnabled() ) log.debug( "Listings skins from "+place );
-
-        if( skinSet != null )
-        {
-            String[] skins = {};
-
-            skins = skinSet.toArray(skins);
-
-            for (int i = 0; i < skins.length; i++)
-            {
-                String[] s = StringUtils.split(skins[i], "/");
+    public Set< String > listSkins( final PageContext pageContext, final String template ) {
+        final String place = makeFullJSPName( template, SKIN_DIRECTORY );
+        final ServletContext sContext = pageContext.getServletContext();
+        final Set< String > skinSet = sContext.getResourcePaths( place );
+        final Set< String > resultSet = new TreeSet<>();
+
+        if( log.isDebugEnabled() ) {
+            log.debug( "Listings skins from " + place );
+        }
 
-                if (s.length > 2 && skins[i].endsWith("/"))
-                {
-                    String skinName = s[s.length - 1];
-                    resultSet.add(skinName);
-                    if (log.isDebugEnabled())
-                        log.debug("...adding skin '" + skinName + "'");
+        if( skinSet != null ) {
+            final String[] skins = skinSet.toArray( new String[]{} );
+            for( final String skin : skins ) {
+                final String[] s = StringUtils.split( skin, "/" );
+                if( s.length > 2 && skin.endsWith( "/" ) ) {
+                    final String skinName = s[ s.length - 1 ];
+                    resultSet.add( skinName );
+                    if( log.isDebugEnabled() ) {
+                        log.debug( "...adding skin '" + skinName + "'" );
+                    }
                 }
             }
         }
@@ -416,28 +365,23 @@ public class TemplateManager extends ModuleManager {
      * @return map of installed Languages
      * @since 2.7.x
      */
-    public Map< String, String > listLanguages(PageContext pageContext)
-    {
-        Map< String, String > resultMap = new LinkedHashMap<>();
-        String clientLanguage = ((HttpServletRequest) pageContext.getRequest()).getLocale().toString();
-
-        List< String > entries = ClassUtil.classpathEntriesUnder( DIRECTORY );
+    public Map< String, String > listLanguages( final PageContext pageContext ) {
+        final Map< String, String > resultMap = new LinkedHashMap<>();
+        final String clientLanguage = pageContext.getRequest().getLocale().toString();
+        final List< String > entries = ClassUtil.classpathEntriesUnder( DIRECTORY );
         for( String name : entries ) {
-            if ( name.equals( I18NRESOURCE_EN ) ||
-                    (name.startsWith( I18NRESOURCE_PREFIX ) && name.endsWith( I18NRESOURCE_SUFFIX ) ) )
-            {
-                if (name.equals( I18NRESOURCE_EN )) {
+            if ( name.equals( I18NRESOURCE_EN ) || (name.startsWith( I18NRESOURCE_PREFIX ) && name.endsWith( I18NRESOURCE_SUFFIX ) ) ) {
+                if( name.equals( I18NRESOURCE_EN ) ) {
                     name = I18NRESOURCE_EN_ID;
-                }    else {
-                    name = name.substring(I18NRESOURCE_PREFIX.length(), name.lastIndexOf(I18NRESOURCE_SUFFIX));
+                } else {
+                    name = name.substring( I18NRESOURCE_PREFIX.length(), name.lastIndexOf( I18NRESOURCE_SUFFIX ) );
                 }
-                Locale locale = new Locale(name.substring(0, 2), ((name.indexOf("_") == -1) ? "" : name.substring(3, 5)));
+                final Locale locale = new Locale( name.substring( 0, 2 ), ( ( name.indexOf( "_" ) == -1 ) ? "" : name.substring( 3, 5 ) ) );
                 String defaultLanguage = "";
-                if (clientLanguage.startsWith(name))
-                {
-                    defaultLanguage = LocaleSupport.getLocalizedMessage(pageContext, I18NDEFAULT_LOCALE);
+                if( clientLanguage.startsWith( name ) ) {
+                    defaultLanguage = LocaleSupport.getLocalizedMessage( pageContext, I18NDEFAULT_LOCALE );
                 }
-                resultMap.put(name, locale.getDisplayName(locale) + " " + defaultLanguage);
+                resultMap.put( name, locale.getDisplayName( locale ) + " " + defaultLanguage );
             }
         }
 
@@ -452,40 +396,36 @@ public class TemplateManager extends ModuleManager {
      * @return map of TimeFormats
      * @since 2.7.x
      */
-    public Map< String, String > listTimeFormats(PageContext pageContext)
-    {
-        WikiContext context = WikiContext.findContext( pageContext );
-        Properties props = m_engine.getWikiProperties();
-        ArrayList<String> tfArr = new ArrayList<>(40);
-        LinkedHashMap<String,String> resultMap = new LinkedHashMap<>();
+    public Map< String, String > listTimeFormats( final PageContext pageContext ) {
+        final WikiContext context = WikiContext.findContext( pageContext );
+        final Properties props = m_engine.getWikiProperties();
+        final ArrayList< String > tfArr = new ArrayList<>(40);
+        final LinkedHashMap< String, String > resultMap = new LinkedHashMap<>();
 
         /* filter timeformat properties */
-        for (Enumeration< ? > e = props.propertyNames(); e.hasMoreElements();)
-        {
-            String name = (String) e.nextElement();
-
-            if (name.startsWith(TIMEFORMATPROPERTIES))
-            {
-                tfArr.add(name);
+        for( final Enumeration< ? > e = props.propertyNames(); e.hasMoreElements(); ) {
+            final String name = ( String )e.nextElement();
+            if( name.startsWith( TIMEFORMATPROPERTIES ) ) {
+                tfArr.add( name );
             }
         }
 
         /* fetch actual formats */
-        if (tfArr.size() == 0)  {/* no props found - make sure some default formats are avail */
-            tfArr.add("dd-MMM-yy");
-            tfArr.add("d-MMM-yyyy");
-            tfArr.add("EEE, dd-MMM-yyyy, zzzz");
+        if( tfArr.size() == 0 )  {/* no props found - make sure some default formats are avail */
+            tfArr.add( "dd-MMM-yy" );
+            tfArr.add( "d-MMM-yyyy" );
+            tfArr.add( "EEE, dd-MMM-yyyy, zzzz" );
         } else {
-            Collections.sort(tfArr);
+            Collections.sort( tfArr );
 
             for (int i = 0; i < tfArr.size(); i++) {
                 tfArr.set(i, props.getProperty(tfArr.get(i)));
             }
         }
 
-        String prefTimeZone = Preferences.getPreference( context, "TimeZone" );
+        final String prefTimeZone = Preferences.getPreference( context, "TimeZone" );
         //TimeZone tz = TimeZone.getDefault();
-        TimeZone tz = TimeZone.getTimeZone(prefTimeZone);
+        final TimeZone tz = TimeZone.getTimeZone(prefTimeZone);
         /*try
         {
             tz.setRawOffset(Integer.parseInt(prefTimeZone));
@@ -494,30 +434,21 @@ public class TemplateManager extends ModuleManager {
         {
         }*/
 
-        Date d = new Date(); // current date
-        try
-        {
+        final Date d = new Date(); // current date
+        try {
             // dummy format pattern
-            SimpleDateFormat fmt = Preferences.getDateFormat( context, TimeFormat.DATETIME );
-            fmt.setTimeZone(tz);
-
-            for (int i = 0; i < tfArr.size(); i++)
-            {
-                try
-                {
-                    String f = tfArr.get(i);
-                    fmt.applyPattern(f);
-
-                    resultMap.put(f, fmt.format(d));
-                }
-                catch (IllegalArgumentException e)
-                {
-                } // skip parameter
+            final SimpleDateFormat fmt = Preferences.getDateFormat( context, TimeFormat.DATETIME );
+            fmt.setTimeZone( tz );
+
+            for( int i = 0; i < tfArr.size(); i++ ) {
+                try {
+                    final String f = tfArr.get( i );
+                    fmt.applyPattern( f );
+                    resultMap.put( f, fmt.format( d ) );
+                } catch( final IllegalArgumentException e ) {} // skip parameter
             }
         }
-        catch (IllegalArgumentException e)
-        {
-        } // skip parameter
+        catch( final IllegalArgumentException e ) {} // skip parameter
 
         return resultMap;
     }
@@ -529,11 +460,10 @@ public class TemplateManager extends ModuleManager {
      * @return map of TimeZones
      * @since 2.7.x
      */
-    public Map< String, String > listTimeZones(PageContext pageContext)
-    {
-        Map<String,String> resultMap = new LinkedHashMap<>();
-
-        String[][] tzs = { { "GMT-12", "Enitwetok, Kwajalien" },
+    public Map< String, String > listTimeZones( final PageContext pageContext ) {
+        final Map<String,String> resultMap = new LinkedHashMap<>();
+        final String[][] tzs = {
+                          { "GMT-12", "Enitwetok, Kwajalien" },
                           { "GMT-11", "Nome, Midway Island, Samoa" },
                           { "GMT-10", "Hawaii" },
                           { "GMT-9", "Alaska" },
@@ -564,22 +494,17 @@ public class TemplateManager extends ModuleManager {
                           { "GMT+11", "Magadan, New Caledonia, Solomon Islands" },
                           { "GMT+12", "Auckland, Wellington, Fiji, Marshall Island" } };
 
-        java.util.TimeZone servertz = java.util.TimeZone.getDefault();
-
-        for( int i = 0; i < tzs.length; i++ )
-        {
-            String tzID = tzs[i][0];
-            java.util.TimeZone tz = java.util.TimeZone.getTimeZone(tzID);
-
+        final TimeZone servertz = TimeZone.getDefault();
+        for( final String[] strings : tzs ) {
+            String tzID = strings[ 0 ];
+            final TimeZone tz = TimeZone.getTimeZone( tzID );
             String serverTimeZone = "";
-
-            if( servertz.getRawOffset() == tz.getRawOffset() )
-            {
-                serverTimeZone = LocaleSupport.getLocalizedMessage(pageContext, I18NSERVER_TIMEZONE);
+            if( servertz.getRawOffset() == tz.getRawOffset() ) {
+                serverTimeZone = LocaleSupport.getLocalizedMessage( pageContext, I18NSERVER_TIMEZONE );
                 tzID = servertz.getID();
             }
 
-            resultMap.put(tzID, "(" + tzs[i][0] + ") "+tzs[i][1] + " " + serverTimeZone);
+            resultMap.put( tzID, "(" + strings[ 0 ] + ") " + strings[ 1 ] + " " + serverTimeZone );
         }
 
         return resultMap;
@@ -620,49 +545,34 @@ public class TemplateManager extends ModuleManager {
      *  @param type the marker
      *  @return the generated marker comment
      */
-    public static String getMarker(WikiContext context, String type )
-    {
-        if( type.equals(RESOURCE_JSLOCALIZEDSTRINGS) )
-        {
+    public static String getMarker( final WikiContext context, final String type ) {
+        if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) ) {
             return getJSLocalizedStrings( context );
-        }
-        else if( type.equals(RESOURCE_JSFUNCTION) )
-        {
+        } else if( type.equals( RESOURCE_JSFUNCTION ) ) {
             return "/* INCLUDERESOURCES ("+type+") */";
         }
         return "<!-- INCLUDERESOURCES ("+type+") -->";
     }
 
     /**
-     *  Extract all i18n strings in the javascript domain. (javascript.*)
-     *  Returns a javascript snippet which defines the LocalizedStings array.
+     *  Extract all i18n strings in the javascript domain. (javascript.*) Returns a javascript snippet which defines the LocalizedStings array.
      *
      *  @param context the {@link WikiContext}
      *  @return Javascript snippet which defines the LocalizedStrings array
      *  @since 2.5.108
      */
-    private static String getJSLocalizedStrings( WikiContext context )
-    {
-    	StringBuilder sb = new StringBuilder();
-
+    private static String getJSLocalizedStrings( final WikiContext context ) {
+        final StringBuilder sb = new StringBuilder();
         sb.append( "var LocalizedStrings = {\n");
-
-        ResourceBundle rb = Preferences.getBundle( context, InternationalizationManager.DEF_TEMPLATE );
-
+        final ResourceBundle rb = Preferences.getBundle( context, InternationalizationManager.DEF_TEMPLATE );
         boolean first = true;
 
-        for( Enumeration< String > en = rb.getKeys(); en.hasMoreElements(); )
-        {
-            String key = en.nextElement();
-
-            if( key.startsWith("javascript") )
-            {
-                if( first )
-                {
+        for( final Enumeration< String > en = rb.getKeys(); en.hasMoreElements(); ) {
+            final String key = en.nextElement();
+            if( key.startsWith("javascript") ) {
+                if( first ) {
                     first = false;
-                }
-                else
-                {
+                } else {
                     sb.append( ",\n" );
                 }
                 sb.append( "\""+key+"\":\""+rb.getString(key)+"\"" );
@@ -674,103 +584,84 @@ public class TemplateManager extends ModuleManager {
     }
 
     /**
-     *  Adds a resource request to the current request context.
-     *  The content will be added at the resource-type marker
+     *  Adds a resource request to the current request context. The content will be added at the resource-type marker
      *  (see IncludeResourcesTag) in WikiJSPFilter.
      *  <p>
-     *  The resources can be of different types.  For RESOURCE_SCRIPT and RESOURCE_STYLESHEET
-     *  this is an URI path to the resource (a script file or an external stylesheet)
-     *  that needs to be included.  For RESOURCE_INLINECSS
-     *  the resource should be something that can be added between &lt;style>&lt;/style> in the
-     *  header file (commonheader.jsp).  For RESOURCE_JSFUNCTION it is the name of the Javascript
-     *  function that should be run at page load.
+     *  The resources can be of different types.  For RESOURCE_SCRIPT and RESOURCE_STYLESHEET this is an URI path to the resource
+     *  (a script file or an external stylesheet) that needs to be included.  For RESOURCE_INLINECSS the resource should be something
+     *  that can be added between &lt;style>&lt;/style> in the header file (commonheader.jsp).  For RESOURCE_JSFUNCTION it is the name
+     *  of the Javascript function that should be run at page load.
      *  <p>
-     *  The IncludeResourceTag inserts code in the template files, which is then filled
-     *  by the WikiFilter after the request has been rendered but not yet sent to the recipient.
+     *  The IncludeResourceTag inserts code in the template files, which is then filled by the WikiFilter after the request has been
+     *  rendered but not yet sent to the recipient.
      *  <p>
-     *  Note that ALL resource requests get rendered, so this method does not check if
-     *  the request already exists in the resources.  Therefore, if you have a plugin which
-     *  makes a new resource request every time, you'll end up with multiple resource requests
-     *  rendered.  It's thus a good idea to make this request only once during the page
-     *  life cycle.
+     *  Note that ALL resource requests get rendered, so this method does not check if the request already exists in the resources.
+     *  Therefore, if you have a plugin which makes a new resource request every time, you'll end up with multiple resource requests
+     *  rendered.  It's thus a good idea to make this request only once during the page life cycle.
      *
      *  @param ctx The current wiki context
      *  @param type What kind of a request should be added?
      *  @param resource The resource to add.
      */
     @SuppressWarnings("unchecked")
-    public static void addResourceRequest( WikiContext ctx, String type, String resource )
-    {
-        HashMap<String,Vector<String>> resourcemap = (HashMap<String,Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
-
-        if( resourcemap == null )
-        {
+    public static void addResourceRequest( final WikiContext ctx, final String type, final String resource ) {
+        HashMap< String, Vector< String > > resourcemap = ( HashMap< String, Vector< String > > ) ctx.getVariable( RESOURCE_INCLUDES );
+        if( resourcemap == null ) {
             resourcemap = new HashMap<>();
         }
 
-        Vector<String> resources = resourcemap.get( type );
-
-        if( resources == null )
-        {
+        Vector< String > resources = resourcemap.get( type );
+        if( resources == null ) {
             resources = new Vector<>();
         }
 
         String resourceString = null;
-
-        if( type.equals(RESOURCE_SCRIPT) )
-        {
-            resourceString = "<script type='text/javascript' src='"+resource+"'></script>";
-        }
-        else if( type.equals(RESOURCE_STYLESHEET) )
-        {
-            resourceString = "<link rel='stylesheet' type='text/css' href='"+resource+"' />";
-        }
-        else if( type.equals(RESOURCE_INLINECSS) )
-        {
-            resourceString = "<style type='text/css'>\n"+resource+"\n</style>\n";
-        }
-        else if( type.equals(RESOURCE_JSFUNCTION) )
-        {
-            resourceString = resource;
-        }
-        else if( type.equals(RESOURCE_HTTPHEADER) )
-        {
+        switch( type ) {
+        case RESOURCE_SCRIPT:
+            resourceString = "<script type='text/javascript' src='" + resource + "'></script>";
+            break;
+        case RESOURCE_STYLESHEET:
+            resourceString = "<link rel='stylesheet' type='text/css' href='" + resource + "' />";
+            break;
+        case RESOURCE_INLINECSS:
+            resourceString = "<style type='text/css'>\n" + resource + "\n</style>\n";
+            break;
+        case RESOURCE_JSFUNCTION:
+        case RESOURCE_HTTPHEADER:
             resourceString = resource;
+            break;
         }
 
-        if( resourceString != null )
-        {
+        if( resourceString != null ) {
             resources.add( resourceString );
         }
 
-        log.debug("Request to add a resource: "+resourceString);
+        log.debug( "Request to add a resource: " + resourceString );
 
         resourcemap.put( type, resources );
         ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
     }
 
     /**
-     *  Returns resource requests for a particular type.  If there are no resources,
-     *  returns an empty array.
+     *  Returns resource requests for a particular type.  If there are no resources, returns an empty array.
      *
      *  @param ctx WikiContext
      *  @param type The resource request type
      *  @return a String array for the resource requests
      */
-
     @SuppressWarnings("unchecked")
-    public static String[] getResourceRequests( WikiContext ctx, String type )
-    {
-        HashMap<String,Vector<String>> hm = (HashMap<String,Vector<String>>) ctx.getVariable( RESOURCE_INCLUDES );
-
-        if( hm == null ) return new String[0];
-
-        Vector<String> resources = hm.get( type );
-
-        if( resources == null ) return new String[0];
+    public static String[] getResourceRequests( final WikiContext ctx, final String type ) {
+        final HashMap< String, Vector< String > > hm = ( HashMap< String, Vector< String > > ) ctx.getVariable( RESOURCE_INCLUDES );
+        if( hm == null ) {
+            return new String[0];
+        }
 
-        String[] res = new String[resources.size()];
+        final Vector<String> resources = hm.get( type );
+        if( resources == null ){
+            return new String[0];
+        }
 
+        final String[] res = new String[resources.size()];
         return resources.toArray( res );
     }
 
@@ -781,18 +672,12 @@ public class TemplateManager extends ModuleManager {
      * @return the array of types requested
      */
     @SuppressWarnings("unchecked")
-    public static String[] getResourceTypes( WikiContext ctx )
-    {
+    public static String[] getResourceTypes( final WikiContext ctx ) {
         String[] res = new String[0];
-
-        if( ctx != null )
-        {
-            HashMap<String,String> hm = (HashMap<String,String>) ctx.getVariable( RESOURCE_INCLUDES );
-
-            if( hm != null )
-            {
-                Set<String> keys = hm.keySet();
-
+        if( ctx != null ) {
+            final HashMap< String, String > hm = ( HashMap< String, String > ) ctx.getVariable( RESOURCE_INCLUDES );
+            if( hm != null ) {
+                final Set< String > keys = hm.keySet();
                 res = keys.toArray( res );
             }
         }
@@ -801,14 +686,12 @@ public class TemplateManager extends ModuleManager {
     }
 
     /**
-     *  Returns an empty collection, since at the moment the TemplateManager
-     *  does not manage any modules.
+     *  Returns an empty collection, since at the moment the TemplateManager does not manage any modules.
      *
      *  @return {@inheritDoc}
      */
     @Override
-    public Collection< WikiModuleInfo > modules()
-    {
+    public Collection< WikiModuleInfo > modules() {
         return new ArrayList<>();
     }
 
@@ -817,7 +700,8 @@ public class TemplateManager extends ModuleManager {
      *  {@inheritDoc}
      */
     @Override
-    public WikiModuleInfo getModuleInfo(String moduleName) {
+    public WikiModuleInfo getModuleInfo( final String moduleName ) {
     	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 84fc2f1..1f22b44 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,23 +18,19 @@
  */
 package org.apache.wiki.ui;
 
-import java.security.Permission;
-
 import org.apache.wiki.auth.permissions.AllPermission;
 import org.apache.wiki.auth.permissions.WikiPermission;
 
+import java.security.Permission;
+
 /**
- * <p>Defines Commands for wiki-wide operations such as creating groups, editing
- * preferences and profiles, and logging in/out. WikiCommands can be combined 
- * with Strings (representing the name of a wiki instance) to produce
- * targeted Commands.</p>
- * <p>This class is not <code>final</code>; it may be extended in
- * the future.</p>
+ * <p>Defines Commands for wiki-wide operations such as creating groups, editing preferences and profiles, and logging in/out.
+ * WikiCommands can be combined with Strings (representing the name of a wiki instance) to produce targeted Commands.</p>
+ *
  * @see org.apache.wiki.WikiEngine#getApplicationName()
  * @since 2.4.22
  */
-public final class WikiCommand extends AbstractCommand
-{
+public final class WikiCommand extends AbstractCommand {
 
     public static final Command CREATE_GROUP
         = new WikiCommand( "createGroup", "%uNewGroup.jsp", "NewGroupContent.jsp", null, WikiPermission.CREATE_GROUPS_ACTION );
@@ -71,31 +67,25 @@ public final class WikiCommand extends AbstractCommand
     private final Permission m_permission;
     
     /**
-     * Constructs a new Command with a specified wiki context, URL pattern,
-     * type, and content template. The WikiPage for this action is initialized
-     * to <code>null</code>.
+     * Constructs a new Command with a specified wiki context, URL pattern, type, and content template. The WikiPage for this action is
+     * initialized to <code>null</code>.
+     *
      * @param requestContext the request context
      * @param urlPattern the URL pattern
-     * @param type the type
      * @param contentTemplate the content template; may be <code>null</code>
      * @param action The action
-     * @throws IllegalArgumentException if the request content, URL pattern, or
-     *         type is <code>null</code>
+     * @throws IllegalArgumentException if the request content, URL pattern, or type is <code>null</code>
      */
-    private WikiCommand( String requestContext, 
-                         String urlPattern, 
-                         String contentTemplate, 
-                         String target, 
-                         String action )
-    {
+    private WikiCommand( final String requestContext,
+                         final String urlPattern,
+                         final String contentTemplate,
+                         final String target,
+                         final String action ) {
         super( requestContext, urlPattern, contentTemplate, target );
         m_action = action;
-        if ( target == null || m_action == null )
-        {
+        if ( target == null || m_action == null ) {
             m_permission = null;
-        }
-        else
-        {
+        } else {
             m_permission = new WikiPermission( target, action );
         }
     }
@@ -107,28 +97,22 @@ public final class WikiCommand extends AbstractCommand
      *  @param urlPattern
      *  @param contentTemplate
      */
-    private WikiCommand( String requestContext, 
-                         String urlPattern, 
-                         String contentTemplate,
-                         String target )
-    {
+    private WikiCommand( final String requestContext, final String urlPattern, final String contentTemplate, final String target ) {
         super( requestContext, urlPattern, contentTemplate, target );
         m_action = null;
-
         m_permission = new AllPermission( target );
     }
+
     /**
-     * Creates and returns a targeted Command by combining a wiki
-     * (a String) with this Command. The supplied <code>target</code>
+     * Creates and returns a targeted Command by combining a wiki (a String) with this Command. The supplied <code>target</code>
      * object must be non-<code>null</code> and of type String.
+     *
      * @param target the name of the wiki to combine into the current Command
      * @return the new targeted command
      * @throws IllegalArgumentException if the target is not of the correct type
      */
-    public Command targetedCommand( Object target )
-    {
-        if ( !( target != null && target instanceof String ) )
-        {
+    public Command targetedCommand( final Object target ) {
+        if ( !( target instanceof String ) ) {
             throw new IllegalArgumentException( "Target must non-null and of type String." );
         }
         return new WikiCommand( getRequestContext(), getURLPattern(), getContentTemplate(), (String)target, m_action );
@@ -136,18 +120,18 @@ public final class WikiCommand extends AbstractCommand
     
     /**
      * Always returns the "friendly" JSP name.
+     *
      * @see org.apache.wiki.ui.Command#getName()
      */
-    public String getName()
-    {
+    public String getName() {
         return getJSPFriendlyName();
     }
 
     /**
      * @see org.apache.wiki.ui.Command#requiredPermission()
      */
-    public Permission requiredPermission()
-    {
+    public Permission requiredPermission() {
         return m_permission;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
index 7dee58c..d7d1fe2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
@@ -48,23 +48,17 @@ import java.nio.charset.Charset;
 
 
 /**
- * This filter goes through the generated page response prior and
- * places requested resources at the appropriate inclusion markers.
- * This is done to let dynamic content (e.g. plugins, editors)
- * include custom resources, even after the HTML head section is
- * in fact built. This filter is typically the last filter to execute,
- * and it <em>must</em> run after servlet or JSP code that performs
+ * This filter goes through the generated page response prior and places requested resources at the appropriate inclusion markers.
+ * This is done to let dynamic content (e.g. plugins, editors) include custom resources, even after the HTML head section is
+ * in fact built. This filter is typically the last filter to execute, and it <em>must</em> run after servlet or JSP code that performs
  * redirections or sends error codes (such as access control methods).
  * <p>
- * Inclusion markers are placed by the IncludeResourcesTag; the
- * default content templates (see .../templates/default/commonheader.jsp)
- * are configured to do this. As an example, a JavaScript resource marker
- * is added like this:
+ * Inclusion markers are placed by the IncludeResourcesTag; the default content templates (see .../templates/default/commonheader.jsp)
+ * are configured to do this. As an example, a JavaScript resource marker is added like this:
  * <pre>
  * &lt;wiki:IncludeResources type="script"/&gt;
  * </pre>
- * Any code that requires special resources must register a resource
- * request with the TemplateManager. For example:
+ * Any code that requires special resources must register a resource request with the TemplateManager. For example:
  * <pre>
  * &lt;wiki:RequestResource type="script" path="scripts/custom.js" /&gt;
  * </pre>
@@ -83,32 +77,24 @@ public class WikiJSPFilter extends WikiServletFilter {
     private boolean useEncoding;
 
     /** {@inheritDoc} */
-    public void init( FilterConfig config ) throws ServletException
-    {
+    public void init( final FilterConfig config ) throws ServletException {
         super.init( config );
         m_wiki_encoding = m_engine.getWikiProperties().getProperty(WikiEngine.PROP_ENCODING);
 
-        useEncoding = !(new Boolean(m_engine.getWikiProperties().getProperty(WikiEngine.PROP_NO_FILTER_ENCODING, "false").trim()).booleanValue());
+        useEncoding = !( Boolean.valueOf( m_engine.getWikiProperties().getProperty( WikiEngine.PROP_NO_FILTER_ENCODING, "false" ).trim() ).booleanValue() );
     }
 
-    public void doFilter( ServletRequest  request, ServletResponse response, FilterChain chain )
-        throws ServletException, IOException
-    {
-        WatchDog w = m_engine.getCurrentWatchDog();
-        try
-        {
+    public void doFilter( final ServletRequest  request, final ServletResponse response, final FilterChain chain ) throws ServletException, IOException {
+        final WatchDog w = m_engine.getCurrentWatchDog();
+        try {
             NDC.push( m_engine.getApplicationName()+":"+((HttpServletRequest)request).getRequestURI() );
-
             w.enterState("Filtering for URL "+((HttpServletRequest)request).getRequestURI(), 90 );
-            HttpServletResponseWrapper responseWrapper;
-
-            responseWrapper = new JSPWikiServletResponseWrapper( (HttpServletResponse)response, m_wiki_encoding, useEncoding);
+            final HttpServletResponseWrapper responseWrapper = new JSPWikiServletResponseWrapper( ( HttpServletResponse )response, m_wiki_encoding, useEncoding );
 
             // fire PAGE_REQUESTED event
-            String pagename = DefaultURLConstructor.parsePageFromURL( ( HttpServletRequest )request,
-                                                                      Charset.forName( response.getCharacterEncoding() ) );
+            final String pagename = DefaultURLConstructor.parsePageFromURL( ( HttpServletRequest )request,
+                                                                            Charset.forName( response.getCharacterEncoding() ) );
             fireEvent( WikiPageEvent.PAGE_REQUESTED, pagename );
-
             super.doFilter( request, responseWrapper, chain );
 
             // The response is now complete. Lets replace the markers now.
@@ -116,42 +102,32 @@ public class WikiJSPFilter extends WikiServletFilter {
             // WikiContext is only available after doFilter! (That is after
             //   interpreting the jsp)
 
-            try
-            {
+            try {
                 w.enterState( "Delivering response", 30 );
-                WikiContext wikiContext = getWikiContext( request );
-                String r = filter( wikiContext, responseWrapper );
-
-                if (useEncoding)
-                {
-                    OutputStreamWriter out = new OutputStreamWriter(response.getOutputStream(),
-                                                                    response.getCharacterEncoding());
-                    out.write(r);
+                final WikiContext wikiContext = getWikiContext( request );
+                final String r = filter( wikiContext, responseWrapper );
+
+                if( useEncoding ) {
+                    final OutputStreamWriter out = new OutputStreamWriter( response.getOutputStream(), response.getCharacterEncoding() );
+                    out.write( r );
                     out.flush();
                     out.close();
-                }
-                else
-                {
+                } else {
                     response.getWriter().write(r);
                 }
 
                 // Clean up the UI messages and loggers
-                if( wikiContext != null )
-                {
+                if( wikiContext != null ) {
                     wikiContext.getWikiSession().clearMessages();
                 }
 
                 // fire PAGE_DELIVERED event
                 fireEvent( WikiPageEvent.PAGE_DELIVERED, pagename );
 
-            }
-            finally
-            {
+            } finally {
                 w.exitState();
             }
-        }
-        finally
-        {
+        } finally {
             w.exitState();
             NDC.pop();
             NDC.remove();
@@ -165,34 +141,25 @@ public class WikiJSPFilter extends WikiServletFilter {
      * @param response The source string
      * @return The modified string with all the insertions in place.
      */
-    private String filter(WikiContext wikiContext, HttpServletResponse response )
-    {
+    private String filter( final WikiContext wikiContext, final HttpServletResponse response ) {
         String string = response.toString();
 
-        if( wikiContext != null )
-        {
-            String[] resourceTypes = TemplateManager.getResourceTypes( wikiContext );
-
-            for( int i = 0; i < resourceTypes.length; i++ )
-            {
-                string = insertResources( wikiContext, string, resourceTypes[i] );
+        if( wikiContext != null ) {
+            final String[] resourceTypes = TemplateManager.getResourceTypes( wikiContext );
+            for( final String resourceType : resourceTypes ) {
+                string = insertResources( wikiContext, string, resourceType );
             }
 
-            //
             //  Add HTTP header Resource Requests
-            //
-            String[] headers = TemplateManager.getResourceRequests( wikiContext,
-                                                                    TemplateManager.RESOURCE_HTTPHEADER );
+            final String[] headers = TemplateManager.getResourceRequests( wikiContext, TemplateManager.RESOURCE_HTTPHEADER );
 
-            for( int i = 0; i < headers.length; i++ )
-            {
-                String key = headers[i];
+            for( final String header : headers ) {
+                String key = header;
                 String value = "";
-                int split = headers[i].indexOf(':');
-                if( split > 0 && split < headers[i].length()-1 )
-                {
-                    key = headers[i].substring( 0, split );
-                    value = headers[i].substring( split+1 );
+                final int split = header.indexOf( ':' );
+                if( split > 0 && split < header.length() - 1 ) {
+                    key = header.substring( 0, split );
+                    value = header.substring( split + 1 );
                 }
 
                 response.addHeader( key.trim(), value.trim() );
@@ -203,48 +170,35 @@ public class WikiJSPFilter extends WikiServletFilter {
     }
 
     /**
-     *  Inserts whatever resources
-     *  were requested by any plugins or other components for this particular
-     *  type.
+     *  Inserts whatever resources were requested by any plugins or other components for this particular type.
      *
      *  @param wikiContext The usual processing context
      *  @param string The source string
      *  @param type Type identifier for insertion
      *  @return The filtered string.
      */
-    private String insertResources(WikiContext wikiContext, String string, String type )
-    {
-        if( wikiContext == null )
-        {
+    private String insertResources( final WikiContext wikiContext, final String string, final String type ) {
+        if( wikiContext == null ) {
             return string;
         }
 
-        String marker = TemplateManager.getMarker( wikiContext, type );
-        int idx = string.indexOf( marker );
-
-        if( idx == -1 )
-        {
+        final String marker = TemplateManager.getMarker( wikiContext, type );
+        final int idx = string.indexOf( marker );
+        if( idx == -1 ) {
             return string;
         }
 
         log.debug("...Inserting...");
 
-        String[] resources = TemplateManager.getResourceRequests( wikiContext, type );
+        final String[] resources = TemplateManager.getResourceRequests( wikiContext, type );
+        final StringBuilder concat = new StringBuilder( resources.length * 40 );
 
-        StringBuilder concat = new StringBuilder( resources.length * 40 );
-
-        for( int i = 0; i < resources.length; i++  )
-        {
-            log.debug("...:::"+resources[i]);
-            concat.append( resources[i] );
+        for( final String resource : resources ) {
+            log.debug( "...:::" + resource );
+            concat.append( resource );
         }
 
-        string = TextUtil.replaceString( string,
-                                         idx,
-                                         idx+marker.length(),
-                                         concat.toString() );
-
-        return string;
+        return TextUtil.replaceString( string, idx, idx + marker.length(), concat.toString() );
     }
 
     /**
@@ -259,108 +213,89 @@ public class WikiJSPFilter extends WikiServletFilter {
         private HttpServletResponse m_response;
         private boolean useEncoding;
 
-        /**
-         *  How large the initial buffer should be.  This should be tuned to achieve
-         *  a balance in speed and memory consumption.
-         */
+        /** How large the initial buffer should be.  This should be tuned to achieve a balance in speed and memory consumption. */
         private static final int INIT_BUFFER_SIZE = 0x8000;
 
-
-        public JSPWikiServletResponseWrapper( HttpServletResponse r, final String wiki_encoding, boolean useEncoding)
-                throws UnsupportedEncodingException {
-            super(r);
-            m_output = new ByteArrayOutputStream(INIT_BUFFER_SIZE);
-            m_servletOut = new ByteArrayServletOutputStream(m_output);
-            m_writer = new PrintWriter(new OutputStreamWriter(m_servletOut, wiki_encoding), true);
+        public JSPWikiServletResponseWrapper( final HttpServletResponse r, final String wikiEncoding, final boolean useEncoding ) throws UnsupportedEncodingException {
+            super( r );
+            m_output = new ByteArrayOutputStream( INIT_BUFFER_SIZE );
+            m_servletOut = new ByteArrayServletOutputStream( m_output );
+            m_writer = new PrintWriter( new OutputStreamWriter( m_servletOut, wikiEncoding ), true );
             this.useEncoding = useEncoding;
 
             m_response = r;
         }
 
         /**
-         *  Returns a writer for output; this wraps the internal buffer
-         *  into a PrintWriter.
+         *  Returns a writer for output; this wraps the internal buffer into a PrintWriter.
          */
-        public PrintWriter getWriter()
-        {
+        public PrintWriter getWriter() {
             return m_writer;
         }
 
-        public ServletOutputStream getOutputStream()
-        {
+        public ServletOutputStream getOutputStream() {
             return m_servletOut;
         }
 
-        public void flushBuffer() throws IOException
-        {
+        public void flushBuffer() throws IOException {
             m_writer.flush();
             super.flushBuffer();
         }
 
-        class ByteArrayServletOutputStream extends ServletOutputStream
-        {
+        class ByteArrayServletOutputStream extends ServletOutputStream {
+
             ByteArrayOutputStream m_buffer;
 
-            public ByteArrayServletOutputStream(ByteArrayOutputStream byteArrayOutputStream)
-            {
+            public ByteArrayServletOutputStream( final ByteArrayOutputStream byteArrayOutputStream ) {
                 super();
                 m_buffer = byteArrayOutputStream;
             }
 
+            //
+            /**{@inheritDoc} */
             @Override
-            public void write(int aInt) throws IOException
-            {
+            public void write( final int aInt ) {
                 m_buffer.write( aInt );
             }
 
-			@Override
-			public boolean isReady() 
-			{
+            /**{@inheritDoc} */
+            @Override
+			public boolean isReady() {
 				return false;
 			}
 
-			@Override
-			public void setWriteListener(WriteListener writeListener) 
-			{
+            /**{@inheritDoc} */
+            @Override
+			public void setWriteListener( final WriteListener writeListener ) {
 			}
 			
         }
 
-        /**
-         *  Returns whatever was written so far into the Writer.
-         */
-        public String toString()
-        {
-            try
-			{
+        /** Returns whatever was written so far into the Writer. */
+        public String toString() {
+            try {
 				flushBuffer();
-			} catch (IOException e)
-			{
+			} catch( final IOException e ) {
                 log.error( e );
                 return StringUtils.EMPTY;
 			}
 
-            try
-			{
-				if (useEncoding)
-				{
-					return m_output.toString(m_response.getCharacterEncoding());
+            try {
+				if( useEncoding ) {
+					return m_output.toString( m_response.getCharacterEncoding() );
 				}
 
 				return m_output.toString();
-			}
-            catch( UnsupportedEncodingException e )
-            {
+			} catch( final UnsupportedEncodingException e ) {
                 log.error( e );
                 return StringUtils.EMPTY;
              }
         }
-    }
 
+    }
 
     // events processing .......................................................
 
-
     /**
      *  Fires a WikiPageEvent of the provided type and page name
      *  to all registered listeners of the current WikiEngine.
@@ -369,11 +304,9 @@ public class WikiJSPFilter extends WikiServletFilter {
      * @param type       the event type to be fired
      * @param pagename   the wiki page name as a String
      */
-    protected final void fireEvent( int type, String pagename )
-    {
-        if ( WikiEventManager.isListening(m_engine) )
-        {
-            WikiEventManager.fireEvent(m_engine,new WikiPageEvent(m_engine,type,pagename));
+    protected final void fireEvent( final int type, final String pagename ) {
+        if( WikiEventManager.isListening( m_engine ) ) {
+            WikiEventManager.fireEvent( m_engine, new WikiPageEvent( m_engine, type, pagename ) );
         }
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java
index 1d72c58..a0a9f48 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java
@@ -18,115 +18,90 @@
  */
 package org.apache.wiki.ui;
 
-import java.security.Principal;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.auth.SessionMonitor;
 import org.apache.wiki.auth.authorize.Role;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import java.security.Principal;
+
 /**
- * Servlet request wrapper that encapsulates an incoming HTTP request and
- * overrides its security methods so that the request returns JSPWiki-specific
- * values.
+ * Servlet request wrapper that encapsulates an incoming HTTP request and overrides its security methods so that the request returns
+ * JSPWiki-specific values.
  * 
  * @since 2.8
  */
-public class WikiRequestWrapper extends HttpServletRequestWrapper
-{
+public class WikiRequestWrapper extends HttpServletRequestWrapper {
+
     private final WikiSession m_session;
 
     /**
      * Constructs a new wrapped request.
      * 
-     * @param engine
-     *            the wiki engine
-     * @param request
-     *            the request to wrap
+     * @param engine the wiki engine
+     * @param request the request to wrap
      */
-    public WikiRequestWrapper(WikiEngine engine, HttpServletRequest request)
-    {
-        super(request);
+    public WikiRequestWrapper( final WikiEngine engine, final HttpServletRequest request ) {
+        super( request );
 
         // Get and stash a reference to the current WikiSession
-        m_session = SessionMonitor.getInstance(engine).find(request.getSession());
+        m_session = SessionMonitor.getInstance( engine ).find( request.getSession() );
     }
 
     /**
-     * Returns the remote user for the HTTP request, taking into account both
-     * container and JSPWiki custom authentication status. Specifically, if the
-     * wrapped request contains a remote user, this method returns that remote
-     * user. Otherwise, if the user's WikiSession is an authenticated session
-     * (that is, {@link WikiSession#isAuthenticated()} returns <code>true</code>,
-     * this method returns the name of the principal returned by
-     * {@link WikiSession#getLoginPrincipal()}.
+     * Returns the remote user for the HTTP request, taking into account both container and JSPWiki custom authentication status.
+     * Specifically, if the wrapped request contains a remote user, this method returns that remote user. Otherwise, if the user's
+     * WikiSession is an authenticated session (that is, {@link WikiSession#isAuthenticated()} returns <code>true</code>,
+     * this method returns the name of the principal returned by {@link WikiSession#getLoginPrincipal()}.
      */
-    public String getRemoteUser()
-    {
-        if (super.getRemoteUser() != null)
-        {
+    public String getRemoteUser() {
+        if( super.getRemoteUser() != null ) {
             return super.getRemoteUser();
         }
 
-        if (m_session.isAuthenticated())
-        {
+        if( m_session.isAuthenticated() ) {
             return m_session.getLoginPrincipal().getName();
         }
         return null;
     }
 
     /**
-     * Returns the user principal for the HTTP request, taking into account both
-     * container and JSPWiki custom authentication status. Specifically, if the
-     * wrapped request contains a user principal, this method returns that
-     * principal. Otherwise, if the user's WikiSession is an authenticated
-     * session (that is, {@link WikiSession#isAuthenticated()} returns
-     * <code>true</code>, this method returns the value of
-     * {@link WikiSession#getLoginPrincipal()}.
+     * Returns the user principal for the HTTP request, taking into account both container and JSPWiki custom authentication status.
+     * Specifically, if the wrapped request contains a user principal, this method returns that principal. Otherwise, if the user's
+     * WikiSession is an authenticated session (that is, {@link WikiSession#isAuthenticated()} returns
+     * <code>true</code>, this method returns the value of {@link WikiSession#getLoginPrincipal()}.
      */
-    public Principal getUserPrincipal()
-    {
-        if (super.getUserPrincipal() != null)
-        {
+    public Principal getUserPrincipal() {
+        if( super.getUserPrincipal() != null ) {
             return super.getUserPrincipal();
         }
 
-        if (m_session.isAuthenticated())
-        {
+        if( m_session.isAuthenticated() ) {
             return m_session.getLoginPrincipal();
         }
         return null;
     }
 
     /**
-     * Determines whether the current user possesses a supplied role, taking
-     * into account both container and JSPWIki custom authentication status.
-     * Specifically, if the wrapped request shows that the user possesses the
-     * role, this method returns <code>true</code>. If not, this method
-     * iterates through the built-in Role objects (<em>e.g.</em>, ANONYMOUS,
-     * ASSERTED, AUTHENTICATED) returned by {@link WikiSession#getRoles()} and
-     * checks to see if any of these principals' names match the supplied role.
+     * Determines whether the current user possesses a supplied role, taking into account both container and JSPWIki custom authentication
+     * status. Specifically, if the wrapped request shows that the user possesses the role, this method returns <code>true</code>. If not,
+     * this method iterates through the built-in Role objects (<em>e.g.</em>, ANONYMOUS, ASSERTED, AUTHENTICATED) returned by
+     * {@link WikiSession#getRoles()} and checks to see if any of these principals' names match the supplied role.
      */
-    public boolean isUserInRole(String role)
-    {
-        boolean hasContainerRole = super.isUserInRole(role);
-        if (hasContainerRole)
-        {
+    public boolean isUserInRole( final String role ) {
+        final boolean hasContainerRole = super.isUserInRole(role);
+        if( hasContainerRole ) {
             return true;
         }
 
         // Iterate through all of the built-in roles and look for a match
-        Principal[] principals = m_session.getRoles();
-        for (int i = 0; i < principals.length; i++)
-        {
-            if (principals[i] instanceof Role)
-            {
-                Role principal = (Role) principals[i];
-                if (Role.isBuiltInRole(principal) && principal.getName().equals(role))
-                {
+        final Principal[] principals = m_session.getRoles();
+        for( final Principal value : principals ) {
+            if( value instanceof Role ) {
+                final Role principal = ( Role )value;
+                if( Role.isBuiltInRole( principal ) && principal.getName().equals( role ) ) {
                     return true;
                 }
             }
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 4d8e08f..33c9454 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
@@ -154,18 +154,18 @@ 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( WikiContext.ATTR_CONTEXT );
     }
 
     /** 
      * Determines whether the request has been previously wrapped with a WikiRequestWrapper. 
      * We find the wrapper by recursively unwrapping successive request wrappers, if they have been supplied.
+     *
      * @param request the current HTTP request
-     * @return <code>true</code> if the request has previously been wrapped;
-     * <code>false</code> otherwise
+     * @return <code>true</code> if the request has previously been wrapped; <code>false</code> otherwise
      */
     private boolean isWrapped( ServletRequest request ) {
-        while( !(request instanceof WikiRequestWrapper ) && request != null && request instanceof HttpServletRequestWrapper ) {
+        while( !(request instanceof WikiRequestWrapper ) && request instanceof HttpServletRequestWrapper ) {
             request = ( ( HttpServletRequestWrapper ) request ).getRequest();
         }
         return request instanceof WikiRequestWrapper;


[jspwiki] 13/32: revisit + revert getViewURL(..) previous fix

Posted by ju...@apache.org.
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 a2c838124a7c849fd871343a44bcf2c95a2c4396
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Jan 20 21:41:58 2020 +0100

    revisit + revert getViewURL(..) previous fix
    
    - it was doing the same as WikiContext#getViewURL(..)
    - the javadoc stated that WikiEngine#getViewURL(..) should yield absolute urls as opposed to WikiContext#getViewURL which can yield relative urls too
    - instead of passing a misleading condition to the absolute parameter, now a simple true is passed
    
    also, apply consistently same brace and javadoc styling throughout the class
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 261 +++++++++------------
 1 file changed, 114 insertions(+), 147 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 4372105..e3c6dd7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -87,25 +87,23 @@ import java.util.concurrent.ConcurrentHashMap;
  *  This is the main interface through which everything should go.
  *
  *  <P>
- *  Using this class:  Always get yourself an instance from JSP page
- *  by using the WikiEngine.getInstance() method.  Never create a new
+ *  Using this class:  Always get yourself an instance from JSP page by using the WikiEngine.getInstance() method.  Never create a new
  *  WikiEngine() from scratch, unless you're writing tests.
+ *
  *  <p>
- *  There's basically only a single WikiEngine for each web application, and
- *  you should always get it using the WikiEngine.getInstance() method.
+ *  There's basically only a single WikiEngine for each web application, and you should always get it using the WikiEngine.getInstance() method.
  */
 public class WikiEngine  {
 
     private static final String ATTR_WIKIENGINE = "org.apache.wiki.WikiEngine";
-    private static final Logger log = Logger.getLogger(WikiEngine.class);
+    private static final Logger log = Logger.getLogger( WikiEngine.class );
 
     /** True, if log4j has been configured. */
-    // FIXME: If you run multiple applications, the first application
-    // to run defines where the log goes.  Not what we want.
-    private static boolean   c_configured = false;
+    // FIXME: If you run multiple applications, the first application to run defines where the log goes.  Not what we want.
+    private static boolean c_configured = false;
 
     /** Stores properties. */
-    private Properties       m_properties;
+    private Properties m_properties;
 
     /** The default inlining pattern.  Currently "*.png" */
     public static final String DEFAULT_INLINEPATTERN = "*.png";
@@ -117,7 +115,7 @@ public class WikiEngine  {
     public static final String PROP_APPNAME = "jspwiki.applicationName";
 
     /** This property defines the inline image pattern.  It's current value is {@value} */
-    public static final String PROP_INLINEIMAGEPTRN  = "jspwiki.translatorReader.inlinePattern";
+    public static final String PROP_INLINEIMAGEPTRN = "jspwiki.translatorReader.inlinePattern";
 
     /** Property start for any interwiki reference. */
     public static final String PROP_INTERWIKIREF = "jspwiki.interWikiRef.";
@@ -126,36 +124,36 @@ public class WikiEngine  {
     public static final String PROP_STOREUSERNAME= "jspwiki.storeUserName";
 
     /** Define the used encoding.  Currently supported are ISO-8859-1 and UTF-8 */
-    public static final String PROP_ENCODING     = "jspwiki.encoding";
+    public static final String PROP_ENCODING = "jspwiki.encoding";
 
     /** Do not use encoding in WikiJSPFilter, default is false for most servers.
     Double negative, cause for most servers you don't need the property */
-    public static final String PROP_NO_FILTER_ENCODING     = "jspwiki.nofilterencoding";
+    public static final String PROP_NO_FILTER_ENCODING = "jspwiki.nofilterencoding";
 
     /** The name for the property which allows you to set the current reference style.  The value is {@value}. */
-    public static final String PROP_REFSTYLE     = "jspwiki.referenceStyle";
+    public static final String PROP_REFSTYLE = "jspwiki.referenceStyle";
 
     /** Property name for where the jspwiki work directory should be.
         If not specified, reverts to ${java.tmpdir}. */
-    public static final String PROP_WORKDIR      = "jspwiki.workDir";
+    public static final String PROP_WORKDIR = "jspwiki.workDir";
 
     /** The name of the cookie that gets stored to the user browser. */
     public static final String PREFS_COOKIE_NAME = "JSPWikiUserProfile";
 
     /** Property name for the "match english plurals" -hack. */
-    public static final String PROP_MATCHPLURALS     = "jspwiki.translatorReader.matchEnglishPlurals";
+    public static final String PROP_MATCHPLURALS = "jspwiki.translatorReader.matchEnglishPlurals";
 
     /** Property name for the template that is used. */
-    public static final String PROP_TEMPLATEDIR  = "jspwiki.templateDir";
+    public static final String PROP_TEMPLATEDIR = "jspwiki.templateDir";
 
     /** Property name for the default front page. */
-    public static final String PROP_FRONTPAGE    = "jspwiki.frontPage";
+    public static final String PROP_FRONTPAGE = "jspwiki.frontPage";
 
     /** Property name for setting the url generator instance */
     public static final String PROP_URLCONSTRUCTOR = "jspwiki.urlConstructor";
 
     /** Does the work in renaming pages. */
-    private PageRenamer    m_pageRenamer = null;
+    private PageRenamer m_pageRenamer = null;
 
     /** The name of the property containing the ACLManager implementing class. The value is {@value}. */
     public static final String PROP_ACL_MANAGER_IMPL = "jspwiki.aclManager";
@@ -170,34 +168,34 @@ public class WikiEngine  {
     private boolean m_useUTF8 = true;
 
     /** Store the file path to the basic URL.  When we're not running as a servlet, it defaults to the user's current directory. */
-    private String m_rootPath = System.getProperty("user.dir");
+    private String m_rootPath = System.getProperty( "user.dir" );
 
     /** Stores references between wikipages. */
-    private ReferenceManager m_referenceManager = null;
+    private ReferenceManager  m_referenceManager = null;
 
     /** Stores the Plugin manager */
-    private PluginManager    m_pluginManager;
+    private PluginManager     m_pluginManager;
 
     /** Stores the Variable manager */
-    private VariableManager m_variableManager;
+    private VariableManager   m_variableManager;
 
     /** Stores the Attachment manager */
     private AttachmentManager m_attachmentManager = null;
 
     /** Stores the Page manager */
-    private PageManager      m_pageManager = null;
+    private PageManager       m_pageManager = null;
 
     /** Stores the authorization manager */
     private AuthorizationManager m_authorizationManager = null;
 
     /** Stores the authentication manager.*/
-    private AuthenticationManager      m_authenticationManager = null;
+    private AuthenticationManager m_authenticationManager = null;
 
     /** Stores the ACL manager. */
     private AclManager       m_aclManager = null;
 
     /** Resolves wiki actions, JSPs and special pages. */
-    private CommandResolver m_commandResolver = null;
+    private CommandResolver  m_commandResolver = null;
 
     private TemplateManager  m_templateManager = null;
 
@@ -235,8 +233,7 @@ public class WikiEngine  {
     /** The RSS file to generate. */
     private String           m_rssFile;
 
-    /** Store the ServletContext that we're in.  This may be null if WikiEngine
-        is not running inside a servlet container (i.e. when testing). */
+    /** Store the ServletContext that we're in.  This may be null if WikiEngine is not running inside a servlet container (i.e. when testing). */
     private ServletContext   m_servletContext = null;
 
     /** Stores the template path.  This is relative to "templates". */
@@ -256,7 +253,6 @@ public class WikiEngine  {
 
     private boolean          m_isConfigured = false; // Flag.
 
-
     /** Each engine has its own workflow manager. */
     private WorkflowManager m_workflowMgr = null;
 
@@ -266,30 +262,26 @@ public class WikiEngine  {
     private Map<String,Object> m_attributes = new ConcurrentHashMap<>();
 
     /**
-     *  Gets a WikiEngine related to this servlet.  Since this method
-     *  is only called from JSP pages (and JspInit()) to be specific,
+     *  Gets a WikiEngine related to this servlet.  Since this method is only called from JSP pages (and JspInit()) to be specific,
      *  we throw a RuntimeException if things don't work.
      *
      *  @param config The ServletConfig object for this servlet.
      *
      *  @return A WikiEngine instance.
-     *  @throws InternalWikiException in case something fails.  This is a RuntimeException, so be prepared for it.
+     *  @throws InternalWikiException in case something fails. This is a RuntimeException, so be prepared for it.
      */
-    // FIXME: It seems that this does not work too well, jspInit()
-    // does not react to RuntimeExceptions, or something...
+    // FIXME: It seems that this does not work too well, jspInit() does not react to RuntimeExceptions, or something...
     public static synchronized WikiEngine getInstance( final ServletConfig config ) throws InternalWikiException {
         return getInstance( config.getServletContext(), null );
     }
 
     /**
-     *  Gets a WikiEngine related to the servlet. Works like getInstance(ServletConfig),
-     *  but does not force the Properties object. This method is just an optional way
-     *  of initializing a WikiEngine for embedded JSPWiki applications; normally, you
+     *  Gets a WikiEngine related to the servlet. Works like getInstance(ServletConfig), but does not force the Properties object.
+     *  This method is just an optional way of initializing a WikiEngine for embedded JSPWiki applications; normally, you
      *  should use getInstance(ServletConfig).
      *
      *  @param config The ServletConfig of the webapp servlet/JSP calling this method.
-     *  @param props  A set of properties, or null, if we are to load JSPWiki's default
-     *                jspwiki.properties (this is the usual case).
+     *  @param props  A set of properties, or null, if we are to load JSPWiki's default jspwiki.properties (this is the usual case).
      *
      *  @return One well-behaving WikiEngine instance.
      */
@@ -311,7 +303,6 @@ public class WikiEngine  {
     // FIXME: Potential make-things-easier thingy here: no need to fetch the wikiengine anymore
     //        Wiki.jsp.jspInit() [really old code]; it's probably even faster to fetch it
     //        using this method every time than go to pageContext.getAttribute().
-
     public static synchronized WikiEngine getInstance( final ServletContext context, Properties props ) throws InternalWikiException {
         WikiEngine engine = ( WikiEngine )context.getAttribute( ATTR_WIKIENGINE );
 
@@ -338,8 +329,7 @@ public class WikiEngine  {
 
 
     /**
-     *  Instantiate the WikiEngine using a given set of properties.
-     *  Use this constructor for testing purposes only.
+     *  Instantiate the WikiEngine using a given set of properties. Use this constructor for testing purposes only.
      *
      *  @param properties A set of properties to use to initialize this WikiEngine.
      *  @throws WikiException If the initialization fails.
@@ -349,14 +339,11 @@ public class WikiEngine  {
     }
 
     /**
-     *  Instantiate using this method when you're running as a servlet and
-     *  WikiEngine will figure out where to look for the property
-     *  file.
+     *  Instantiate using this method when you're running as a servlet and WikiEngine will figure out where to look for the property file.
      *  Do not use this method - use WikiEngine.getInstance() instead.
      *
      *  @param context A ServletContext.
-     *  @param appid   An Application ID.  This application is an unique random string which
-     *                 is used to recognize this WikiEngine.
+     *  @param appid   An Application ID.  This application is an unique random string which is used to recognize this WikiEngine.
      *  @param props   The WikiEngine configuration.
      *  @throws WikiException If the WikiEngine construction fails.
      */
@@ -644,8 +631,7 @@ public class WikiEngine  {
      *  @since 2.1.100
      *  @return The working directory.
      */
-    public String getWorkDir()
-    {
+    public String getWorkDir() {
         return m_workDir;
     }
 
@@ -655,8 +641,7 @@ public class WikiEngine  {
      *  @since 1.9.20
      *  @return The template directory as initialized by the engine.
      */
-    public String getTemplateDir()
-    {
+    public String getTemplateDir() {
         return m_templateDir;
     }
 
@@ -665,35 +650,56 @@ public class WikiEngine  {
      *
      *  @return A TemplateManager instance.
      */
-    public TemplateManager getTemplateManager()
-    {
+    public TemplateManager getTemplateManager() {
         return m_templateManager;
     }
 
     /**
+     *  Returns the moment when this engine was started.
+     *
+     *  @since 2.0.15.
+     *  @return The start time of this wiki.
+     */
+    public Date getStartTime() {
+        return ( Date )m_startTime.clone();
+    }
+
+    /**
      *  Returns the base URL, telling where this Wiki actually lives.
      *
      *  @since 1.6.1
      *  @return The Base URL.
      */
     public String getBaseURL() {
-    	return m_servletContext.getContextPath();
+        return m_servletContext.getContextPath();
     }
 
     /**
-     *  Returns the moment when this engine was started.
+     *  Returns the URL of the global RSS file.  May be null, if the RSS file generation is not operational.
      *
-     *  @since 2.0.15.
-     *  @return The start time of this wiki.
+     *  @since 1.7.10
+     *  @return The global RSS url
      */
-    public Date getStartTime()
-    {
-        return (Date)m_startTime.clone();
+    public String getGlobalRSSURL() {
+        if( m_rssGenerator != null && m_rssGenerator.isEnabled() ) {
+            return getBaseURL() + "/" + m_rssFile;
+        }
+
+        return null;
     }
 
     /**
-     * <p>Returns the basic absolute (or relative, depending on the variable {@link WikiEngine#PROP_REFSTYLE}) URL to a page, without any
-     * modifications. You may add any parameters to this.</p>
+     *  Returns an URL to some other Wiki that we know.
+     *
+     *  @param  wikiName The name of the other wiki.
+     *  @return null, if no such reference was found.
+     */
+    public String getInterWikiURL( final String wikiName ) {
+        return TextUtil.getStringProperty( m_properties,PROP_INTERWIKIREF + wikiName,null );
+    }
+
+    /**
+     * <p>Returns the basic absolute URL to a page, without any modifications. You may add any parameters to this.</p>
      * <p>Since 2.3.90 it is safe to call this method with {@code null} pageName, in which case it will default to the front page.</p>
      *
      * @since 2.0.3
@@ -704,9 +710,7 @@ public class WikiEngine  {
         if( pageName == null ) {
             pageName = getFrontPage();
         }
-        final WikiContext wc = new WikiContext( this, new WikiPage( this, pageName ) );
-        final boolean absolute = Boolean.parseBoolean( getVariableManager().getVariable( wc, WikiEngine.PROP_REFSTYLE ) );
-        return getURLConstructor().makeURL( WikiContext.VIEW, pageName, absolute, null );
+        return getURLConstructor().makeURL( WikiContext.VIEW, pageName, true, null );
     }
 
     /**
@@ -730,7 +734,6 @@ public class WikiEngine  {
      *
      *  @return The front page name.
      */
-
     public String getFrontPage() {
         return m_frontPage;
     }
@@ -743,22 +746,11 @@ public class WikiEngine  {
      *  @since 1.7.10
      *  @return ServletContext of the WikiEngine, or null.
      */
-
     public ServletContext getServletContext() {
         return m_servletContext;
     }
 
     /**
-     *  Returns an URL to some other Wiki that we know.
-     *
-     *  @param  wikiName The name of the other wiki.
-     *  @return null, if no such reference was found.
-     */
-    public String getInterWikiURL( final String wikiName ) {
-        return TextUtil.getStringProperty( m_properties,PROP_INTERWIKIREF + wikiName,null );
-    }
-
-    /**
      *  Returns a collection of all supported InterWiki links.
      *
      *  @return A Collection of Strings.
@@ -883,10 +875,10 @@ public class WikiEngine  {
     /**
      * Returns the {@link org.apache.wiki.workflow.WorkflowManager} associated with this WikiEngine. If the WIkiEngine has not been
      * initialized, this method will return <code>null</code>.
+     *
      * @return the task queue
      */
-    public WorkflowManager getWorkflowManager()
-    {
+    public WorkflowManager getWorkflowManager() {
         return m_workflowMgr;
     }
 
@@ -901,12 +893,11 @@ public class WikiEngine  {
 
     /**
      *  Returns this object's ReferenceManager.
-     *  @return The current ReferenceManager instance.
      *
+     *  @return The current ReferenceManager instance.
      *  @since 1.6.1
      */
-    public ReferenceManager getReferenceManager()
-    {
+    public ReferenceManager getReferenceManager() {
         return m_referenceManager;
     }
 
@@ -916,8 +907,7 @@ public class WikiEngine  {
      *  @since 2.3.27
      * @return A RenderingManager object.
      */
-    public RenderingManager getRenderingManager()
-    {
+    public RenderingManager getRenderingManager() {
         return m_renderingManager;
     }
 
@@ -933,42 +923,38 @@ public class WikiEngine  {
 
     /**
      *  Returns the current variable manager.
+     *
      *  @return The current VariableManager.
      */
-    public VariableManager getVariableManager()
-    {
+    public VariableManager getVariableManager()  {
         return m_variableManager;
     }
 
     /**
-     *  Returns the current PageManager which is responsible for storing
-     *  and managing WikiPages.
+     *  Returns the current PageManager which is responsible for storing and managing WikiPages.
      *
      *  @return The current PageManager instance.
      */
-    public PageManager getPageManager()
-    {
+    public PageManager getPageManager() {
         return m_pageManager;
     }
 
     /**
      * Returns the CommandResolver for this wiki engine.
+     *
      * @return the resolver
      */
-    public CommandResolver getCommandResolver()
-    {
+    public CommandResolver getCommandResolver() {
         return m_commandResolver;
     }
 
     /**
-     *  Returns the current AttachmentManager, which is responsible for
-     *  storing and managing attachments.
+     *  Returns the current AttachmentManager, which is responsible for storing and managing attachments.
      *
      *  @since 1.9.31.
      *  @return The current AttachmentManager instance
      */
-    public AttachmentManager getAttachmentManager()
-    {
+    public AttachmentManager getAttachmentManager() {
         return m_attachmentManager;
     }
 
@@ -977,8 +963,7 @@ public class WikiEngine  {
      *
      *  @return The current AuthorizationManager instance
      */
-    public AuthorizationManager getAuthorizationManager()
-    {
+    public AuthorizationManager getAuthorizationManager()  {
         return m_authorizationManager;
     }
 
@@ -987,13 +972,13 @@ public class WikiEngine  {
      *
      *  @return The current AuthenticationManager instance.
      */
-    public AuthenticationManager getAuthenticationManager()
-    {
+    public AuthenticationManager getAuthenticationManager() {
         return m_authenticationManager;
     }
 
     /**
      *  Returns the manager responsible for the filters.
+     *
      *  @since 2.1.88
      *  @return The current FilterManager instance
      */
@@ -1003,38 +988,39 @@ public class WikiEngine  {
 
     /**
      *  Returns the manager responsible for searching the Wiki.
+     *
      *  @since 2.2.21
      *  @return The current SearchManager instance
      */
-    public SearchManager getSearchManager()
-    {
+    public SearchManager getSearchManager() {
         return m_searchManager;
     }
 
     /**
      *  Returns the progress manager we're using
+     *
      *  @return A ProgressManager
      *  @since 2.6
      */
-    public ProgressManager getProgressManager()
-    {
+    public ProgressManager getProgressManager() {
         return m_progressManager;
     }
 
     /**
      *  Figure out to which page we are really going to.  Considers special page names from the jspwiki.properties, and possible aliases.
      *  This method delgates requests to {@link org.apache.wiki.WikiContext#getRedirectURL()}.
+     *
      *  @param context The Wiki Context in which the request is being made.
      *  @return A complete URL to the new page to redirect to
      *  @since 2.2
      */
-    public String getRedirectURL( final WikiContext context )
-    {
+    public String getRedirectURL( final WikiContext context ) {
         return context.getRedirectURL();
     }
 
     /**
      *  Shortcut to create a WikiContext from a supplied HTTP request, using a default wiki context.
+     *
      *  @param request the HTTP request
      *  @param requestContext the default context to use
      *  @return a new WikiContext object.
@@ -1055,28 +1041,12 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the URL of the global RSS file.  May be null, if the RSS file generation is not operational.
-     *  @since 1.7.10
-     *  @return The global RSS url
-     */
-    public String getGlobalRSSURL()
-    {
-        if( m_rssGenerator != null && m_rssGenerator.isEnabled() )
-        {
-            return getBaseURL()+ "/" + m_rssFile;
-        }
-
-        return null;
-    }
-
-    /**
      *  Returns the root path.  The root path is where the WikiEngine is located in the file system.
      *
      *  @since 2.2
      *  @return A path to where the Wiki is installed in the local filesystem.
      */
-    public String getRootPath()
-    {
+    public String getRootPath() {
         return m_rootPath;
     }
 
@@ -1084,58 +1054,57 @@ public class WikiEngine  {
      * @since 2.2.6
      * @return the URL constructor
      */
-    public URLConstructor getURLConstructor()
-    {
+    public URLConstructor getURLConstructor() {
         return m_urlConstructor;
     }
 
     /**
      * Returns the RSSGenerator. If the property <code>jspwiki.rss.generate</code> has not been set to <code>true</code>, this method
      * will return <code>null</code>, <em>and callers should check for this value.</em>
+     *
      * @since 2.1.165
      * @return the RSS generator
      */
-    public RSSGenerator getRSSGenerator()
-    {
+    public RSSGenerator getRSSGenerator() {
         return m_rssGenerator;
     }
 
     /**
      *  Returns the PageRenamer employed by this WikiEngine.
+     *
      *  @since 2.5.141
      *  @return The current PageRenamer instance.
      */
-    public PageRenamer getPageRenamer()
-    {
+    public PageRenamer getPageRenamer() {
         return m_pageRenamer;
     }
 
     /**
      *  Returns the UserManager employed by this WikiEngine.
+     *
      *  @since 2.3
      *  @return The current UserManager instance.
      */
-    public UserManager getUserManager()
-    {
+    public UserManager getUserManager() {
         return m_userManager;
     }
 
     /**
      *  Returns the TasksManager employed by this WikiEngine.
+     *
      *  @return The current TasksManager instance.
      */
-    public TasksManager getTasksManager()
-    {
+    public TasksManager getTasksManager() {
         return m_tasksManager;
     }
 
     /**
      *  Returns the GroupManager employed by this WikiEngine.
+     *
      *  @since 2.3
      *  @return The current GroupManager instance
      */
-    public GroupManager getGroupManager()
-    {
+    public GroupManager getGroupManager() {
         return m_groupManager;
     }
 
@@ -1174,10 +1143,10 @@ public class WikiEngine  {
 
     /**
      *  Returns the DifferenceManager so that texts can be compared.
+     *
      *  @return the difference manager
      */
-    public DifferenceManager getDifferenceManager()
-    {
+    public DifferenceManager getDifferenceManager() {
         return m_differenceManager;
     }
 
@@ -1186,8 +1155,7 @@ public class WikiEngine  {
      *
      *  @return The current EditorManager.
      */
-    public EditorManager getEditorManager()
-    {
+    public EditorManager getEditorManager() {
         return m_editorManager;
     }
 
@@ -1196,13 +1164,13 @@ public class WikiEngine  {
      *
      *  @return The current Intertan... Interante... Internatatializ... Whatever.
      */
-    public InternationalizationManager getInternationalizationManager()
-    {
+    public InternationalizationManager getInternationalizationManager() {
         return m_internationalizationManager;
     }
 
     /**
      * Registers a WikiEventListener with this instance.
+     *
      * @param listener the event listener
      */
     public final synchronized void addWikiEventListener( final WikiEventListener listener ) {
@@ -1211,6 +1179,7 @@ public class WikiEngine  {
 
     /**
      * Un-registers a WikiEventListener with this instance.
+     *
      * @param listener the event listener
      */
     public final synchronized void removeWikiEventListener( final WikiEventListener listener ) {
@@ -1219,6 +1188,7 @@ public class WikiEngine  {
 
     /**
      * Fires a WikiEngineEvent to all registered listeners.
+     *
      * @param type  the event type
      */
     protected final void fireEvent( final int type ) {
@@ -1244,8 +1214,7 @@ public class WikiEngine  {
      * @param key the attribute name
      * @param value the value
      */
-    public void setAttribute( final String key, final Object value )
-    {
+    public void setAttribute( final String key, final Object value ) {
         m_attributes.put( key, value );
     }
 
@@ -1266,8 +1235,7 @@ public class WikiEngine  {
      *  @param key The key of the attribute to remove.
      *  @return The previous attribute, if it existed.
      */
-    public Object removeAttribute( final String key )
-    {
+    public Object removeAttribute( final String key ) {
         return m_attributes.remove( key );
     }
 
@@ -1277,9 +1245,8 @@ public class WikiEngine  {
      *  @return The current thread WatchDog.
      *  @since 2.4.92
      */
-    public WatchDog getCurrentWatchDog()
-    {
-        return WatchDog.getCurrentWatchDog(this);
+    public WatchDog getCurrentWatchDog() {
+        return WatchDog.getCurrentWatchDog( this );
     }
 
 }


[jspwiki] 20/32: JSPWIKI-1127: remove references to PROP_REFSTYLE

Posted by ju...@apache.org.
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 3e8e1e6e1b860185d671d0d269863ccbffe20aa9
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 22 23:30:28 2020 +0100

    JSPWIKI-1127: remove references to PROP_REFSTYLE
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  3 ---
 .../main/java/org/apache/wiki/tags/LinkTag.java    | 25 +++++-----------------
 .../java/org/apache/wiki/xmlrpc/RPCHandler.java    |  3 ---
 .../org/apache/wiki/xmlrpc/RPCHandlerUTF8.java     |  3 ---
 4 files changed, 5 insertions(+), 29 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 67c1d4d..873d583 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -128,9 +128,6 @@ public class WikiEngine  {
     Double negative, cause for most servers you don't need the property */
     public static final String PROP_NO_FILTER_ENCODING = "jspwiki.nofilterencoding";
 
-    /** The name for the property which allows you to set the current reference style.  The value is {@value}. */
-    public static final String PROP_REFSTYLE = "jspwiki.referenceStyle";
-
     /** Property name for where the jspwiki work directory should be.
         If not specified, reverts to ${java.tmpdir}. */
     public static final String PROP_WORKDIR = "jspwiki.workDir";
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java
index ab096a7..e464f59 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java
@@ -63,9 +63,6 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
     private String m_tabindex = null;
     private String m_templatefile = null;
 
-    private boolean m_absolute = false;
-    private boolean m_overrideAbsolute = false;
-
     private Map<String, String> m_containedParams;
 
     private BodyContent m_bodyContent;
@@ -75,7 +72,6 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
         m_version = m_cssClass = m_style = m_title = m_target = m_compareToVersion = m_rel = m_jsp = m_ref = m_accesskey = m_templatefile = null;
         m_context = WikiContext.VIEW;
         m_containedParams = new HashMap<>();
-        m_absolute = false;
     }
 
     public void setTemplatefile( final String key )
@@ -88,11 +84,6 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
         m_accesskey = key;
     }
 
-    public void setAbsolute( final String arg ) {
-        m_overrideAbsolute = true;
-        m_absolute = TextUtil.isPositive( arg );
-    }
-
     public String getVersion()
     {
         return m_version;
@@ -235,10 +226,10 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
                         matchedLink = reallink;
                     }
 
-                    url = makeBasicURL( m_context, matchedLink, parms, m_absolute ) + sectref;
+                    url = makeBasicURL( m_context, matchedLink, parms ) + sectref;
                 } else {
                     final String reallink = MarkupParser.cleanLink( m_ref );
-                    url = makeBasicURL( m_context, reallink, parms, m_absolute );
+                    url = makeBasicURL( m_context, reallink, parms );
                 }
             }
         } else if( m_pageName != null && m_pageName.length() > 0 ) {
@@ -258,11 +249,11 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
                 url = engine.getURL( ctx, m_pageName, parms );
                 //url = m_wikiContext.getURL( ctx, m_pageName, parms );
             } else {
-                url = makeBasicURL( m_context, m_pageName, parms, m_absolute );
+                url = makeBasicURL( m_context, m_pageName, parms );
             }
         } else {
             final String page = engine.getFrontPage();
-            url = makeBasicURL( m_context, page, null, m_absolute );
+            url = makeBasicURL( m_context, page, null );
         }
 
         return url;
@@ -294,7 +285,7 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
         return addTo + buf.toString();
     }
 
-    private String makeBasicURL( final String context, final String page, String parms, final boolean absolute ) {
+    private String makeBasicURL( final String context, final String page, String parms ) {
         final WikiEngine engine = m_wikiContext.getEngine();
 
         if( context.equals( WikiContext.DIFF ) ) {
@@ -340,12 +331,6 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
     public int doEndTag() {
         try {
             final WikiEngine engine = m_wikiContext.getEngine();
-
-            if( !m_overrideAbsolute ) {
-                // TODO: see WikiContext.getURL(); this check needs to be specified somewhere.
-                m_absolute = "absolute".equals( engine.getWikiProperties().getProperty( WikiEngine.PROP_REFSTYLE ) );
-            }
-
             final JspWriter out = pageContext.getOut();
             final String url = figureOutURL();
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java
index 756a710..e2a8f40 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java
@@ -21,7 +21,6 @@ package org.apache.wiki.xmlrpc;
 import org.apache.log4j.Logger;
 import org.apache.wiki.LinkCollector;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.auth.permissions.PagePermission;
@@ -219,8 +218,6 @@ public class RPCHandler extends AbstractRPCHandler {
         final LinkCollector attCollector   = new LinkCollector();
 
         final WikiContext context = new WikiContext( m_engine, page );
-        context.setVariable( WikiEngine.PROP_REFSTYLE, "absolute" );
-
         m_engine.getRenderingManager().textToHTML( context, pagedata, localCollector, extCollector, attCollector );
 
         final Vector< Hashtable< String, String > > result = new Vector<>();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java
index a0b323b..40f143f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandlerUTF8.java
@@ -20,7 +20,6 @@ package org.apache.wiki.xmlrpc;
 
 import org.apache.wiki.LinkCollector;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.auth.permissions.PagePermission;
@@ -173,8 +172,6 @@ public class RPCHandlerUTF8 extends AbstractRPCHandler {
         final LinkCollector attCollector   = new LinkCollector();
 
         final WikiContext context = new WikiContext( m_engine, page );
-        context.setVariable( WikiEngine.PROP_REFSTYLE, "absolute" );
-
         m_engine.getRenderingManager().textToHTML( context, pagedata, localCollector, extCollector, attCollector );
 
         final Vector< Hashtable< String, String > > result = new Vector<>();


[jspwiki] 09/32: explicit javadoc

Posted by ju...@apache.org.
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 bddeab5a7b663ab02777209cee94fb92bc6e2f71
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 18 19:09:50 2020 +0100

    explicit javadoc
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index b261745..6969223 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -711,12 +711,10 @@ public class WikiEngine  {
     }
 
     /**
-     * <p>
-     * Returns the basic absolute URL to a page, without any modifications. You may add any parameters to this.
-     * </p>
-     * <p>
-     * Since 2.3.90 it is safe to call this method with <code>null</code> pageName, in which case it will default to the front page.
-     * </p>
+     * <p>Returns the basic absolute (or relative, depending on the variable {@link WikiEngine#PROP_REFSTYLE}) URL to a page, without any
+     * modifications. You may add any parameters to this.</p>
+     * <p>Since 2.3.90 it is safe to call this method with {@code null} pageName, in which case it will default to the front page.</p>
+     *
      * @since 2.0.3
      * @param pageName The name of the page.  May be null, in which case defaults to the front page.
      * @return An absolute URL to the page.


[jspwiki] 30/32: apply format and fixes suggested by intellij to classes under the org.apache.wiki.search package

Posted by ju...@apache.org.
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 d94e958d666b6cd91e5dc67b8dc20e5d74e8a0e0
Author: juanpablo <ju...@apache.org>
AuthorDate: Tue Jan 28 21:17:05 2020 +0100

    apply format and fixes suggested by intellij to classes under the org.apache.wiki.search package
---
 .../apache/wiki/search/BasicSearchProvider.java    | 143 +++++++++------------
 .../java/org/apache/wiki/search/QueryItem.java     |   3 +-
 .../java/org/apache/wiki/search/SearchMatcher.java |  49 +++----
 .../org/apache/wiki/search/SearchProvider.java     |  17 +--
 .../java/org/apache/wiki/search/SearchResult.java  |   3 +-
 .../apache/wiki/search/SearchResultComparator.java |   7 +-
 6 files changed, 93 insertions(+), 129 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/BasicSearchProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
index 3f2d58b..12e2887 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/BasicSearchProvider.java
@@ -42,30 +42,28 @@ import java.util.TreeSet;
  *
  *  @since 2.2.21.
  */
-public class BasicSearchProvider implements SearchProvider
-{
-    private static final Logger log = Logger.getLogger(BasicSearchProvider.class);
+public class BasicSearchProvider implements SearchProvider {
+
+    private static final Logger log = Logger.getLogger( BasicSearchProvider.class );
 
     private WikiEngine m_engine;
 
     /**
      *  {@inheritDoc}
      */
-    public void initialize(WikiEngine engine, Properties props)
-            throws NoRequiredPropertyException, IOException
-    {
+    public void initialize( final WikiEngine engine, final Properties props ) throws NoRequiredPropertyException, IOException {
         m_engine = engine;
     }
 
     /**
      *  {@inheritDoc}
      */
-    public void pageRemoved(WikiPage page) {}
+    public void pageRemoved( final WikiPage page ) {}
 
     /**
      *  {@inheritDoc}
      */
-    public void reindexPage(WikiPage page) {}
+    public void reindexPage( final WikiPage page ) {}
 
     /**
      *  Parses a query into something that we can use.
@@ -73,74 +71,61 @@ public class BasicSearchProvider implements SearchProvider
      *  @param query A query string.
      *  @return A parsed array.
      */
-    public  QueryItem[] parseQuery(String query)
-    {
-        StringTokenizer st = new StringTokenizer( query, " \t," );
-
-        QueryItem[] items = new QueryItem[st.countTokens()];
+    public QueryItem[] parseQuery( final String query) {
+        final StringTokenizer st = new StringTokenizer( query, " \t," );
+        final QueryItem[] items = new QueryItem[st.countTokens()];
         int word = 0;
 
         log.debug("Expecting "+items.length+" items");
 
-        //
         //  Parse incoming search string
-        //
-
-        while( st.hasMoreTokens() )
-        {
-            log.debug("Item "+word);
+        while( st.hasMoreTokens() ) {
+            log.debug( "Item " + word );
             String token = st.nextToken().toLowerCase();
 
-            items[word] = new QueryItem();
+            items[ word ] = new QueryItem();
 
-            switch( token.charAt(0) )
-            {
-              case '+':
-                items[word].type = QueryItem.REQUIRED;
-                token = token.substring(1);
-                log.debug("Required word: "+token);
+            switch( token.charAt( 0 ) ) {
+            case '+':
+                items[ word ].type = QueryItem.REQUIRED;
+                token = token.substring( 1 );
+                log.debug( "Required word: " + token );
                 break;
 
-              case '-':
-                items[word].type = QueryItem.FORBIDDEN;
-                token = token.substring(1);
-                log.debug("Forbidden word: "+token);
+            case '-':
+                items[ word ].type = QueryItem.FORBIDDEN;
+                token = token.substring( 1 );
+                log.debug( "Forbidden word: " + token );
                 break;
 
-              default:
-                items[word].type = QueryItem.REQUESTED;
-                log.debug("Requested word: "+token);
+            default:
+                items[ word ].type = QueryItem.REQUESTED;
+                log.debug( "Requested word: " + token );
                 break;
             }
 
-            items[word++].word = token;
+            items[ word++ ].word = token;
         }
 
         return items;
     }
 
-    private String attachmentNames(WikiPage page, String separator)
-    {
-        if(m_engine.getAttachmentManager().hasAttachments(page))
-        {
-            List< Attachment > attachments;
-            try
-            {
-                attachments = m_engine.getAttachmentManager().listAttachments(page);
-            }
-            catch (ProviderException e)
-            {
-                log.error("Unable to get attachments for page", e);
+    private String attachmentNames( final WikiPage page ) {
+        if( m_engine.getAttachmentManager().hasAttachments( page ) ) {
+            final List< Attachment > attachments;
+            try {
+                attachments = m_engine.getAttachmentManager().listAttachments( page );
+            } catch( final ProviderException e ) {
+                log.error( "Unable to get attachments for page", e );
                 return "";
             }
 
-            StringBuilder attachmentNames = new StringBuilder();
-            for( Iterator< Attachment > it = attachments.iterator(); it.hasNext(); )
-            {
-                Attachment att = it.next();
-                attachmentNames.append(att.getName());
-                if(it.hasNext()) {
-                    attachmentNames.append(separator);
+            final StringBuilder attachmentNames = new StringBuilder();
+            for( final Iterator< Attachment > it = attachments.iterator(); it.hasNext(); ) {
+                final Attachment att = it.next();
+                attachmentNames.append( att.getName() );
+                if( it.hasNext() ) {
+                    attachmentNames.append( " " );
                 }
             }
             return attachmentNames.toString();
@@ -149,42 +134,36 @@ public class BasicSearchProvider implements SearchProvider
         return "";
     }
 
-    private Collection< SearchResult > findPages( QueryItem[] query, WikiContext wikiContext )
-    {
-        TreeSet<SearchResult> res = new TreeSet<>( new SearchResultComparator() );
-        SearchMatcher matcher = new SearchMatcher( m_engine, query );
-
-        Collection< WikiPage > allPages = null;
+    private Collection< SearchResult > findPages( final QueryItem[] query, final WikiContext wikiContext ) {
+        final TreeSet< SearchResult > res = new TreeSet<>( new SearchResultComparator() );
+        final SearchMatcher matcher = new SearchMatcher( m_engine, query );
+        final Collection< WikiPage > allPages;
         try {
             allPages = m_engine.getPageManager().getAllPages();
-        } catch( ProviderException pe ) {
+        } catch( final ProviderException pe ) {
             log.error( "Unable to retrieve page list", pe );
             return null;
         }
 
-        AuthorizationManager mgr = m_engine.getAuthorizationManager();
+        final AuthorizationManager mgr = m_engine.getAuthorizationManager();
 
-        Iterator< WikiPage > it = allPages.iterator();
-        while( it.hasNext() ) {
+        for( final WikiPage page : allPages ) {
             try {
-                WikiPage page = it.next();
-                if (page != null) {
-                	
-                    PagePermission pp = new PagePermission( page, PagePermission.VIEW_ACTION );
-                    if( wikiContext==null || mgr.checkPermission( wikiContext.getWikiSession(), pp ) ) {
-	                    String pageName = page.getName();
-	                    String pageContent = m_engine.getPageManager().getPageText(pageName, WikiPageProvider.LATEST_VERSION) +
-	                                         attachmentNames(page, " ");
-	                    SearchResult comparison = matcher.matchPageContent( pageName, pageContent );
-	
-	                    if( comparison != null ) {
-	                        res.add( comparison );
-	                    }
-	                }
-	            }
-            } catch( ProviderException pe ) {
+                if( page != null ) {
+                    final PagePermission pp = new PagePermission( page, PagePermission.VIEW_ACTION );
+                    if( wikiContext == null || mgr.checkPermission( wikiContext.getWikiSession(), pp ) ) {
+                        final String pageName = page.getName();
+                        final String pageContent =
+                                m_engine.getPageManager().getPageText( pageName, WikiPageProvider.LATEST_VERSION ) + attachmentNames( page );
+                        final SearchResult comparison = matcher.matchPageContent( pageName, pageContent );
+                        if( comparison != null ) {
+                            res.add( comparison );
+                        }
+                    }
+                }
+            } catch( final ProviderException pe ) {
                 log.error( "Unable to retrieve page from cache", pe );
-            } catch( IOException ioe ) {
+            } catch( final IOException ioe ) {
                 log.error( "Failed to search page", ioe );
             }
         }
@@ -195,8 +174,8 @@ public class BasicSearchProvider implements SearchProvider
     /**
      *  {@inheritDoc}
      */
-    public Collection< SearchResult > findPages(String query, WikiContext wikiContext) {
-        return findPages(parseQuery(query), wikiContext);
+    public Collection< SearchResult > findPages( final String query, final WikiContext wikiContext ) {
+        return findPages( parseQuery( query ), wikiContext );
     }
 
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/QueryItem.java b/jspwiki-main/src/main/java/org/apache/wiki/search/QueryItem.java
index ad18b27..acbb74a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/QueryItem.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/QueryItem.java
@@ -20,8 +20,7 @@ package org.apache.wiki.search;
 
 
 /**
- * This simple class just fulfils the role of a container for searches.  It tells the word and whether it is 
- * requested or not.
+ * This simple class just fulfils the role of a container for searches.  It tells the word and whether it is requested or not.
  */
 public class QueryItem {
 	
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
index 71c67ca..c741ac7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
@@ -18,19 +18,18 @@
  */
 package org.apache.wiki.search;
 
-import java.io.IOException;
-import java.io.BufferedReader;
-import java.io.StringReader;
-
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+
 
 /**
- * SearchMatcher performs the task of matching a search query to a page's
- * contents. This utility class is isolated to simplify WikiPageProvider
- * implementations and to offer an easy target for upgrades. The upcoming(?)
- * TranslatorReader rewrite will presumably invalidate this, among other things.
+ * SearchMatcher performs the task of matching a search query to a page's contents. This utility class is isolated to simplify
+ * WikiPageProvider implementations and to offer an easy target for upgrades. The upcoming(?) TranslatorReader rewrite will
+ * presumably invalidate this, among other things.
  *
  * @since 2.1.5
  */
@@ -45,15 +44,14 @@ public class SearchMatcher {
      *  @param engine The WikiEngine
      *  @param queries A list of queries
      */
-    public SearchMatcher( WikiEngine engine, QueryItem[] queries ) {
+    public SearchMatcher( final WikiEngine engine, final QueryItem[] queries ) {
         m_engine = engine;
         m_queries = queries != null ? queries.clone() : null;
     }
 
     /**
-     * Compares the page content, available through the given stream, to the
-     * query items of this matcher. Returns a search result object describing
-     * the quality of the match.
+     * Compares the page content, available through the given stream, to the query items of this matcher. Returns a search result
+     * object describing the quality of the match.
      *
      * <p>This method would benefit of regexps (1.4) and streaming. FIXME!
      * 
@@ -62,14 +60,14 @@ public class SearchMatcher {
      * @return A SearchResult item, or null, there are no queries
      * @throws IOException If reading page content fails
      */
-    public SearchResult matchPageContent( String wikiname, String pageText ) throws IOException {
+    public SearchResult matchPageContent( final String wikiname, final String pageText ) throws IOException {
         if( m_queries == null ) {
             return null;
         }
 
-        int[] scores = new int[ m_queries.length ];
-        BufferedReader in = new BufferedReader( new StringReader( pageText ) );
-        String line = null;
+        final int[] scores = new int[ m_queries.length ];
+        final BufferedReader in = new BufferedReader( new StringReader( pageText ) );
+        String line;
 
         while( (line = in.readLine() ) != null ) {
             line = line.toLowerCase();
@@ -88,29 +86,21 @@ public class SearchMatcher {
             }
         }
 
-        //
         //  Check that we have all required words.
-        //
         int totalscore = 0;
 
         for( int j = 0; j < scores.length; j++ ) {
-            // Give five points for each occurrence
-            // of the word in the wiki name.
-
-            if( wikiname.toLowerCase().indexOf( m_queries[j].word ) != -1 && m_queries[j].type != QueryItem.FORBIDDEN ) {
+            // Give five points for each occurrence of the word in the wiki name.
+            if( wikiname.toLowerCase().contains( m_queries[ j ].word ) && m_queries[j].type != QueryItem.FORBIDDEN ) {
                 scores[j] += 5;
             }
 
-            //  Filter out pages if the search word is marked 'required'
-            //  but they have no score.
-
+            //  Filter out pages if the search word is marked 'required' but they have no score.
             if( m_queries[j].type == QueryItem.REQUIRED && scores[j] == 0 ) {
                 return null;
             }
 
-            //
             //  Count the total score for this page.
-            //
             totalscore += scores[j];
         }
 
@@ -135,7 +125,7 @@ public class SearchMatcher {
          *  @param name Page Name
          *  @param score A score from 0+
          */
-        public SearchResultImpl( String name, int score ) {
+        public SearchResultImpl( final String name, final int score ) {
             m_page  = new WikiPage( m_engine, name );
             m_score = score;
         }
@@ -158,8 +148,7 @@ public class SearchMatcher {
         }
 
         /**
-         *  Returns an empty array, since BasicSearchProvider does not support
-         *  context matching.
+         *  Returns an empty array, since BasicSearchProvider does not support context matching.
          *  
          *  @return an empty array
          */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchProvider.java
index c72c488..1c2fc3c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchProvider.java
@@ -18,26 +18,26 @@
  */
 package org.apache.wiki.search;
 
-import java.io.IOException;
-import java.util.Collection;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.exceptions.ProviderException;
 
+import java.io.IOException;
+import java.util.Collection;
+
 /**
  *  Interface for the search providers that handle searching the Wiki
  *
  *  @since 2.2.21.
  */
-public interface SearchProvider extends WikiProvider
-{
+public interface SearchProvider extends WikiProvider {
+
     /**
      * Delete a page from the search index
      * @param page Page to remove from search index
      */
-    void pageRemoved(WikiPage page);
+    void pageRemoved( WikiPage page );
 
     /**
      *  Adds a WikiPage for indexing queue. This is called a queue, since
@@ -46,7 +46,7 @@ public interface SearchProvider extends WikiProvider
      *
      *  @param page The WikiPage to be indexed.
      */
-    void reindexPage(WikiPage page);
+    void reindexPage( WikiPage page );
 
     /**
      * Search for pages matching a search query
@@ -56,5 +56,6 @@ public interface SearchProvider extends WikiProvider
      * @throws ProviderException if the search provider failed.
      * @throws IOException if for some reason the query could not be executed.
      */
-    Collection< SearchResult > findPages(String query, WikiContext wikiContext) throws ProviderException, IOException;
+    Collection< SearchResult > findPages( String query, WikiContext wikiContext ) throws ProviderException, IOException;
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchResult.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchResult.java
index 161c6bf..34b0d88 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchResult.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchResult.java
@@ -39,8 +39,7 @@ public interface SearchResult {
      *  @return A positive score value.  Note that there is no upper limit for the score.
      */
     int getScore();
-    
-    
+
     /**
      * Collection of XHTML fragments representing some contexts in which the match was made (a.k.a., "snippets").
      *
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchResultComparator.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchResultComparator.java
index dd3a180..e727c06 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchResultComparator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchResultComparator.java
@@ -30,16 +30,13 @@ public class SearchResultComparator implements Comparator< SearchResult >, Seria
     private static final long serialVersionUID = 1L;
 
     /**
-     *  Compares two SearchResult objects, returning
-     *  the one that scored higher.
+     *  Compares two SearchResult objects, returning the one that scored higher.
      *  
      *  {@inheritDoc}
      */
-    public int compare( SearchResult s1, SearchResult s2 ) {
+    public int compare( final SearchResult s1, final SearchResult s2 ) {
         // Bigger scores are first.
-
         int res = s2.getScore() - s1.getScore();
-
         if( res == 0 ) {
             res = s1.getPage().getName().compareTo( s2.getPage().getName() );
         }


[jspwiki] 01/32: fix WikiEngine#getViewURL so that absolute parameter from makeUrl(..) is correctly calculated against the resolved variable instead to its associated key

Posted by ju...@apache.org.
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 4a639d78e194844258ea2a372840b0788c15e529
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 18 00:19:58 2020 +0100

    fix WikiEngine#getViewURL so that absolute parameter from makeUrl(..) is correctly calculated against the resolved variable instead to its associated key
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 2189371..83f4cdc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -729,8 +729,9 @@ public class WikiEngine  {
         if( pageName == null ) {
             pageName = getFrontPage();
         }
-        //FIXME: final boolean absolute = getVariableManager().getVariable( this, WikiEngine.PROP_REFSTYLE );
-        return getURLConstructor().makeURL( WikiContext.VIEW, pageName, "absolute".equals( PROP_REFSTYLE ), null );
+        final WikiContext wc = new WikiContext( this, new WikiPage( this, pageName ) );
+        final boolean absolute = Boolean.parseBoolean( getVariableManager().getVariable( wc, WikiEngine.PROP_REFSTYLE ) );
+        return getURLConstructor().makeURL( WikiContext.VIEW, pageName, absolute, null );
     }
 
     /**
@@ -755,8 +756,7 @@ public class WikiEngine  {
      *  @return The front page name.
      */
 
-    public String getFrontPage()
-    {
+    public String getFrontPage() {
         return m_frontPage;
     }
 
@@ -769,8 +769,7 @@ public class WikiEngine  {
      *  @return ServletContext of the WikiEngine, or null.
      */
 
-    public ServletContext getServletContext()
-    {
+    public ServletContext getServletContext() {
         return m_servletContext;
     }
 
@@ -808,7 +807,7 @@ public class WikiEngine  {
      */
     public Collection< String > getAllInlinedImagePatterns() {
         final ArrayList< String > ptrnlist = new ArrayList<>();
-        for( Enumeration< ? > e = m_properties.propertyNames(); e.hasMoreElements(); ) {
+        for( final Enumeration< ? > e = m_properties.propertyNames(); e.hasMoreElements(); ) {
             final String name = ( String )e.nextElement();
             if( name.startsWith( PROP_INLINEIMAGEPTRN ) ) {
                 ptrnlist.add( TextUtil.getStringProperty( m_properties, name, null ) );


[jspwiki] 32/32: 2.11.0-M7-git-06

Posted by ju...@apache.org.
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 62bb84ce444278f50d8531b55603e830e5c96b9d
Author: juanpablo <ju...@apache.org>
AuthorDate: Tue Jan 28 21:33:30 2020 +0100

    2.11.0-M7-git-06
---
 ChangeLog.md                                       | 26 +++++++++++++++++++++-
 .../src/main/java/org/apache/wiki/Release.java     |  2 +-
 2 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index e5f9366..7857aeb 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -17,6 +17,30 @@ specific language governing permissions and limitations
 under the License.
 -->
 
+**2020-01-28  Juan Pablo Santos (juanpablo AT apache DOT org)**
+
+* _2.11.0-M7-git-06_
+
+* [JSPWIKI-120](https://issues.apache.org/jira/browse/JSPWIKI-120): Separate rendering engine from core
+    * `CommandResolver` renamed as `org.apache.wiki.ui.DefaultCommandResolver`, with new 
+       `org.apache.wiki.ui.CommandResolver` extracted as interface of the latter
+    * `ProgressManager` renamed as `org.apache.wiki.ui.progress.DefaultProgressManager`, with new 
+      `org.apache.wiki.ui.progress.ProgressManager` extracted as interface of the latter
+    * removed `createContext(..)` method from `WikiEngine` use new constructor on `WikiContext` instead
+    * removed `WikiEngine#getRedirectURL(..)` use same method on `WikiContext`
+* Removed `WikiEventUtils` if relying on it use directly `WikiEventManager.getInstance().addWikiEventListener( client, listener )`
+* Fixed possible synchronization issues on `DefaultProgressManager` and `WikiAjaxDispatcherServlet`
+* `PageEventFilter` moved from `event` to `filters` package
+* `WikiEngine#init(..)` now enforces at least a 3.1 servlet api environment, inline with the servlet-api dependency version
+* [JSPWIKI-1127](https://issues.apache.org/jira/browse/JSPWIKI-1127): Get rid off jspwiki.referenceStyle
+* Dependency updates
+    * ASF parent pom to version 23
+    * Awaitility to 4.0.2
+    * Flexmark to 0.50.48
+    * JUnit to 5.6.0
+    * Lucene to 8.4.1
+    * SLF4J to 1.7.30
+
 **2020-01-16  Juan Pablo Santos (juanpablo AT apache DOT org)**
 
 * _2.11.0-M7-git-05_
@@ -26,7 +50,7 @@ under the License.
        `org.apache.wiki.render.RenderingManager` extracted as interface of the latter
     * moved `textToHtml(..)` methods from `WikiEngine` to `RenderingManager`
     * moved `getHTML(..)` methods from `WikiEngine` to `RenderingManager`
-    * moved `beautifyTitle( String )` and `beautifyTitleNoBreak` methods from `WikiEngine` to `RenderingManager`__
+    * moved `beautifyTitle( String )` and `beautifyTitleNoBreak` methods from `WikiEngine` to `RenderingManager`
 * `VAR_EXECUTE_PLUGINS` and `WYSIWYG_EDITOR_MODE` constants from `RenderingManager` moved to `WikiContext` (the latter 
 as `VAR_WYSIWYG_EDITOR_MODE`)
 * constant `PROP_RUNFILTERS` from `WikiEngine` moved to `VariableManager` as `VAR_RUNFILTERS`.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/Release.java b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
index c06bb25..225c8ba 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/Release.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
@@ -69,7 +69,7 @@ public final class Release {
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "git-05";
+    public static final String     BUILD         = "git-06";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of


[jspwiki] 04/32: fix: add synchronization to progressing tasks on progress manager

Posted by ju...@apache.org.
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 8a7d63b26d4085913ffc76d73d30662b0710e9d2
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 18 15:07:58 2020 +0100

    fix: add synchronization to progressing tasks on progress manager
---
 .../apache/wiki/ui/progress/ProgressManager.java   | 122 ++++++++++-----------
 1 file changed, 55 insertions(+), 67 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java
index 7e04394..8552a3f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java
@@ -18,51 +18,46 @@
  */
 package org.apache.wiki.ui.progress;
 
+import org.apache.log4j.Logger;
+import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
+import org.apache.wiki.ajax.WikiAjaxServlet;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.UUID;
+import java.util.concurrent.ConcurrentHashMap;
 
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.log4j.Logger;
-import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
-import org.apache.wiki.ajax.WikiAjaxServlet;
 
 /**
- *  Manages progressing items.  In general this class is used whenever JSPWiki
- *  is doing something which may require a long time.  In addition, this manager
- *  provides a JSON interface for finding remotely what the progress is.  The
- *  JSON object name is JSON_PROGRESSTRACKER = "{@value #JSON_PROGRESSTRACKER}".
+ *  Manages progressing items.  In general this class is used whenever JSPWiki is doing something which may require a long time.
+ *  In addition, this manager provides a JSON interface for finding remotely what the progress is.  The JSON object name is
+ *  JSON_PROGRESSTRACKER = "{@value #JSON_PROGRESSTRACKER}".
  *
  *  @since  2.6
  */
-// FIXME: Needs synchronization, I think
-public class ProgressManager
-{
-    private Map<String,ProgressItem> m_progressingTasks = new HashMap<String,ProgressItem>();
+public class ProgressManager {
 
-    /**
-     *  The name of the progress tracker JSON object.  The current value is "{@value}",
-     */
+    private Map< String,ProgressItem > m_progressingTasks = new ConcurrentHashMap<>();
+
+    /** The name of the progress tracker JSON object.  The current value is "{@value}", */
     public static final String JSON_PROGRESSTRACKER = "progressTracker";
 
-    private static Logger log = Logger.getLogger( ProgressManager.class );
+    private static final Logger log = Logger.getLogger( ProgressManager.class );
 
     /**
      *  Creates a new ProgressManager.
      */
-    public ProgressManager()
-    {
-    	//TODO: Replace with custom annotations. See JSPWIKI-566
+    public ProgressManager() {
+    	// TODO: Replace with custom annotations. See JSPWIKI-566
         WikiAjaxDispatcherServlet.registerServlet( JSON_PROGRESSTRACKER, new JSONTracker() );
     }
 
     /**
      *  You can use this to get an unique process identifier.
+     *
      *  @return A new random value
      */
     public String getNewProgressIdentifier()
@@ -71,31 +66,29 @@ public class ProgressManager
     }
 
     /**
-     *  Call this method to get your ProgressItem into the ProgressManager queue.
-     *  The ProgressItem will be moved to state STARTED.
+     *  Call this method to get your ProgressItem into the ProgressManager queue. The ProgressItem will be moved to state STARTED.
      *
      *  @param pi ProgressItem to start
      *  @param id The progress identifier
      */
-    public void startProgress( ProgressItem pi, String id )
-    {
-        log.debug("Adding "+id+" to progress queue");
+    public void startProgress( final ProgressItem pi, final String id ) {
+        log.debug( "Adding " + id + " to progress queue" );
         m_progressingTasks.put( id, pi );
         pi.setState( ProgressItem.STARTED );
     }
 
     /**
-     *  Call this method to remove your ProgressItem from the queue (after which
-     *  getProgress() will no longer find it.  The ProgressItem will be moved to state
-     *  STOPPED.
+     *  Call this method to remove your ProgressItem from the queue (after which getProgress() will no longer find it.
+     *  The ProgressItem will be moved to state STOPPED.
      *
      *  @param id The progress identifier
      */
-    public void stopProgress( String id )
-    {
-        log.debug("Removed "+id+" from progress queue");
-        ProgressItem pi = m_progressingTasks.remove( id );
-        if( pi != null ) pi.setState( ProgressItem.STOPPED );
+    public void stopProgress( final String id ) {
+        log.debug( "Removed " + id + " from progress queue" );
+        final ProgressItem pi = m_progressingTasks.remove( id );
+        if( pi != null ) {
+            pi.setState( ProgressItem.STOPPED );
+        }
     }
 
     /**
@@ -105,33 +98,27 @@ public class ProgressManager
      *  @return a value between 0 to 100 indicating the progress
      *  @throws IllegalArgumentException If no such progress item exists.
      */
-    public int getProgress( String id )
-        throws IllegalArgumentException
-    {
-        ProgressItem pi = m_progressingTasks.get( id );
-
-        if( pi != null )
-        {
+    public int getProgress( final String id ) throws IllegalArgumentException {
+        final ProgressItem pi = m_progressingTasks.get( id );
+        if( pi != null ) {
             return pi.getProgress();
         }
 
-        throw new IllegalArgumentException("No such id was found");
+        throw new IllegalArgumentException( "No such id was found" );
     }
 
     /**
-     *  Provides access to a progress indicator, assuming you know the ID.
-     *  Progress of zero (0) means that the progress has just started, and a progress of
-     *  100 means that it is complete.
+     *  Provides access to a progress indicator, assuming you know the ID. Progress of zero (0) means that the progress has just started,
+     *  and a progress of 100 means that it is complete.
      */
-    public class JSONTracker implements WikiAjaxServlet
-    {
+    public class JSONTracker implements WikiAjaxServlet {
         /**
          *  Returns upload progress in percents so far.
-         *  @param progressId The string representation of the progress ID that you want to know the
-         *                    progress of.
+         *
+         *  @param progressId The string representation of the progress ID that you want to know the progress of.
          *  @return a value between 0 to 100 indicating the progress
          */
-        public int getProgress( String progressId )
+        public int getProgress( final String progressId )
         {
             return ProgressManager.this.getProgress( progressId );
         }
@@ -140,26 +127,27 @@ public class ProgressManager
         	return JSON_PROGRESSTRACKER;
         }
         
-        public void service(HttpServletRequest req, HttpServletResponse resp, String actionName, List<String> params)
-        		throws ServletException, IOException 
-        {
-        	log.debug("ProgressManager.doGet() START");
-        	if (params.size()<1) {
+        public void service( final HttpServletRequest req,
+                             final HttpServletResponse resp,
+                             final String actionName,
+                             final List< String > params ) throws IOException {
+        	log.debug( "ProgressManager.doGet() START" );
+        	if( params.size() < 1 ) {
         		return;
         	}
-        	String progressId = params.get(0);
-        	log.debug("progressId="+progressId);
+        	final String progressId = params.get(0);
+        	log.debug( "progressId=" + progressId );
         	String progressString = "";
         	try {
-        		int progress = getProgress(progressId);
-        		progressString = Integer.toString(progress);
-        	} catch (IllegalArgumentException e) {
-        		// ignore
-        		log.debug("progressId "+progressId+" is no longer valid");
+        		progressString = Integer.toString( getProgress( progressId ) );
+        	} catch( final IllegalArgumentException e ) { // ignore
+        		log.debug( "progressId " + progressId + " is no longer valid" );
         	}
-        	log.debug("progressString="+progressString);
-        	resp.getWriter().write(progressString);
-        	log.debug("ProgressManager.doGet() DONE");
+        	log.debug( "progressString=" + progressString );
+        	resp.getWriter().write( progressString );
+        	log.debug( "ProgressManager.doGet() DONE" );
         }
+
     }
+
 }


[jspwiki] 23/32: Update dependencies

Posted by ju...@apache.org.
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 bab93e90ebf532042b9ad434ce13d6b8475f4aa9
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 22 23:35:19 2020 +0100

    Update dependencies
    
    * awaitility to 4.0.2
    * flexmark to 0.50.48
    * junit to 5.6.0
    * lucene to 8.4.1
    * slf4j to 1.7.30
---
 pom.xml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/pom.xml b/pom.xml
index 48f20fd..9c8c5e4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,14 +45,14 @@
     <maven.version>3.5</maven.version>
 
     <akismet-java.version>1.02</akismet-java.version>
-    <awaitility.version>4.0.1</awaitility.version>
+    <awaitility.version>4.0.2</awaitility.version>
     <commons-fileupload.version>1.4</commons-fileupload.version>
     <commons-httpclient.version>3.1</commons-httpclient.version>
     <commons-io.version>2.6</commons-io.version>
     <commons-lang.version>3.9</commons-lang.version>
     <commons-text.version>1.8</commons-text.version>
     <ehcache.version>2.10.6</ehcache.version>
-    <flexmark.version>0.50.46</flexmark.version>
+    <flexmark.version>0.50.48</flexmark.version>
     <freshcookies-security.version>0.60</freshcookies-security.version>
     <gson.version>2.8.5</gson.version>
     <hsqldb.version>2.5.0</hsqldb.version>
@@ -64,14 +64,14 @@
     <jdom2.version>2.0.6</jdom2.version>
     <jetty.version>8.1.15.v20140411</jetty.version>
     <jrcs-diff.version>0.4.2</jrcs-diff.version>
-    <junit.version>5.5.2</junit.version>
+    <junit.version>5.6.0</junit.version>
     <log4j.version>1.2.17</log4j.version>
-    <lucene.version>8.4.0</lucene.version>
+    <lucene.version>8.4.1</lucene.version>
     <nekohtml.version>1.9.22</nekohtml.version>
     <oro.version>2.0.8</oro.version>
     <sandler.version>0.5</sandler.version>
     <selenide.version>5.6.0</selenide.version>
-    <slf4j.version>1.7.29</slf4j.version>
+    <slf4j.version>1.7.30</slf4j.version>
     <stripes.version>1.7.0-async-beta</stripes.version>
     <tika.version>1.23</tika.version>
     <tomcat.version>8.5.50</tomcat.version>


[jspwiki] 19/32: JSPWIKI-1127: propagate changes on JSPs

Posted by ju...@apache.org.
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 f5701c0df029f0afbdfdbc9b99f404fe1a5eff04
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 22 23:23:09 2020 +0100

    JSPWIKI-1127: propagate changes on JSPs
---
 jspwiki-war/src/main/webapp/Comment.jsp         |  6 +++---
 jspwiki-war/src/main/webapp/Delete.jsp          | 10 +++-------
 jspwiki-war/src/main/webapp/Edit.jsp            |  8 ++++----
 jspwiki-war/src/main/webapp/Login.jsp           |  6 +++---
 jspwiki-war/src/main/webapp/LostPassword.jsp    |  2 +-
 jspwiki-war/src/main/webapp/SisterSites.jsp     |  2 +-
 jspwiki-war/src/main/webapp/UserPreferences.jsp | 12 +++++-------
 7 files changed, 20 insertions(+), 26 deletions(-)

diff --git a/jspwiki-war/src/main/webapp/Comment.jsp b/jspwiki-war/src/main/webapp/Comment.jsp
index 0ca43c5..071eea6 100644
--- a/jspwiki-war/src/main/webapp/Comment.jsp
+++ b/jspwiki-war/src/main/webapp/Comment.jsp
@@ -238,12 +238,12 @@
             response.sendRedirect( e.getRedirect() );
             return;
         }
-        response.sendRedirect(wiki.getViewURL(pagereq));
+        response.sendRedirect(wikiContext.getViewURL(pagereq));
         return;
     } else if( preview != null ) {
         log.debug("Previewing "+pagereq);
         session.setAttribute(EditorManager.REQ_EDITEDTEXT, EditorManager.getEditedText(pageContext));
-        response.sendRedirect( TextUtil.replaceString( wiki.getURL(WikiContext.PREVIEW, pagereq, "action=comment", false),"&amp;","&") );
+        response.sendRedirect( TextUtil.replaceString( wiki.getURL(WikiContext.PREVIEW, pagereq, "action=comment"),"&amp;","&") );
         return;
     } else if( cancel != null ) {
         log.debug("Cancelled editing "+pagereq);
@@ -253,7 +253,7 @@
             wiki.getPageManager().unlockPage( lock );
             session.removeAttribute( "lock-"+pagereq );
         }
-        response.sendRedirect( wiki.getViewURL(pagereq) );
+        response.sendRedirect( wikiContext.getViewURL(pagereq) );
         return;
     }
 
diff --git a/jspwiki-war/src/main/webapp/Delete.jsp b/jspwiki-war/src/main/webapp/Delete.jsp
index 7dbe7d8..f2bfbda 100644
--- a/jspwiki-war/src/main/webapp/Delete.jsp
+++ b/jspwiki-war/src/main/webapp/Delete.jsp
@@ -74,7 +74,7 @@
             session.setAttribute( BreadcrumbsTag.BREADCRUMBTRAIL_KEY, trail );
         }
 
-        response.sendRedirect( TextUtil.replaceString( wiki.getURL( WikiContext.VIEW, redirTo, "tab="+request.getParameter("tab"), false ),"&amp;","&" ));
+        response.sendRedirect( TextUtil.replaceString( wiki.getURL( WikiContext.VIEW, redirTo, "tab="+request.getParameter("tab") ),"&amp;","&" ));
         return;
     }
     else if( delete != null )
@@ -98,9 +98,7 @@
 
         response.sendRedirect(
             TextUtil.replaceString(
-                wiki.getURL(
-                    WikiContext.VIEW, redirTo, "tab="+request.getParameter("tab"), false
-                ),"&amp;","&"
+                wiki.getURL( WikiContext.VIEW, redirTo, "tab=" + request.getParameter( "tab" ) ),"&amp;","&"
             )
         );
 
@@ -111,8 +109,6 @@
     // Set the content type and include the response content
     // FIXME: not so.
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "EditTemplate.jsp" );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "EditTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
 
diff --git a/jspwiki-war/src/main/webapp/Edit.jsp b/jspwiki-war/src/main/webapp/Edit.jsp
index 3972ff3..fbcd6ea 100644
--- a/jspwiki-war/src/main/webapp/Edit.jsp
+++ b/jspwiki-war/src/main/webapp/Edit.jsp
@@ -133,7 +133,7 @@
             log.info("Page changed, warning user.");
 
             session.setAttribute( EditorManager.REQ_EDITEDTEXT, EditorManager.getEditedText(pageContext) );
-            response.sendRedirect( wiki.getURL(WikiContext.CONFLICT, pagereq, null, false) );
+            response.sendRedirect( wiki.getURL(WikiContext.CONFLICT, pagereq, null ) );
             return;
         }
 
@@ -206,7 +206,7 @@
             return;
         }
 
-        response.sendRedirect(wiki.getViewURL(pagereq));
+        response.sendRedirect(wikiContext.getViewURL(pagereq));
         return;
     } else if( preview != null ) {
         log.debug("Previewing "+pagereq);
@@ -219,7 +219,7 @@
         }
 
         session.setAttribute("changenote", changenote != null ? changenote : "" );
-        response.sendRedirect( wiki.getURL(WikiContext.PREVIEW,pagereq,null,false) );
+        response.sendRedirect( wiki.getURL( WikiContext.PREVIEW, pagereq, null ) );
         return;
     } else if( cancel != null ) {
         log.debug("Cancelled editing "+pagereq);
@@ -228,7 +228,7 @@
             wiki.getPageManager().unlockPage( lock );
             session.removeAttribute( "lock-"+pagereq );
         }
-        response.sendRedirect( wiki.getViewURL(pagereq) );
+        response.sendRedirect( wikiContext.getViewURL(pagereq) );
         return;
     }
 
diff --git a/jspwiki-war/src/main/webapp/Login.jsp b/jspwiki-war/src/main/webapp/Login.jsp
index 7cbd41e..38313fb 100644
--- a/jspwiki-war/src/main/webapp/Login.jsp
+++ b/jspwiki-war/src/main/webapp/Login.jsp
@@ -69,7 +69,7 @@
                 		                            		 Preferences.getLocale( wikiContext ), 
                 		                            		 due.getMessage(), due.getArgs() ) );
             } catch( DecisionRequiredException e ) {
-                String redirect = wiki.getURL(WikiContext.VIEW,"ApprovalRequiredForUserProfiles",null,true);
+                String redirect = wiki.getURL( WikiContext.VIEW, "ApprovalRequiredForUserProfiles", null );
                 response.sendRedirect( redirect );
                 return;
             } catch( WikiSecurityException e ) {
@@ -79,7 +79,7 @@
         }
         if ( wikiSession.getMessages( "profile" ).length == 0 ) {
             String redirectPage = request.getParameter( "redirect" );
-            response.sendRedirect( wiki.getViewURL(redirectPage) );
+            response.sendRedirect( wikiContext.getViewURL(redirectPage) );
             return;
         }
     }
@@ -153,7 +153,7 @@
         if( !wiki.getPageManager().wikiPageExists( redirectPage ) ) {
            redirectPage = wiki.getFrontPage();
         }
-        String viewUrl = ( "Login".equals( redirectPage ) ) ? "Wiki.jsp" : wiki.getViewURL( redirectPage );
+        String viewUrl = ( "Login".equals( redirectPage ) ) ? "Wiki.jsp" : wikiContext.getViewURL( redirectPage );
 
         // Redirect!
         log.info( "Redirecting user to " + viewUrl );
diff --git a/jspwiki-war/src/main/webapp/LostPassword.jsp b/jspwiki-war/src/main/webapp/LostPassword.jsp
index 5c15297..b5ce908 100644
--- a/jspwiki-war/src/main/webapp/LostPassword.jsp
+++ b/jspwiki-war/src/main/webapp/LostPassword.jsp
@@ -61,7 +61,7 @@
             // Try sending email first, as that is more likely to fail.
 
             Object[] args = { profile.getLoginName(), randomPassword, request.getScheme() + "://"+ request.getServerName() + ":" + request.getServerPort() +
-                             wiki.getURLConstructor().makeURL( WikiContext.NONE, "Login.jsp", true, "" ), wiki.getApplicationName() };
+                             wiki.getURLConstructor().makeURL( WikiContext.NONE, "Login.jsp", "" ), wiki.getApplicationName() };
 
             String mailMessage = MessageFormat.format( rb.getString( "lostpwd.newpassword.email" ), args );
 
diff --git a/jspwiki-war/src/main/webapp/SisterSites.jsp b/jspwiki-war/src/main/webapp/SisterSites.jsp
index 067d9ef..d7fc719 100644
--- a/jspwiki-war/src/main/webapp/SisterSites.jsp
+++ b/jspwiki-war/src/main/webapp/SisterSites.jsp
@@ -49,7 +49,7 @@
         // TODO: This is a kludge and not forward-compatible.
         
         if( pageName.indexOf("/") != -1 ) continue; 
-        String url = wiki.getViewURL( pageName );
+        String url = wikiContext.getViewURL( pageName );
         
         out.write( url + " " + pageName + "\n" );
     }
diff --git a/jspwiki-war/src/main/webapp/UserPreferences.jsp b/jspwiki-war/src/main/webapp/UserPreferences.jsp
index 101acb9..1cc5b89 100644
--- a/jspwiki-war/src/main/webapp/UserPreferences.jsp
+++ b/jspwiki-war/src/main/webapp/UserPreferences.jsp
@@ -49,7 +49,7 @@
     UserManager userMgr = wiki.getUserManager();
     WikiSession wikiSession = wikiContext.getWikiSession();
 
-/* FIXME: Obsoslete 
+/* FIXME: Obsolete
     if( request.getParameter(EditorManager.PARA_EDITOR) != null )
     {
     	String editor = request.getParameter(EditorManager.PARA_EDITOR);
@@ -83,7 +83,7 @@
             }
             catch( DecisionRequiredException e )
             {
-                String redirect = wiki.getURL(WikiContext.VIEW,"ApprovalRequiredForUserProfiles",null,true);
+                String redirect = wiki.getURL( WikiContext.VIEW, "ApprovalRequiredForUserProfiles", null );
                 response.sendRedirect( redirect );
                 return;
             }
@@ -102,7 +102,7 @@
                redirectPage = wiki.getFrontPage();
             }
             
-            String viewUrl = ( "UserPreferences".equals( redirectPage ) ) ? "Wiki.jsp" : wiki.getViewURL( redirectPage );
+            String viewUrl = ( "UserPreferences".equals( redirectPage ) ) ? "Wiki.jsp" : wikiContext.getViewURL( redirectPage );
             log.info( "Redirecting user to " + viewUrl );
             response.sendRedirect( viewUrl );
             return;
@@ -120,7 +120,7 @@
         {
           redirectPage = wiki.getFrontPage();
         }
-        String viewUrl = ( "UserPreferences".equals( redirectPage ) ) ? "Wiki.jsp" : wiki.getViewURL( redirectPage );
+        String viewUrl = ( "UserPreferences".equals( redirectPage ) ) ? "Wiki.jsp" : wikiContext.getViewURL( redirectPage );
 
         log.info( "Redirecting user to " + viewUrl );
         response.sendRedirect( viewUrl );
@@ -133,8 +133,6 @@
         return;
     }
     response.setContentType("text/html; charset="+wiki.getContentEncoding() );
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "ViewTemplate.jsp" );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "ViewTemplate.jsp" );
 %><wiki:Include page="<%=contentPage%>" />
 


[jspwiki] 24/32: move PageEventFilter to filters package: it's a wiki filter, and we break a package cycle between event and filter

Posted by ju...@apache.org.
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 d741a8b8edbd4d70da23d4236f4adfa2b7e356fd
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 23 21:45:57 2020 +0100

    move PageEventFilter to filters package: it's a wiki filter, and we break a package cycle between event and filter
---
 .../java/org/apache/wiki/{event => filters}/PageEventFilter.java    | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/PageEventFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/PageEventFilter.java
similarity index 96%
rename from jspwiki-main/src/main/java/org/apache/wiki/event/PageEventFilter.java
rename to jspwiki-main/src/main/java/org/apache/wiki/filters/PageEventFilter.java
index d957466..3296774 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/PageEventFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/PageEventFilter.java
@@ -17,12 +17,16 @@
     under the License.  
  */
 
-package org.apache.wiki.event;
+package org.apache.wiki.filters;
 
 import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.wiki.api.exceptions.FilterException;
 
 import org.apache.wiki.WikiContext;
+import org.apache.wiki.event.WikiEventListener;
+import org.apache.wiki.event.WikiEventManager;
+import org.apache.wiki.event.WikiPageEvent;
+
 import java.util.Properties;
 
 /**


[jspwiki] 07/32: apply intellij's suggested formatting

Posted by ju...@apache.org.
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 9d3daeaba0dbd76fdaa42202386501d75247e9e0
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 18 15:30:22 2020 +0100

    apply intellij's suggested formatting
---
 .../main/java/org/apache/wiki/ajax/AjaxUtil.java   | 70 +++++++++++-----------
 .../java/org/apache/wiki/ajax/WikiAjaxServlet.java | 11 ++--
 .../org/apache/wiki/ui/progress/ProgressItem.java  | 17 +++---
 .../apache/wiki/ui/progress/ProgressManager.java   |  2 +-
 4 files changed, 49 insertions(+), 51 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ajax/AjaxUtil.java b/jspwiki-main/src/main/java/org/apache/wiki/ajax/AjaxUtil.java
index 3cd1801..8deda32 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ajax/AjaxUtil.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ajax/AjaxUtil.java
@@ -35,15 +35,15 @@ public class AjaxUtil extends HttpServlet {
 
 	/**
 	 * Uses Google Gson (https://code.google.com/p/google-gson/) to convert to JSON
+	 *
 	 * @param input the object to be converted to JSON
 	 * @return the JSON string of the object
 	 */
-	public static String toJson(Object input) {
-		String result = "";
-		if (input != null) {
-			result = gson.toJson(input);
+	public static String toJson( final Object input ) {
+		if( input != null ) {
+			return gson.toJson( input );
 		}
-		return result;
+		return "";
 	}
 	
 	/**
@@ -56,37 +56,37 @@ public class AjaxUtil extends HttpServlet {
 	 * @param path the RequestURI to search usually done by calling request.getRequestUri().
 	 * @param lastPart the previousPart of the path to search after.
 	 * @return the next part of the path.
-	 * @throws ServletException
+	 * @throws ServletException if {@code path} does not contain {@code lastPart}
 	 */
-	public static String getNextPathPart(String path, String lastPart) throws ServletException {
-        String result = null;
-        if (StringUtils.isBlank(path)) {
-            return result;
-        }
-        if (!lastPart.endsWith("/")) {
-        	lastPart += "/";
-        }
-        int index = path.indexOf(lastPart);
-        if (index<0) {
-        	lastPart = lastPart.substring(0,lastPart.length()-1);
-        	index = path.indexOf(lastPart);
-        	if (index<0) {
-        		throw new ServletException("Invalid path provided " + path + " does not contain '" + lastPart + "'");
-        	}
-        }
-        path = path.substring(index+lastPart.length());
-        index = path.indexOf("/");
-        if (index == -1) {
-            index = path.indexOf("#");
-            if (index == -1) {
-                index = path.indexOf("?");
-            }
-        }
-        if (index == -1) {
-            result = path;
-        }
-        else {
-            result = path.substring(0,index);
+	public static String getNextPathPart( String path, String lastPart ) throws ServletException {
+        if( StringUtils.isBlank( path ) ) {
+			return null;
+		}
+		if( !lastPart.endsWith( "/" ) ) {
+			lastPart += "/";
+		}
+		int index = path.indexOf( lastPart );
+		if( index < 0 ) {
+			lastPart = lastPart.substring( 0, lastPart.length() - 1 );
+			index = path.indexOf( lastPart );
+			if( index < 0 ) {
+				throw new ServletException( "Invalid path provided " + path + " does not contain '" + lastPart + "'" );
+			}
+		}
+		path = path.substring( index + lastPart.length() );
+		index = path.indexOf( "/" );
+		if( index == -1 ) {
+			index = path.indexOf( "#" );
+			if( index == -1 ) {
+				index = path.indexOf( "?" );
+			}
+		}
+
+		final String result;
+		if( index == -1 ) {
+			result = path;
+        } else {
+            result = path.substring( 0, index );
         }
 
         return result;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxServlet.java
index f24c94c..366a3e0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxServlet.java
@@ -19,14 +19,13 @@
  */
 package org.apache.wiki.ajax;
 
-import java.io.IOException;
-import java.util.List;
+import org.apache.wiki.plugin.SampleAjaxPlugin;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
-
-import org.apache.wiki.plugin.SampleAjaxPlugin;
+import java.io.IOException;
+import java.util.List;
 
 /**
  * An interface for a servlet that wants to use Ajax functionality.
@@ -36,8 +35,8 @@ import org.apache.wiki.plugin.SampleAjaxPlugin;
  */
 public interface WikiAjaxServlet {
 
-	public String getServletMapping();
+	String getServletMapping();
 
-	public void service(HttpServletRequest request, HttpServletResponse response, String actionName, List<String> params) throws ServletException, IOException;
+	void service( HttpServletRequest request, HttpServletResponse response, String actionName, List< String > params ) throws ServletException, IOException;
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressItem.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressItem.java
index 2f0a970..b9f3205 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressItem.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressItem.java
@@ -23,11 +23,9 @@ package org.apache.wiki.ui.progress;
  *
  *  @since  2.6
  */
-public abstract class ProgressItem
-{
-    /**
-     *  Status: The PI is created.
-     */
+public abstract class ProgressItem {
+
+    /** Status: The PI is created. */
     public static final int CREATED  = 0;
     
     /** Status: The PI is started. */
@@ -43,10 +41,10 @@ public abstract class ProgressItem
 
     /**
      *  Get the state of the ProgressItem.
+     *
      *  @return CREATED, STARTED, STOPPED or FINISHED.
      */
-    public int getState()
-    {
+    public int getState() {
         return m_state;
     }
 
@@ -55,14 +53,15 @@ public abstract class ProgressItem
      *  
      *  @param state One of the CREATED, STARTED, STOPPED or FINISHED.
      */
-    public void setState( int state )
-    {
+    public void setState( final int state ) {
         m_state = state;
     }
 
     /**
      *  Returns the progress in percents.
+     *
      *  @return An integer 0-100.
      */
     public abstract int getProgress();
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java
index 8552a3f..6ce37ce 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/progress/ProgressManager.java
@@ -40,7 +40,7 @@ import java.util.concurrent.ConcurrentHashMap;
  */
 public class ProgressManager {
 
-    private Map< String,ProgressItem > m_progressingTasks = new ConcurrentHashMap<>();
+    private final Map< String,ProgressItem > m_progressingTasks = new ConcurrentHashMap<>();
 
     /** The name of the progress tracker JSON object.  The current value is "{@value}", */
     public static final String JSON_PROGRESSTRACKER = "progressTracker";


[jspwiki] 22/32: JSPWIKI-1127: remove absolute parameter from wiki:Link tags

Posted by ju...@apache.org.
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 6a20fb4adbfd2046b0c2e7ddf772459915616236
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 22 23:32:05 2020 +0100

    JSPWIKI-1127: remove absolute parameter from wiki:Link tags
---
 jspwiki-war/src/main/webapp/rss.jsp                             | 4 ----
 jspwiki-war/src/main/webapp/templates/210/AttachmentTab.jsp     | 2 +-
 jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp       | 2 +-
 jspwiki-war/src/main/webapp/templates/default/AttachmentTab.jsp | 2 +-
 jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp   | 2 +-
 5 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/jspwiki-war/src/main/webapp/rss.jsp b/jspwiki-war/src/main/webapp/rss.jsp
index d58c2c2..e528bb9 100644
--- a/jspwiki-war/src/main/webapp/rss.jsp
+++ b/jspwiki-war/src/main/webapp/rss.jsp
@@ -79,10 +79,6 @@
     if( type == null || !(type.equals(RSSGenerator.RSS10) || type.equals(RSSGenerator.RSS20) || type.equals(RSSGenerator.ATOM)) ) 
     	   type = RSSGenerator.RSS20;
     
-    // Force the TranslatorReader to output absolute URLs
-    // regardless of the current settings.
-    wikiContext.setVariable( WikiEngine.PROP_REFSTYLE, "absolute" );
-
     // Set the content type and include the response content
     response.setContentType( RSSGenerator.getContentType(type)+"; charset=UTF-8");
 
diff --git a/jspwiki-war/src/main/webapp/templates/210/AttachmentTab.jsp b/jspwiki-war/src/main/webapp/templates/210/AttachmentTab.jsp
index 6ff5611..bc88026 100644
--- a/jspwiki-war/src/main/webapp/templates/210/AttachmentTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/AttachmentTab.jsp
@@ -35,7 +35,7 @@
 <div id="addattachment">
 <h3><fmt:message key="attach.add"/></h3>
 <wiki:Permission permission="upload">
-  <form action="<wiki:Link jsp='attach' format='url' absolute='true'><wiki:Param name='progressid' value='<%=progressId%>'/></wiki:Link>"
+  <form action="<wiki:Link jsp='attach' format='url'><wiki:Param name='progressid' value='<%=progressId%>'/></wiki:Link>"
          class="wikiform"
             id="uploadform"
         method="post"
diff --git a/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp b/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp
index 7d02d4a..57baec4 100644
--- a/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp
@@ -280,7 +280,7 @@
   <h3><fmt:message key="info.uploadnew"/></h3>
 
   <wiki:Permission permission="upload">
-  <form action="<wiki:Link jsp='attach' format='url' absolute='true'><wiki:Param name='progressid' value='<%=progressId%>'/></wiki:Link>"
+  <form action="<wiki:Link jsp='attach' format='url'><wiki:Param name='progressid' value='<%=progressId%>'/></wiki:Link>"
          class="wikiform"
             id="uploadform"
       onsubmit="return Wiki.submitUpload(this, '<%=progressId%>');"
diff --git a/jspwiki-war/src/main/webapp/templates/default/AttachmentTab.jsp b/jspwiki-war/src/main/webapp/templates/default/AttachmentTab.jsp
index 20ddf24..634df52 100644
--- a/jspwiki-war/src/main/webapp/templates/default/AttachmentTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/AttachmentTab.jsp
@@ -36,7 +36,7 @@
 <div class="page-content">
 <wiki:Permission permission="upload">
 
-  <form action="<wiki:Link jsp='attach' format='url' absolute='true'><wiki:Param name='progressid' value='${progressId}'/></wiki:Link>"
+  <form action="<wiki:Link jsp='attach' format='url'><wiki:Param name='progressid' value='${progressId}'/></wiki:Link>"
          class="accordion<wiki:HasAttachments></wiki:HasAttachments>"
             id="uploadform"
         method="post"
diff --git a/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp b/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp
index bfda22b..3575a83 100644
--- a/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp
@@ -252,7 +252,7 @@
 <c:set var="progressId" value="<%= c.getEngine().getProgressManager().getNewProgressIdentifier() %>" />
 <wiki:Permission permission="upload">
 
-  <form action="<wiki:Link jsp='attach' format='url' absolute='true'><wiki:Param name='progressid' value='${progressId}'/></wiki:Link>"
+  <form action="<wiki:Link jsp='attach' format='url'><wiki:Param name='progressid' value='${progressId}'/></wiki:Link>"
          class="accordion-close"
             id="uploadform"
         method="post" accept-charset="<wiki:ContentEncoding/>"


[jspwiki] 11/32: WikiEngine init now enforces at least a 3.1 servlet api environment, inline with the servlet-api dependency version

Posted by ju...@apache.org.
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 9aeae933f61a6cee91d35e1f64685288455e9d34
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Jan 20 00:17:08 2020 +0100

    WikiEngine init now enforces at least a 3.1 servlet api environment, inline with the servlet-api dependency version
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 61 ++++++++--------------
 1 file changed, 21 insertions(+), 40 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 6969223..4372105 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -391,10 +391,9 @@ public class WikiEngine  {
         m_properties = props;
 
         //
-        //  Initialize log4j.  However, make sure that we don't initialize it multiple times.
-        //  By default we load the log4j config statements from jspwiki.properties, unless
-        //  the property jspwiki.use.external.logconfig=true, in that case we let log4j figure out the
-        //  logging configuration.
+        //  Initialize log4j.  However, make sure that we don't initialize it multiple times. By default we load the log4j config
+        //  statements from jspwiki.properties, unless the property jspwiki.use.external.logconfig=true, in that case we let log4j
+        //  figure out the logging configuration.
         //
         if( !c_configured ) {
             final String useExternalLogConfig = TextUtil.getStringProperty( props,"jspwiki.use.external.logconfig","false" );
@@ -409,30 +408,25 @@ public class WikiEngine  {
 
         fireEvent( WikiEngineEvent.INITIALIZING ); // begin initialization
 
-        log.debug("Java version: "+System.getProperty("java.runtime.version"));
-        log.debug("Java vendor: "+System.getProperty("java.vm.vendor"));
-        log.debug("OS: "+System.getProperty("os.name")+" "+System.getProperty("os.version")+" "+System.getProperty("os.arch"));
-        log.debug("Default server locale: "+Locale.getDefault());
-        log.debug("Default server timezone: "+TimeZone.getDefault().getDisplayName(true, TimeZone.LONG));
+        log.debug( "Java version: " + System.getProperty( "java.runtime.version" ) );
+        log.debug( "Java vendor: " + System.getProperty( "java.vm.vendor" ) );
+        log.debug( "OS: " + System.getProperty( "os.name" ) + " " + System.getProperty( "os.version" ) + " " + System.getProperty( "os.arch" ) );
+        log.debug( "Default server locale: " + Locale.getDefault() );
+        log.debug( "Default server timezone: " + TimeZone.getDefault().getDisplayName( true, TimeZone.LONG ) );
 
-        if( m_servletContext != null )
-        {
-            log.info("Servlet container: "+m_servletContext.getServerInfo() );
-            if( m_servletContext.getMajorVersion() < 2 ||
-                (m_servletContext.getMajorVersion() == 2 && m_servletContext.getMinorVersion() < 4) )
-            {
-                throw new InternalWikiException("I require a container which supports at least version 2.4 of Servlet specification");
+        if( m_servletContext != null ) {
+            log.info( "Servlet container: " + m_servletContext.getServerInfo() );
+            if( m_servletContext.getMajorVersion() < 3 || ( m_servletContext.getMajorVersion() == 3 && m_servletContext.getMinorVersion() < 1 ) ) {
+                throw new InternalWikiException( "JSPWiki requires a container which supports at least version 3.1 of Servlet specification" );
             }
         }
 
-        log.debug("Configuring WikiEngine...");
+        log.debug( "Configuring WikiEngine..." );
 
         //  Initializes the CommandResolver
-        m_commandResolver  = new CommandResolver( this, props );
+        m_commandResolver = new CommandResolver( this, props );
 
-        //
         //  Create and find the default working directory.
-        //
         m_workDir = TextUtil.getStringProperty( props, PROP_WORKDIR, null );
 
         if( m_workDir == null ) {
@@ -512,10 +506,8 @@ public class WikiEngine  {
             m_internationalizationManager = ClassUtil.getMappedObject(InternationalizationManager.class.getName(),this);
             m_templateManager = ClassUtil.getMappedObject(TemplateManager.class.getName(), this, props );
 
-            // Since we want to use a page filters initilize() method
-            // as a engine startup listener where we can initialize global event listeners,
-            // it must be called lastly, so that all object references in the engine
-            // are availabe to the initialize() method
+            // Since we want to use a page filters initilize() method as a engine startup listener where we can initialize global event
+            // listeners, it must be called lastly, so that all object references in the engine are availabe to the initialize() method
             m_filterManager = ClassUtil.getMappedObject(FilterManager.class.getName(), this, props );
 
             m_adminBeanManager = ClassUtil.getMappedObject(AdminBeanManager.class.getName(),this);
@@ -523,19 +515,11 @@ public class WikiEngine  {
             // RenderingManager depends on FilterManager events.
             m_renderingManager.initialize( this, props );
 
-            //
-            //  ReferenceManager has the side effect of loading all
-            //  pages.  Therefore after this point, all page attributes
-            //  are available.
-            //
-            //  initReferenceManager is indirectly using m_filterManager, therefore
-            //  it has to be called after it was initialized.
-            //
+            //  ReferenceManager has the side effect of loading all pages.  Therefore after this point, all page attributes are available.
+            //  initReferenceManager is indirectly using m_filterManager, therefore it has to be called after it was initialized.
             initReferenceManager();
 
-            //
             //  Hook the different manager routines into the system.
-            //
             m_filterManager.addPageFilter(m_referenceManager, -1001 );
             m_filterManager.addPageFilter(m_searchManager, -1002 );
         } catch( final RuntimeException e ) {
@@ -645,15 +629,12 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the set of properties that the WikiEngine was initialized
-     *  with.  Note that this method returns a direct reference, so it's possible
-     *  to manipulate the properties.  However, this is not advised unless you
-     *  really know what you're doing.
+     *  Returns the set of properties that the WikiEngine was initialized with.  Note that this method returns a direct reference, so it's
+     *  possible to manipulate the properties.  However, this is not advised unless you really know what you're doing.
      *
      *  @return The wiki properties
      */
-    public Properties getWikiProperties()
-    {
+    public Properties getWikiProperties() {
         return m_properties;
     }
 


[jspwiki] 03/32: apply fixes and formatting suggested by IntelliJ

Posted by ju...@apache.org.
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 ddb2cdd94e9c856fa629e6ed23677dd83d4cb97d
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 18 00:21:02 2020 +0100

    apply fixes and formatting suggested by IntelliJ
---
 .../main/java/org/apache/wiki/rss/AtomFeed.java    | 109 +++------
 .../java/org/apache/wiki/rss/RSSGenerator.java     | 271 ++++++++-------------
 .../wiki/tasks/auth/SaveUserProfileTask.java       |  11 +-
 .../org/apache/wiki/xmlrpc/MetaWeblogHandler.java  | 205 ++++++----------
 4 files changed, 225 insertions(+), 371 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
index 3548c21..b8d7449 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
@@ -36,20 +36,17 @@ import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 
 /**
  *  Provides an Atom 1.0 standard feed, with enclosures.
  *
  */
-public class AtomFeed extends Feed
-{
+public class AtomFeed extends Feed {
+
     private Namespace m_atomNameSpace = Namespace.getNamespace("http://www.w3.org/2005/Atom");
 
-    /**
-     *  Defines a SimpleDateFormat string for RFC3339-formatted dates.
-     */
+    /** Defines a SimpleDateFormat string for RFC3339-formatted dates. */
     public static final String RFC3339FORMAT = "yyyy-MM-dd'T'HH:mm:ssZZ";
 
     /**
@@ -57,14 +54,13 @@ public class AtomFeed extends Feed
      *  
      *  @param c A WikiContext.
      */
-    public AtomFeed( WikiContext c )
+    public AtomFeed( final WikiContext c )
     {
         super(c);
     }
 
     /**
-     *   This is a bit complicated right now, as there is no proper metadata
-     *   store in JSPWiki.
+     *   This is a bit complicated right now, as there is no proper metadata store in JSPWiki.
      *
      *   @return An unique feed ID.
      */
@@ -73,53 +69,39 @@ public class AtomFeed extends Feed
         return m_wikiContext.getEngine().getBaseURL(); // FIXME: This is not a feed id
     }
 
-    private String getEntryID( Entry e )
+    private String getEntryID( final Entry e )
     {
         return e.getURL(); // FIXME: Not really a feed id!
     }
 
-    private Collection<Element> getItems()
-    {
-        ArrayList<Element> list = new ArrayList<>();
-
-        WikiEngine engine = m_wikiContext.getEngine();
+    private Collection<Element> getItems() {
+        final ArrayList< Element > list = new ArrayList<>();
+        final WikiEngine engine = m_wikiContext.getEngine();
         ServletContext servletContext = null;
-
-        if( m_wikiContext.getHttpRequest() != null )
+        if( m_wikiContext.getHttpRequest() != null ) {
             servletContext = m_wikiContext.getHttpRequest().getSession().getServletContext();
+        }
 
-        for( Entry e : m_entries ) {
-            WikiPage p = e.getPage();
-
-            Element entryEl = getElement( "entry" );
+        for( final Entry e : m_entries ) {
+            final WikiPage p = e.getPage();
+            final Element entryEl = getElement( "entry" );
 
-            //
             //  Mandatory elements
-            //
-
             entryEl.addContent( getElement( "id" ).setText( getEntryID( e ) ) );
             entryEl.addContent( getElement( "title" ).setAttribute( "type", "html" ).setText( e.getTitle() ) );
             entryEl.addContent( getElement( "updated" ).setText( DateFormatUtils.formatUTC( p.getLastModified(), RFC3339FORMAT ) ) );
-            //
-            //  Optional elements
-            //
 
+            //  Optional elements
             entryEl.addContent( getElement( "author" ).addContent( getElement( "name" ).setText( e.getAuthor() ) ) );
             entryEl.addContent( getElement( "link" ).setAttribute( "rel", "alternate" ).setAttribute( "href", e.getURL() ) );
             entryEl.addContent( getElement( "content" ).setAttribute( "type", "html" ).setText( e.getContent() ) );
 
-            //
             //  Check for enclosures
-            //
-
             if( engine.getAttachmentManager().hasAttachments( p ) && servletContext != null ) {
                 try {
-                    List<Attachment> c = engine.getAttachmentManager().listAttachments( p );
-
-                    for( Iterator<Attachment> a = c.iterator(); a.hasNext(); ) {
-                        Attachment att = a.next();
-
-                        Element attEl = getElement( "link" );
+                    final List< Attachment > c = engine.getAttachmentManager().listAttachments( p );
+                    for( final Attachment att : c ) {
+                        final Element attEl = getElement( "link" );
                         attEl.setAttribute( "rel", "enclosure" );
                         attEl.setAttribute( "href", engine.getURL( WikiContext.ATTACH, att.getName(), null, true ) );
                         attEl.setAttribute( "length", Long.toString( att.getSize() ) );
@@ -127,7 +109,7 @@ public class AtomFeed extends Feed
 
                         entryEl.addContent( attEl );
                     }
-                } catch( ProviderException ex ) {
+                } catch( final ProviderException ex ) {
                     // FIXME: log.info("Can't get attachment data",ex);
                 }
             }
@@ -142,73 +124,56 @@ public class AtomFeed extends Feed
      *  {@inheritDoc}
      */
     @Override
-    public String getString()
-    {
-        Element root = getElement("feed");
-        WikiEngine engine = m_wikiContext.getEngine();
+    public String getString() {
+        final Element root = getElement("feed");
+        final WikiEngine engine = m_wikiContext.getEngine();
 
         Date lastModified = new Date(0L);
 
-        for( Iterator< Entry > i = m_entries.iterator(); i.hasNext(); )
-        {
-            Entry e = i.next();
-
-            if( e.getPage().getLastModified().after(lastModified) )
+        for( final Entry e : m_entries ) {
+            if( e.getPage().getLastModified().after( lastModified ) )
                 lastModified = e.getPage().getLastModified();
         }
 
-        //
         //  Mandatory parts
-        //
         root.addContent( getElement("title").setText( getChannelTitle() ) );
         root.addContent( getElement("id").setText(getFeedID()) );
         root.addContent( getElement("updated").setText(DateFormatUtils.formatUTC( lastModified,
                                                                                   RFC3339FORMAT ) ));
 
-        //
         //  Optional
-        //
         // root.addContent( getElement("author").addContent(getElement("name").setText(format())))
         root.addContent( getElement("link").setAttribute("href",engine.getBaseURL()));
         root.addContent( getElement("generator").setText("JSPWiki "+Release.VERSTR));
 
-        String rssFeedURL  = engine.getURL(WikiContext.NONE, "rss.jsp",
-                                           "page="+engine.encodeName(m_wikiContext.getPage().getName())+
-                                           "&mode="+m_mode+
-                                           "&type=atom",
+        final String rssFeedURL  = engine.getURL(WikiContext.NONE, "rss.jsp",
+                                                 "page=" + engine.encodeName( m_wikiContext.getPage().getName() ) +
+                                                 "&mode=" + m_mode +
+                                                 "&type=atom",
                                            true );
-        Element self = getElement("link").setAttribute("rel","self");
-        self.setAttribute("href",rssFeedURL);
-        root.addContent(self);
+        final Element self = getElement( "link" ).setAttribute( "rel","self" );
+        self.setAttribute( "href", rssFeedURL );
+        root.addContent( self );
 
-        //
         //  Items
-        //
-
         root.addContent( getItems() );
 
-        //
         //  aaand output
-        //
-        XMLOutputter output = new XMLOutputter();
-
+        final XMLOutputter output = new XMLOutputter();
         output.setFormat( Format.getPrettyFormat() );
 
-        try
-        {
-            StringWriter res = new StringWriter();
+        try {
+            final StringWriter res = new StringWriter();
             output.output( root, res );
 
             return res.toString();
-        }
-        catch( IOException e )
-        {
+        } catch( final IOException e ) {
             return null;
         }
     }
 
-    private Element getElement( String name )
-    {
+    private Element getElement( final String name ) {
         return new Element( name, m_atomNameSpace );
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
index dfe9391..d48ea62 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
@@ -24,14 +24,11 @@ import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.WikiSession;
-import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
-import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.pages.PageTimeComparator;
 import org.apache.wiki.util.TextUtil;
 
-import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
@@ -40,8 +37,7 @@ import java.util.Set;
 /**
  *  The master class for generating different kinds of Feeds (including RSS1.0, 2.0 and Atom).
  *  <p>
- *  This class can produce quite a few different styles of feeds.  The following modes are
- *  available:
+ *  This class can produce quite a few different styles of feeds.  The following modes are available:
  *  
  *  <ul>
  *  <li><b>wiki</b> - All the changes to the given page are enumerated and announced as diffs.</li>
@@ -56,12 +52,12 @@ import java.util.Set;
 // FIXME3.0: This class would need a bit of refactoring.  Method names, e.g. are confusing.
 public class RSSGenerator {
 
-    static Logger              log = Logger.getLogger( RSSGenerator.class );
-    private WikiEngine         m_engine;
+    private static final Logger log = Logger.getLogger( RSSGenerator.class );
+    private WikiEngine m_engine;
 
-    private String             m_channelDescription = "";
-    private String             m_channelLanguage    = "en-us";
-    private boolean            m_enabled = true;
+    private String m_channelDescription = "";
+    private String m_channelLanguage = "en-us";
+    private boolean m_enabled = true;
 
     /** Parameter value to represent RSS 1.0 feeds.  Value is <tt>{@value}</tt>. */
     public static final String RSS10 = "rss10";
@@ -82,8 +78,7 @@ public class RSSGenerator {
     public static final String MODE_FULL = "full";
 
     /**
-     *  Defines the property name for the RSS channel description.  Default value for the
-     *  channel description is an empty string.
+     *  Defines the property name for the RSS channel description.  Default value for the channel description is an empty string.
      *  @since 1.7.6.
      */
     public static final String PROP_CHANNEL_DESCRIPTION = "jspwiki.rss.channelDescription";
@@ -92,48 +87,47 @@ public class RSSGenerator {
      *  Defines the property name for the RSS channel language.  Default value for the language is "en-us".
      *  @since 1.7.6.
      */
-    public static final String PROP_CHANNEL_LANGUAGE    = "jspwiki.rss.channelLanguage";
+    public static final String PROP_CHANNEL_LANGUAGE = "jspwiki.rss.channelLanguage";
 
     /** Defines the property name for the RSS channel title.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_CHANNEL_TITLE       = "jspwiki.rss.channelTitle";
+    public static final String PROP_CHANNEL_TITLE = "jspwiki.rss.channelTitle";
 
     /**
      *  Defines the property name for the RSS generator main switch.
      *  @since 1.7.6.
      */
-    public static final String PROP_GENERATE_RSS        = "jspwiki.rss.generate";
+    public static final String PROP_GENERATE_RSS = "jspwiki.rss.generate";
 
     /**
      *  Defines the property name for the RSS file that the wiki should generate.
      *  @since 1.7.6.
      */
-    public static final String PROP_RSSFILE             = "jspwiki.rss.fileName";
+    public static final String PROP_RSSFILE = "jspwiki.rss.fileName";
 
     /**
      *  Defines the property name for the RSS generation interval in seconds.
      *  @since 1.7.6.
      */
-    public static final String PROP_INTERVAL            = "jspwiki.rss.interval";
+    public static final String PROP_INTERVAL = "jspwiki.rss.interval";
 
     /** Defines the property name for the RSS author.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_RSS_AUTHOR          = "jspwiki.rss.author";
+    public static final String PROP_RSS_AUTHOR = "jspwiki.rss.author";
 
     /** Defines the property name for the RSS author email.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_RSS_AUTHOREMAIL     = "jspwiki.rss.author.email";
+    public static final String PROP_RSS_AUTHOREMAIL = "jspwiki.rss.author.email";
 
-    private static final int MAX_CHARACTERS             = Integer.MAX_VALUE-1;
+    private static final int MAX_CHARACTERS = Integer.MAX_VALUE-1;
 
     /**
      *  Initialize the RSS generator for a given WikiEngine.
      *
      *  @param engine The WikiEngine.
      *  @param properties The properties.
-     *  @throws NoRequiredPropertyException If something is missing from the given property set.
      */
-    public RSSGenerator( WikiEngine engine, Properties properties ) {
+    public RSSGenerator( final WikiEngine engine, final Properties properties ) {
         m_engine = engine;
         m_channelDescription = properties.getProperty( PROP_CHANNEL_DESCRIPTION, m_channelDescription );
-        m_channelLanguage    = properties.getProperty( PROP_CHANNEL_LANGUAGE, m_channelLanguage );
+        m_channelLanguage = properties.getProperty( PROP_CHANNEL_LANGUAGE, m_channelLanguage );
     }
 
     /**
@@ -143,8 +137,7 @@ public class RSSGenerator {
      *  @return A formatted string.
      */
     // FIXME: Replicates Feed.format().
-    public static String format( String s )
-    {
+    public static String format( String s ) {
         s = TextUtil.replaceString( s, "&", "&amp;" );
         s = TextUtil.replaceString( s, "<", "&lt;" );
         s = TextUtil.replaceString( s, "]]>", "]]&gt;" );
@@ -152,74 +145,60 @@ public class RSSGenerator {
         return s.trim();
     }
 
-    private String getAuthor( WikiPage page )
-    {
+    private String getAuthor( final WikiPage page ) {
         String author = page.getAuthor();
-
-        if( author == null ) author = "An unknown author";
+        if( author == null ) {
+            author = "An unknown author";
+        }
 
         return author;
     }
 
-    private String getAttachmentDescription( Attachment att )
-    {
-        String author = getAuthor(att);
-        StringBuilder sb = new StringBuilder();
+    private String getAttachmentDescription( final Attachment att ) {
+        final String author = getAuthor( att );
+        final StringBuilder sb = new StringBuilder();
 
-        if( att.getVersion() != 1 )
-        {
-            sb.append(author+" uploaded a new version of this attachment on "+att.getLastModified() );
-        }
-        else
-        {
-            sb.append(author+" created this attachment on "+att.getLastModified() );
+        if( att.getVersion() != 1 ) {
+            sb.append( author ).append( " uploaded a new version of this attachment on " ).append( att.getLastModified() );
+        } else {
+            sb.append( author ).append( " created this attachment on " ).append( att.getLastModified() );
         }
 
-        sb.append("<br /><hr /><br />");
-        sb.append( "Parent page: <a href=\""+
-                   m_engine.getURL( WikiContext.VIEW, att.getParentName(), null, true ) +
-                   "\">"+att.getParentName()+"</a><br />" );
-        sb.append( "Info page: <a href=\""+
-                   m_engine.getURL( WikiContext.INFO, att.getName(), null, true ) +
-                   "\">"+att.getName()+"</a>" );
+        sb.append( "<br /><hr /><br />" )
+          .append( "Parent page: <a href=\"" )
+          .append( m_engine.getURL( WikiContext.VIEW, att.getParentName(), null, true ) )
+          .append( "\">" ).append( att.getParentName() ).append( "</a><br />" )
+          .append( "Info page: <a href=\"" )
+          .append( m_engine.getURL( WikiContext.INFO, att.getName(), null, true ) )
+          .append( "\">" ).append( att.getName() ).append( "</a>" );
 
         return sb.toString();
     }
 
-    private String getPageDescription( WikiPage page )
-    {
-    	StringBuilder buf = new StringBuilder();
-        String author = getAuthor(page);
-
-        WikiContext ctx = new WikiContext( m_engine, page );
-        if( page.getVersion() > 1 )
-        {
-            String diff = m_engine.getDifferenceManager().getDiff( ctx,
-                                                          page.getVersion() - 1, // FIXME: Will fail when non-contiguous versions
-                                                                   page.getVersion() );
-
-            buf.append(author+" changed this page on "+page.getLastModified()+":<br /><hr /><br />" );
-            buf.append(diff);
-        }
-        else
-        {
-            buf.append(author+" created this page on "+page.getLastModified()+":<br /><hr /><br />" );
-            buf.append(m_engine.getRenderingManager().getHTML( page.getName() ));
+    private String getPageDescription( final WikiPage page ) {
+        final StringBuilder buf = new StringBuilder();
+        final String author = getAuthor( page );
+        final WikiContext ctx = new WikiContext( m_engine, page );
+        if( page.getVersion() > 1 ) {
+            final String diff = m_engine.getDifferenceManager().getDiff( ctx,
+                                                                page.getVersion() - 1, // FIXME: Will fail when non-contiguous versions
+                                                                         page.getVersion() );
+
+            buf.append( author ).append( " changed this page on " ).append( page.getLastModified() ).append( ":<br /><hr /><br />" );
+            buf.append( diff );
+        } else {
+            buf.append( author ).append( " created this page on " ).append( page.getLastModified() ).append( ":<br /><hr /><br />" );
+            buf.append( m_engine.getRenderingManager().getHTML( page.getName() ) );
         }
 
         return buf.toString();
     }
 
-    private String getEntryDescription( WikiPage page )
-    {
-        String res;
-
-        if( page instanceof Attachment )
-        {
+    private String getEntryDescription( final WikiPage page ) {
+        final String res;
+        if( page instanceof Attachment ) {
             res = getAttachmentDescription( (Attachment)page );
-        }
-        else
-        {
+        } else {
             res = getPageDescription( page );
         }
 
@@ -227,19 +206,18 @@ public class RSSGenerator {
     }
 
     // FIXME: This should probably return something more intelligent
-    private String getEntryTitle( WikiPage page )
+    private String getEntryTitle( final WikiPage page )
     {
-        return page.getName()+", version "+page.getVersion();
+        return page.getName() + ", version " + page.getVersion();
     }
 
     /**
-     *  Generates the RSS resource.  You probably want to output this
-     *  result into a file or something, or serve as output from a servlet.
+     *  Generates the RSS resource.  You probably want to output this result into a file or something, or serve as output from a servlet.
      *  
      *  @return A RSS 1.0 feed in the "full" mode.
      */
     public String generate() {
-        final WikiContext context = new WikiContext( m_engine,new WikiPage( m_engine, "__DUMMY" ) );
+        final WikiContext context = new WikiContext( m_engine, new WikiPage( m_engine, "__DUMMY" ) );
         context.setRequestContext( WikiContext.RSS );
         final Feed feed = new RSS10Feed( context );
         return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + generateFullWikiRSS( context, feed );
@@ -247,7 +225,8 @@ public class RSSGenerator {
 
     /**
      * Returns the content type of this RSS feed.
-     *  @since 2.3.15
+     *
+     * @since 2.3.15
      * @param mode the RSS mode: {@link #RSS10}, {@link #RSS20} or {@link #ATOM}.
      * @return the content type
      */
@@ -262,14 +241,13 @@ public class RSSGenerator {
     }
 
     /**
-     *  Generates a feed based on a context and list of changes.
+     * Generates a feed based on a context and list of changes.
+     *
      * @param wikiContext The WikiContext
      * @param changed A list of Entry objects
      * @param mode The mode (wiki/blog)
      * @param type The type (RSS10, RSS20, ATOM).  Default is RSS 1.0
      * @return Fully formed XML.
-     *
-     * @throws ProviderException If the underlying provider failed.
      * @throws IllegalArgumentException If an illegal mode is given.
      */
     public String generateFeed( final WikiContext wikiContext, final List< WikiPage > changed, final String mode, final String type ) throws IllegalArgumentException {
@@ -301,6 +279,7 @@ public class RSSGenerator {
 
     /**
      * Returns <code>true</code> if RSS generation is enabled.
+     *
      * @return whether RSS generation is currently enabled
      */
     public boolean isEnabled()
@@ -309,11 +288,9 @@ public class RSSGenerator {
     }
 
     /**
-     * Turns RSS generation on or off. This setting is used to set
-     * the "enabled" flag only for use by callers, and does not
-     * actually affect whether the {@link #generate()} or
-     * {@link #generateFeed(WikiContext, List, String, String)}
-     * methods output anything.
+     * Turns RSS generation on or off. This setting is used to set the "enabled" flag only for use by callers, and does not
+     * actually affect whether the {@link #generate()} or {@link #generateFeed(WikiContext, List, String, String)} methods output anything.
+     *
      * @param enabled whether RSS generation is considered enabled.
      */
     public synchronized void setEnabled( final boolean enabled )
@@ -339,12 +316,9 @@ public class RSSGenerator {
         final WikiSession session = WikiSession.guestSession( m_engine );
         int items = 0;
         for( final Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
-            WikiPage page = i.next();
+            final WikiPage page = i.next();
 
-            //
             //  Check if the anonymous user has view access to this page.
-            //
-
             if( !m_engine.getAuthorizationManager().checkPermission(session, new PagePermission(page,PagePermission.VIEW_ACTION) ) ) {
                 // No permission, skip to the next one.
                 continue;
@@ -371,64 +345,46 @@ public class RSSGenerator {
     }
 
     /**
-     *  Create RSS/Atom as if this page was a wikipage (in contrast to Blog mode).
+     * Create RSS/Atom as if this page was a wikipage (in contrast to Blog mode).
      *
      * @param wikiContext The WikiContext
      * @param changed A List of changed WikiPages.
      * @param feed A Feed object to fill.
      * @return the RSS representation of the wiki context
      */
-    protected String generateWikiPageRSS( WikiContext wikiContext, List< WikiPage > changed, Feed feed )
-    {
+    protected String generateWikiPageRSS( final WikiContext wikiContext, final List< WikiPage > changed, final Feed feed ) {
         feed.setChannelTitle( m_engine.getApplicationName()+": "+wikiContext.getPage().getName() );
         feed.setFeedURL( wikiContext.getViewURL( wikiContext.getPage().getName() ) );
-        String language = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
+        final String language = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
 
-        if( language != null )
+        if( language != null ) {
             feed.setChannelLanguage( language );
-        else
+        } else {
             feed.setChannelLanguage( m_channelLanguage );
+        }
+        final String channelDescription = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
 
-        String channelDescription = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
-
-        if( channelDescription != null )
-        {
+        if( channelDescription != null ) {
             feed.setChannelDescription( channelDescription );
         }
 
-        Collections.sort( changed, new PageTimeComparator() );
+        changed.sort( new PageTimeComparator() );
 
         int items = 0;
-        for( Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ )
-        {
-            WikiPage page = i.next();
-
-            Entry e = new Entry();
-
+        for( final Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
+            final WikiPage page = i.next();
+            final Entry e = new Entry();
             e.setPage( page );
-
             String url;
 
-            if( page instanceof Attachment )
-            {
-                url = m_engine.getURL( WikiContext.ATTACH,
-                                       page.getName(),
-                                       "version="+page.getVersion(),
-                                       true );
-            }
-            else
-            {
-                url = m_engine.getURL( WikiContext.VIEW,
-                                       page.getName(),
-                                       "version="+page.getVersion(),
-                                       true );
+            if( page instanceof Attachment ) {
+                url = m_engine.getURL( WikiContext.ATTACH, page.getName(), "version=" + page.getVersion(),true );
+            } else {
+                url = m_engine.getURL( WikiContext.VIEW, page.getName(), "version=" + page.getVersion(), true );
             }
 
-            // Unfortunately, this is needed because the code will again go through
-            // replacement conversion
-
+            // Unfortunately, this is needed because the code will again go through replacement conversion
             url = TextUtil.replaceString( url, "&amp;", "&" );
-
             e.setURL( url );
             e.setTitle( getEntryTitle(page) );
             e.setContent( getEntryDescription(page) );
@@ -446,18 +402,15 @@ public class RSSGenerator {
      *
      *  @param wikiContext The WikiContext, as usual.
      *  @param changed A list of the changed pages.
-     *  @param feed A valid Feed object.  The feed will be used to create the RSS/Atom, depending
-     *              on which kind of an object you want to put in it.
+     *  @param feed A valid Feed object.  The feed will be used to create the RSS/Atom, depending on which kind of an object you want to put in it.
      *  @return A String of valid RSS or Atom.
-     *  @throws ProviderException If reading of pages was not possible.
      */
-    protected String generateBlogRSS( WikiContext wikiContext, List< WikiPage > changed, Feed feed ) {
+    protected String generateBlogRSS( final WikiContext wikiContext, final List< WikiPage > changed, final Feed feed ) {
         if( log.isDebugEnabled() ) {
             log.debug( "Generating RSS for blog, size=" + changed.size() );
         }
 
-        String ctitle = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_TITLE );
-
+        final String ctitle = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_TITLE );
         if( ctitle != null ) {
             feed.setChannelTitle( ctitle );
         } else {
@@ -466,31 +419,26 @@ public class RSSGenerator {
 
         feed.setFeedURL( wikiContext.getViewURL( wikiContext.getPage().getName() ) );
 
-        String language = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
-
+        final String language = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
         if( language != null ) {
             feed.setChannelLanguage( language );
         } else {
             feed.setChannelLanguage( m_channelLanguage );
         }
 
-        String channelDescription = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
-
+        final String channelDescription = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
         if( channelDescription != null ) {
             feed.setChannelDescription( channelDescription );
         }
 
-        Collections.sort( changed, new PageTimeComparator() );
+        changed.sort( new PageTimeComparator() );
 
         int items = 0;
-        for( Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
-            WikiPage page = i.next();
-
-            Entry e = new Entry();
-
+        for( final Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
+            final WikiPage page = i.next();
+            final Entry e = new Entry();
             e.setPage( page );
-
-            String url;
+            final String url;
 
             if( page instanceof Attachment ) {
                 url = m_engine.getURL( WikiContext.ATTACH, page.getName(),null,true );
@@ -500,14 +448,11 @@ public class RSSGenerator {
 
             e.setURL( url );
 
-            //
             //  Title
-            //
-
-            String pageText = m_engine.getPageManager().getPureText(page.getName(), WikiProvider.LATEST_VERSION );
+            String pageText = m_engine.getPageManager().getPureText( page.getName(), WikiProvider.LATEST_VERSION );
 
             String title = "";
-            int firstLine = pageText.indexOf('\n');
+            final int firstLine = pageText.indexOf('\n');
 
             if( firstLine > 0 ) {
                 title = pageText.substring( 0, firstLine ).trim();
@@ -524,31 +469,21 @@ public class RSSGenerator {
 
             e.setTitle( title );
 
-            //
             //  Description
-            //
-
             if( firstLine > 0 ) {
                 int maxlen = pageText.length();
-                if( maxlen > MAX_CHARACTERS ) maxlen = MAX_CHARACTERS;
-
-                if( maxlen > 0 ) {
-                    pageText = m_engine.getRenderingManager().textToHTML( wikiContext, pageText.substring( firstLine + 1, maxlen ).trim() );
-
-                    if( maxlen == MAX_CHARACTERS ) {
-                        pageText += "...";
-                    }
-
-                    e.setContent( pageText );
-                } else {
-                    e.setContent( title );
+                if( maxlen > MAX_CHARACTERS ) {
+                    maxlen = MAX_CHARACTERS;
                 }
+                pageText = m_engine.getRenderingManager().textToHTML( wikiContext, pageText.substring( firstLine + 1, maxlen ).trim() );
+                if( maxlen == MAX_CHARACTERS ) {
+                    pageText += "...";
+                }
+                e.setContent( pageText );
             } else {
                 e.setContent( title );
             }
-
             e.setAuthor( getAuthor(page) );
-
             feed.addEntry( e );
         }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java b/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java
index 9a53bf8..7aee63c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java
@@ -1,10 +1,5 @@
 package org.apache.wiki.tasks.auth;
 
-import java.util.Locale;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.AddressException;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -17,6 +12,10 @@ import org.apache.wiki.workflow.Outcome;
 import org.apache.wiki.workflow.Task;
 import org.apache.wiki.workflow.WorkflowManager;
 
+import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
+import java.util.Locale;
+
 
 /**
  * Handles the actual profile save action. 
@@ -32,7 +31,7 @@ public class SaveUserProfileTask extends Task {
      * Constructs a new Task for saving a user profile.
      * @param engine the wiki engine
      */
-    public SaveUserProfileTask( WikiEngine engine, Locale loc ) {
+    public SaveUserProfileTask( final WikiEngine engine, final Locale loc ) {
         super( TasksManager.USER_PROFILE_SAVE_TASK_MESSAGE_KEY );
         m_engine = engine;
         m_loc = loc;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
index d2d8c80..bf2a206 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
@@ -51,17 +51,16 @@ import java.util.List;
  *  @since 2.1.7
  */
 
-public class MetaWeblogHandler
-    implements WikiRPCHandler
-{
-    private static Logger log = Logger.getLogger( MetaWeblogHandler.class );
+public class MetaWeblogHandler implements WikiRPCHandler {
+
+    private static final Logger log = Logger.getLogger( MetaWeblogHandler.class );
 
     private WikiContext m_context;
 
     /**
      *  {@inheritDoc}
      */
-    public void initialize( WikiContext context )
+    public void initialize( final WikiContext context )
     {
         m_context = context;
     }
@@ -73,36 +72,26 @@ public class MetaWeblogHandler
      *  <p>
      *  If there is no authentication enabled, returns normally.
      *
-     *  @throw XmlRpcException with the correct error message, if auth fails.
+     *  @throws XmlRpcException with the correct error message, if auth fails.
      */
-    private void checkPermissions( WikiPage page,
-                                   String username,
-                                   String password,
-                                   String permission )
-        throws XmlRpcException
-    {
-        try
-        {
-            AuthenticationManager amm = m_context.getEngine().getAuthenticationManager();
-            AuthorizationManager mgr = m_context.getEngine().getAuthorizationManager();
-
-            if( amm.login( m_context.getWikiSession(), m_context.getHttpRequest(), username, password ) )
-            {
-                if( !mgr.checkPermission( m_context.getWikiSession(), PermissionFactory.getPagePermission( page, permission ) ))
-                {
+    private void checkPermissions( final WikiPage page,
+                                   final String username,
+                                   final String password,
+                                   final String permission ) throws XmlRpcException {
+        try {
+            final AuthenticationManager amm = m_context.getEngine().getAuthenticationManager();
+            final AuthorizationManager mgr = m_context.getEngine().getAuthorizationManager();
+
+            if( amm.login( m_context.getWikiSession(), m_context.getHttpRequest(), username, password ) ) {
+                if( !mgr.checkPermission( m_context.getWikiSession(), PermissionFactory.getPagePermission( page, permission ) ) ) {
                     throw new XmlRpcException( 1, "No permission" );
                 }
-            }
-            else
-            {
+            } else {
                 throw new XmlRpcException( 1, "Unknown login" );
             }
-        }
-        catch( WikiSecurityException e )
-        {
+        } catch( final WikiSecurityException e ) {
             throw new XmlRpcException( 1, e.getMessage(), e );
         }
-        return;
     }
 
     /**
@@ -114,15 +103,13 @@ public class MetaWeblogHandler
      *  @throws XmlRpcException If something goes wrong
      *  @return An empty hashtable.
      */
-    public Hashtable getCategories( String blogid, String username, String password )  throws XmlRpcException {
+    public Hashtable< Object, Object > getCategories( final String blogid, final String username, final String password )  throws XmlRpcException {
         final WikiPage page = m_context.getEngine().getPageManager().getPage( blogid );
         checkPermissions( page, username, password, "view" );
-        final Hashtable ht = new Hashtable();
-
-        return ht;
+        return new Hashtable<>();
     }
 
-    private String getURL( String page ) {
+    private String getURL( final String page ) {
         return m_context.getEngine().getURL( WikiContext.VIEW, page,null, true ); // Force absolute urls
     }
 
@@ -132,21 +119,19 @@ public class MetaWeblogHandler
      *  @param page The actual entry page
      *  @return A metaWeblog entry struct.
      */
-    private Hashtable<String,Object> makeEntry( WikiPage page ) {
-        Hashtable<String, Object> ht = new Hashtable<>();
-
-        WikiPage firstVersion = m_context.getEngine().getPageManager().getPage( page.getName(), 1 );
-
-        ht.put("dateCreated", firstVersion.getLastModified());
-        ht.put("link", getURL(page.getName()));
-        ht.put("permaLink", getURL(page.getName()));
-        ht.put("postid", page.getName());
-        ht.put("userid", page.getAuthor());
+    private Hashtable< String,Object > makeEntry( final WikiPage page ) {
+        final WikiPage firstVersion = m_context.getEngine().getPageManager().getPage( page.getName(), 1 );
+        final Hashtable< String, Object > ht = new Hashtable<>();
+        ht.put( "dateCreated", firstVersion.getLastModified() );
+        ht.put( "link", getURL(page.getName() ) );
+        ht.put( "permaLink", getURL(page.getName() ) );
+        ht.put( "postid", page.getName() );
+        ht.put( "userid", page.getAuthor() );
 
         final String pageText = m_context.getEngine().getPageManager().getText(page.getName());
-        String title = "";
         final int firstLine = pageText.indexOf('\n');
 
+        String title = "";
         if( firstLine > 0 ) {
             title = pageText.substring( 0, firstLine );
         }
@@ -177,29 +162,22 @@ public class MetaWeblogHandler
      *  @return As per MetaweblogAPI specification
      */
     // FIXME: The implementation is suboptimal, as it goes through all of the blog entries.
-    public Hashtable getRecentPosts( String blogid, String username, String password, int numberOfPosts) throws XmlRpcException {
-        Hashtable<String, Hashtable<String, Object>> result = new Hashtable<>();
-
+    public Hashtable getRecentPosts( final String blogid, final String username, final String password, final int numberOfPosts ) throws XmlRpcException {
+        final Hashtable<String, Hashtable<String, Object>> result = new Hashtable<>();
         log.info( "metaWeblog.getRecentPosts() called");
-
-        WikiPage page = m_context.getEngine().getPageManager().getPage( blogid );
-
+        final WikiPage page = m_context.getEngine().getPageManager().getPage( blogid );
         checkPermissions( page, username, password, "view" );
 
         final WeblogPlugin plugin = new WeblogPlugin();
-        final List<WikiPage> changed = plugin.findBlogEntries( m_context.getEngine(), blogid, new Date( 0L ), new Date() );
-
+        final List< WikiPage > changed = plugin.findBlogEntries( m_context.getEngine(), blogid, new Date( 0L ), new Date() );
         changed.sort( new PageTimeComparator() );
 
         int items = 0;
-        for( Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < numberOfPosts; items++ )
-        {
-            WikiPage p = i.next();
-
+        for( final Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < numberOfPosts; items++ ) {
+            final WikiPage p = i.next();
             result.put( "entry", makeEntry( p ) );
         }
 
-
         return result;
     }
 
@@ -214,41 +192,32 @@ public class MetaWeblogHandler
      *  @return Returns an empty string
      *  @throws XmlRpcException If something goes wrong
      */
-    public String newPost( String blogid,
-                           String username,
-                           String password,
-                           Hashtable content,
-                           boolean publish )
-        throws XmlRpcException
-    {
+    public String newPost( final String blogid,
+                           final String username,
+                           final String password,
+                           final Hashtable< String, Object > content,
+                           final boolean publish ) throws XmlRpcException {
         log.info("metaWeblog.newPost() called");
-        WikiEngine engine = m_context.getEngine();
-
-        WikiPage page = engine.getPageManager().getPage( blogid );
+        final WikiEngine engine = m_context.getEngine();
+        final WikiPage page = engine.getPageManager().getPage( blogid );
         checkPermissions( page, username, password, "createPages" );
 
-        try
-        {
-            WeblogEntryPlugin plugin = new WeblogEntryPlugin();
-
-            String pageName = plugin.getNewEntryPage( engine, blogid );
-
-            WikiPage entryPage = new WikiPage( engine, pageName );
+        try {
+            final WeblogEntryPlugin plugin = new WeblogEntryPlugin();
+            final String pageName = plugin.getNewEntryPage( engine, blogid );
+            final WikiPage entryPage = new WikiPage( engine, pageName );
             entryPage.setAuthor( username );
 
-            WikiContext context = new WikiContext( engine, entryPage );
-
-            StringBuilder text = new StringBuilder();
-            text.append( "!"+content.get("title") );
+            final WikiContext context = new WikiContext( engine, entryPage );
+            final StringBuilder text = new StringBuilder();
+            text.append( "!" ).append( content.get( "title" ) );
             text.append( "\n\n" );
             text.append( content.get("description") );
 
             log.debug("Writing entry: "+text);
 
             engine.getPageManager().saveText( context, text.toString() );
-        }
-        catch( Exception e )
-        {
+        } catch( final Exception e ) {
             log.error("Failed to create weblog entry",e);
             throw new XmlRpcException( 0, "Failed to create weblog entry: "+e.getMessage() );
         }
@@ -267,29 +236,26 @@ public class MetaWeblogHandler
      *  @param content As per the MetaweblogAPI contract
      *  @return As per the MetaweblogAPI contract
      *  @throws XmlRpcException If something goes wrong
-     *
      */
-    public Hashtable newMediaObject( String blogid,
-                                     String username,
-                                     String password,
-                                     Hashtable content )
-        throws XmlRpcException
-    {
-        WikiEngine engine = m_context.getEngine();
-        String url = "";
+    public Hashtable< String, Object > newMediaObject( final String blogid,
+                                                       final String username,
+                                                       final String password,
+                                                       final Hashtable< String, Object > content ) throws XmlRpcException {
+        final WikiEngine engine = m_context.getEngine();
+        final String url;
 
-        log.info("metaWeblog.newMediaObject() called");
+        log.info( "metaWeblog.newMediaObject() called" );
 
-        WikiPage page = engine.getPageManager().getPage( blogid );
+        final WikiPage page = engine.getPageManager().getPage( blogid );
         checkPermissions( page, username, password, "upload" );
 
-        String name = (String) content.get( "name" );
-        byte[] data = (byte[]) content.get( "bits" );
+        final String name = (String) content.get( "name" );
+        final byte[] data = (byte[]) content.get( "bits" );
 
-        AttachmentManager attmgr = engine.getAttachmentManager();
+        final AttachmentManager attmgr = engine.getAttachmentManager();
 
         try {
-            Attachment att = new Attachment( engine, blogid, name );
+            final Attachment att = new Attachment( engine, blogid, name );
             att.setAuthor( username );
             attmgr.storeAttachment( att, new ByteArrayInputStream( data ) );
 
@@ -299,7 +265,7 @@ public class MetaWeblogHandler
             throw new XmlRpcException( 0, "Failed to upload media object: "+e.getMessage() );
         }
 
-        Hashtable<String, Object> result = new Hashtable<String, Object>();
+        final Hashtable< String, Object > result = new Hashtable<>();
         result.put("url", url);
 
         return result;
@@ -307,33 +273,28 @@ public class MetaWeblogHandler
 
 
     /**
-     *  Allows the user to edit a post.  It does not allow general
-     *   editability of wiki pages, because of the limitations of the
-     *  metaWeblog API.
+     *  Allows the user to edit a post.  It does not allow general editability of wiki pages, because of the limitations of the metaWeblog API.
      */
-    boolean editPost( String postid,
-                      String username,
-                      String password,
-                      Hashtable content,
-                      boolean publish )
-        throws XmlRpcException
-    {
-        WikiEngine engine = m_context.getEngine();
+    boolean editPost( final String postid,
+                      final String username,
+                      final String password,
+                      final Hashtable< String,Object > content,
+                      final boolean publish ) throws XmlRpcException {
+        final WikiEngine engine = m_context.getEngine();
         log.info("metaWeblog.editPost("+postid+") called");
 
         // FIXME: Is postid correct?  Should we determine it from the page name?
-        WikiPage page = engine.getPageManager().getPage( postid );
+        final WikiPage page = engine.getPageManager().getPage( postid );
         checkPermissions( page, username, password, "edit" );
 
-        try
-        {
-            WikiPage entryPage = (WikiPage)page.clone();
+        try {
+            final WikiPage entryPage = (WikiPage)page.clone();
             entryPage.setAuthor( username );
 
-            WikiContext context = new WikiContext( engine, entryPage );
+            final WikiContext context = new WikiContext( engine, entryPage );
 
-            StringBuilder text = new StringBuilder();
-            text.append( "!"+content.get("title") );
+            final StringBuilder text = new StringBuilder();
+            text.append( "!" ).append( content.get( "title" ) );
             text.append( "\n\n" );
             text.append( content.get("description") );
 
@@ -352,17 +313,11 @@ public class MetaWeblogHandler
      *  Gets the text of any page.  The title of the page is parsed
      *  (if any is provided).
      */
-    Hashtable getPost( String postid,
-                       String username,
-                       String password )
-        throws XmlRpcException
-    {
-        String wikiname = "FIXME";
-
-        WikiPage page = m_context.getEngine().getPageManager().getPage( wikiname );
-
+    Hashtable< String, Object > getPost( final String postid, final String username, final String password ) throws XmlRpcException {
+        final String wikiname = "FIXME";
+        final WikiPage page = m_context.getEngine().getPageManager().getPage( wikiname );
         checkPermissions( page, username, password, "view" );
-
         return makeEntry( page );
     }
+
 }


[jspwiki] 05/32: add synchronization to ajaxServlets on WikiAjaxDispatcherServlet + apply intellij's suggested format

Posted by ju...@apache.org.
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 d9ad1ac1e570974bcc494098cc71baa69fdb6cd5
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 18 15:28:54 2020 +0100

    add synchronization to ajaxServlets on WikiAjaxDispatcherServlet + apply intellij's suggested format
---
 .../wiki/ajax/WikiAjaxDispatcherServlet.java       | 123 +++++++++++----------
 1 file changed, 62 insertions(+), 61 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
index 88bcbf1..41d11ba 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
@@ -36,9 +36,10 @@ import java.io.IOException;
 import java.security.Permission;
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 
 /**
  * This provides a simple ajax servlet for handling /ajax/<ClassName> requests.
@@ -47,9 +48,10 @@ import java.util.Map;
  * @since 2.10.2-svn12
  */
 public class WikiAjaxDispatcherServlet extends HttpServlet {
+
     private static final long serialVersionUID = 1L;
-    private static Map<String,AjaxServletContainer> ajaxServlets = new HashMap<String,AjaxServletContainer>();
-    static final Logger log = Logger.getLogger(WikiAjaxDispatcherServlet.class.getName());
+    private static final Map< String, AjaxServletContainer > ajaxServlets = new ConcurrentHashMap<>();
+    private static final Logger log = Logger.getLogger( WikiAjaxDispatcherServlet.class.getName() );
     private String PATH_AJAX = "/ajax/";
     private WikiEngine m_engine;
 
@@ -60,95 +62,92 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
      * Note: Do not change this without also changing the web.xml file.
      */
     @Override
-    public void init(ServletConfig config)
-            throws ServletException {
-        super.init(config);
-        m_engine = WikiEngine.getInstance(config);
-        PATH_AJAX = "/"+TextUtil.getStringProperty(m_engine.getWikiProperties(), "jspwiki.ajax.url.prefix", "ajax")+"/";
-        log.info("WikiAjaxDispatcherServlet initialized.");
+    public void init( final ServletConfig config ) throws ServletException {
+        super.init( config );
+        m_engine = WikiEngine.getInstance( config );
+        PATH_AJAX = "/"+TextUtil.getStringProperty( m_engine.getWikiProperties(), "jspwiki.ajax.url.prefix", "ajax" ) + "/";
+        log.info( "WikiAjaxDispatcherServlet initialized." );
     }
 
     /**
      * Register a {@link WikiAjaxServlet} using the servlet mapping as the alias
      */
-    public static void registerServlet(WikiAjaxServlet servlet) {
-        registerServlet(servlet.getServletMapping(),servlet);
+    public static void registerServlet( final WikiAjaxServlet servlet ) {
+        registerServlet( servlet.getServletMapping(), servlet );
     }
 
     /**
      * Register a {@link WikiAjaxServlet} with a specific alias, and default permission {@link PagePermission#VIEW}.
      */
-    public static void registerServlet(String alias, WikiAjaxServlet servlet) {
-        registerServlet(alias, servlet, PagePermission.VIEW);
+    public static void registerServlet( final String alias, final WikiAjaxServlet servlet ) {
+        registerServlet( alias, servlet, PagePermission.VIEW );
     }
 
     /**
      * Regster a {@link WikiAjaxServlet} given an alias, the servlet, and the permission.
      * This creates a temporary bundle object called {@link WikiAjaxDispatcherServlet.AjaxServletContainer}
+     *
      * @param alias the uri link to this servlet
      * @param servlet the servlet being registered
      * @param perm the permission required to execute the servlet.
      */
-    public static void registerServlet(String alias, WikiAjaxServlet servlet, Permission perm) {
-        log.info("WikiAjaxDispatcherServlet registering "+alias+"="+servlet+" perm="+perm);
-        ajaxServlets.put(alias,new AjaxServletContainer(alias, servlet, perm));
+    public static void registerServlet( final String alias, final WikiAjaxServlet servlet, final Permission perm ) {
+        log.info( "WikiAjaxDispatcherServlet registering " + alias + "=" + servlet + " perm=" + perm );
+        ajaxServlets.put( alias, new AjaxServletContainer( alias, servlet, perm ) );
     }
 
     /**
      * Calls {@link #performAction}
      */
     @Override
-    public void doPost(HttpServletRequest req, HttpServletResponse res)
-            throws IOException, ServletException {
-        performAction(req,res);
+    public void doPost( final HttpServletRequest req, final HttpServletResponse res ) throws IOException, ServletException {
+        performAction( req, res );
     }
 
     /**
      * Calls {@link #performAction}
      */
     @Override
-    public void doGet(HttpServletRequest req, HttpServletResponse res)
-            throws IOException, ServletException {
-        performAction(req,res);
+    public void doGet( final HttpServletRequest req, final HttpServletResponse res ) throws IOException, ServletException {
+        performAction( req, res );
     }
 
     /**
-     * The main method which get the requestURI "/ajax/<ServletName>", gets the
-     * {@link #getServletName} and finds the servlet using {@link #findServletByName}.
-     * It then calls {@link WikiAjaxServlet#service} method.
+     * The main method which get the requestURI "/ajax/<ServletName>", gets the {@link #getServletName} and finds the servlet using
+     * {@link #findServletByName}. It then calls {@link WikiAjaxServlet#service} method.
+     *
      * @param req the inbound request
      * @param res the outbound response
-     * @throws IOException
+     * @throws IOException if WikiEngine's content encoding is valid
      * @throws ServletException if no registered servlet can be found
      */
     private void performAction( final HttpServletRequest req, final HttpServletResponse res ) throws IOException, ServletException {
         final String path = req.getRequestURI();
-        final String servletName = getServletName(path);
-        if (servletName!=null) {
-            final AjaxServletContainer container = findServletContainer(servletName);
-            if (container != null) {
+        final String servletName = getServletName( path );
+        if( servletName != null) {
+            final AjaxServletContainer container = findServletContainer( servletName );
+            if( container != null ) {
                 final WikiAjaxServlet servlet = container.servlet;
-                if ( validatePermission(req,container) ) {
-                    req.setCharacterEncoding(m_engine.getContentEncoding().displayName());
-                    res.setCharacterEncoding(m_engine.getContentEncoding().displayName());
-                    final String actionName = AjaxUtil.getNextPathPart(req.getRequestURI(), servlet.getServletMapping());
-                    log.debug("actionName="+actionName);
-                    final Object params = req.getParameter("params");
-                    log.debug("params="+params);
-                    List<String> paramValues = new ArrayList<>();
-                    if (params instanceof String) {
-                        final String paramString = (String)params;
-                        if (StringUtils.isNotBlank(paramString)) {
-                            paramValues = Arrays.asList(paramString.trim().split(","));
+                if ( validatePermission( req, container ) ) {
+                    req.setCharacterEncoding( m_engine.getContentEncoding().displayName() );
+                    res.setCharacterEncoding( m_engine.getContentEncoding().displayName() );
+                    final String actionName = AjaxUtil.getNextPathPart( req.getRequestURI(), servlet.getServletMapping() );
+                    log.debug( "actionName=" + actionName );
+                    final String params = req.getParameter( "params" );
+                    log.debug( "params=" + params );
+                    List< String > paramValues = new ArrayList<>();
+                    if( params != null ) {
+                        if( StringUtils.isNotBlank( params ) ) {
+                            paramValues = Arrays.asList( params.trim().split( "," ) );
                         }
                     }
-                    servlet.service(req, res, actionName, paramValues);
+                    servlet.service( req, res, actionName, paramValues );
                 } else {
-                    log.warn("Servlet container "+container+" not authorised. Permission required.");
+                    log.warn( "Servlet container " + container + " not authorised. Permission required." );
                 }
             } else {
-                log.error("No registered class for servletName=" + servletName + " in path=" + path);
-                throw new ServletException("No registered class for servletName=" + servletName);
+                log.error( "No registered class for servletName=" + servletName + " in path=" + path );
+                throw new ServletException( "No registered class for servletName=" + servletName );
             }
         }
     }
@@ -160,11 +159,11 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
      * @param container the container info of the servlet
      * @return true if permission is valid
      */
-    private boolean validatePermission(HttpServletRequest req, AjaxServletContainer container) {
+    private boolean validatePermission( final HttpServletRequest req, final AjaxServletContainer container ) {
         final WikiEngine e = WikiEngine.getInstance(req.getSession().getServletContext(), null);
         boolean valid = false;
-        if (container != null) {
-            valid = e.getAuthorizationManager().checkPermission(WikiSession.getWikiSession(e, req), container.permission);
+        if( container != null ) {
+            valid = e.getAuthorizationManager().checkPermission( WikiSession.getWikiSession( e, req ), container.permission );
         }
         return valid;
     }
@@ -176,8 +175,8 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
      * @return The ServletName for the requestURI, or null
      * @throws ServletException if the path is invalid
      */
-    public String getServletName(String path) throws ServletException {
-        return AjaxUtil.getNextPathPart(path, PATH_AJAX);
+    public String getServletName( final String path ) throws ServletException {
+        return AjaxUtil.getNextPathPart( path, PATH_AJAX );
     }
 
     /**
@@ -186,8 +185,8 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
      * @param servletAlias the name of the servlet from {@link #getServletName}
      * @return The first servlet found, or null.
      */
-    private AjaxServletContainer findServletContainer(String servletAlias) {
-        return ajaxServlets.get(servletAlias);
+    private AjaxServletContainer findServletContainer( final String servletAlias ) {
+        return ajaxServlets.get( servletAlias );
     }
 
     /**
@@ -196,20 +195,21 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
      * @param servletAlias the value provided to {@link #registerServlet}
      * @return the {@link WikiAjaxServlet} given the servletAlias that it was registered with.
      */
-    public WikiAjaxServlet findServletByName(String servletAlias) {
-        final AjaxServletContainer container = ajaxServlets.get(servletAlias);
-        if (container != null) {
+    public WikiAjaxServlet findServletByName( final String servletAlias ) {
+        final AjaxServletContainer container = ajaxServlets.get( servletAlias );
+        if( container != null ) {
             return container.servlet;
         }
         return null;
     }
 
     private static class AjaxServletContainer {
-        String alias;
-        WikiAjaxServlet servlet;
-        Permission permission;
 
-        public AjaxServletContainer(String alias, WikiAjaxServlet servlet, Permission permission) {
+        final String alias;
+        final WikiAjaxServlet servlet;
+        final Permission permission;
+
+        public AjaxServletContainer( final String alias, final WikiAjaxServlet servlet, final Permission permission ) {
             this.alias = alias;
             this.servlet = servlet;
             this.permission = permission;
@@ -217,8 +217,9 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
 
         @Override
         public String toString() {
-            return getClass().getSimpleName()+" "+alias+"="+servlet.getClass().getSimpleName()+" permission="+permission;
+            return getClass().getSimpleName() + " " + alias + "=" + servlet.getClass().getSimpleName() + " permission=" + permission;
         }
+
     }
 
 }