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/09 22:17:10 UTC

[jspwiki] branch master updated (9e05cc5 -> c9bc3c7)

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 9e05cc5  2.11.0-M7-git-03
     new 1ec1151  JSPWIKI-120: move deletePage(..) and deleteVersion(..) methods from WikiEngine to PageManager
     new fcd0f5d  JSPWIKI-120: getCurrentProvider() moved from WikiEngine to PageManager; getCurrentProviderInfo deleted from WikiEngine - use PageManager.getProviderDescription() instead
     new 46b7e97  JSPWIKI-120: removed getPageCount from WikiEngine - use PageManager.getTotalPageCount instead
     new 27d799e  apply formats and fixes suggested by IntelliJ
     new 1630b75  apply formats and fixes suggested by IntelliJ
     new f917189  add missing package.html
     new 94d4598  JSPWIKI-120: getPage( String ) and getPage( String, int ) methods from WikiEngine moved to PageManager
     new 0280063  include missing jspwiki.basicAttachmentProvider.storageDir, used on some tests
     new 3a4c6a5  Improvements on TestEngine
     new 54814dc  clean up + simplify tests
     new 8081873  JSPWIKI-120: move getPureText methods to PageManager
     new 99c5c7d  '<init>' is not a valid dir name, so we replace it with 'init'
     new 4932569  JSPWIKI-120: use getPureText from PageManager
     new d7dd21d  take into account executions on Windows boxes can have both / and \
     new f41a539  simplify test a tiny bit
     new 686c57a  JSPWIKI-120: move getRecentChanges from WikiEngine to PageManager
     new 806fc47  JSPWIKI-120: move getVersionHistory from WikiEngine into same method in PageManager
     new a64c5a5  make casting unnecessary when calling WikiEngine#getAttribute()
     new be8e23f  WikiEngine#getPluginManager() and WikiEngine#getFilterManager() now only return their associated interface
     new 4cb064d  JSPWIKI-120: move getText(..) methods from WikiEngine to PageManager
     new 7a5fbbd  fix JSP compilation error
     new 74e8560  JSPWIKI-120: move pageExist(..) methods to PageManager, renamed as wikiPageExist(..)
     new 86778fd  rename WorkflowManager as DefaultWorkflowManager and extract interface (WorkflowManager) from it
     new 27f6209  remove getEngine from PageManager, you should already have access to it if you've grabbed the PageManager
     new 2bac2a4  explicit casting on WikiPage#getAttribute() can be removed in most cases now
     new d65ebff  revert change on previous commits: PageManager and WorkflowManager must extend WikiEventListener
     new 7a70566  apply format and fixes suggested by IntelliJ to WikiEngine
     new bdcfef8  fix test compilation error
     new 28c2daf  JSPWIKI-120: move saveText from WikiEngine to PageManager
     new 5e84989  remove FIXME tag - actually done! :-)
     new 2297125  apply format and fixes suggested by IntelliJ
     new c9bc3c7  2.11.0-M7-git-04

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                                       |  25 +
 .../src/main/java/org/apache/wiki/Release.java     |   2 +-
 .../src/main/java/org/apache/wiki/WikiContext.java |  51 +-
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 843 ++++-----------------
 .../src/main/java/org/apache/wiki/WikiPage.java    |  14 +-
 .../main/java/org/apache/wiki/WikiProvider.java    |   3 +-
 .../src/main/java/org/apache/wiki/WikiServlet.java |  24 +-
 .../src/main/java/org/apache/wiki/WikiSession.java | 603 ++++++---------
 .../apache/wiki/attachment/AttachmentManager.java  |  38 +-
 .../org/apache/wiki/auth/AuthorizationManager.java |   2 +-
 .../apache/wiki/auth/acl/DefaultAclManager.java    |  60 +-
 .../apache/wiki/content/DefaultPageRenamer.java    |  16 +-
 .../apache/wiki/diff/DefaultDifferenceManager.java |   4 +-
 .../org/apache/wiki/event/WikiEventListener.java   |   9 +-
 .../java/org/apache/wiki/filters/SpamFilter.java   |  60 +-
 .../org/apache/wiki/pages/DefaultPageManager.java  | 493 ++++++++----
 .../main/java/org/apache/wiki/pages/PageLock.java  |  19 +-
 .../java/org/apache/wiki/pages/PageManager.java    | 257 +++++--
 .../java/org/apache/wiki/pages/PageSorter.java     |  37 +-
 .../org/apache/wiki/pages/PageTimeComparator.java  |   6 +-
 .../main/java/org/apache/wiki/pages}/package.html  |   4 +-
 .../apache/wiki/parser/JSPWikiMarkupParser.java    |  17 +-
 .../java/org/apache/wiki/parser/MarkupParser.java  |  22 +-
 .../apache/wiki/plugin/AbstractReferralPlugin.java |   2 +-
 .../org/apache/wiki/plugin/BugReportHandler.java   | 224 +++---
 .../main/java/org/apache/wiki/plugin/Counter.java  |  66 +-
 .../main/java/org/apache/wiki/plugin/IfPlugin.java | 133 ++--
 .../java/org/apache/wiki/plugin/InsertPage.java    |  48 +-
 .../apache/wiki/plugin/RecentChangesPlugin.java    |   8 +-
 .../apache/wiki/plugin/ReferredPagesPlugin.java    | 150 ++--
 .../apache/wiki/plugin/ReferringPagesPlugin.java   |   2 +-
 .../org/apache/wiki/plugin/TableOfContents.java    |  27 +-
 .../org/apache/wiki/plugin/WeblogEntryPlugin.java  | 100 +--
 .../java/org/apache/wiki/plugin/WeblogPlugin.java  |  14 +-
 .../wiki/providers/BasicAttachmentProvider.java    |   2 +-
 .../apache/wiki/providers/FileSystemProvider.java  |  12 +-
 .../wiki/providers/VersioningFileProvider.java     |   2 +-
 .../wiki/references/DefaultReferenceManager.java   |  10 +-
 .../org/apache/wiki/rpc/atom/AtomAPIServlet.java   |  63 +-
 .../java/org/apache/wiki/rss/RSSGenerator.java     |  41 +-
 .../apache/wiki/search/LuceneSearchProvider.java   |   4 +-
 .../java/org/apache/wiki/search/SearchManager.java |  37 +-
 .../apache/wiki/tags/AttachmentsIteratorTag.java   |  97 +--
 .../main/java/org/apache/wiki/tags/AuthorTag.java  |  47 +-
 .../java/org/apache/wiki/tags/BreadcrumbsTag.java  |   8 +-
 .../java/org/apache/wiki/tags/CalendarTag.java     |   2 +-
 .../java/org/apache/wiki/tags/CheckVersionTag.java |  90 +--
 .../java/org/apache/wiki/tags/DiffLinkTag.java     | 103 +--
 .../java/org/apache/wiki/tags/EditLinkTag.java     |   8 +-
 .../org/apache/wiki/tags/HasAttachmentsTag.java    |  28 +-
 .../org/apache/wiki/tags/HistoryIteratorTag.java   |  81 +-
 .../java/org/apache/wiki/tags/InsertDiffTag.java   |   2 +-
 .../java/org/apache/wiki/tags/InsertPageTag.java   |  61 +-
 .../main/java/org/apache/wiki/tags/LinkTag.java    |  27 +-
 .../java/org/apache/wiki/tags/NoSuchPageTag.java   |  37 +-
 .../java/org/apache/wiki/tags/PageInfoLinkTag.java |  57 +-
 .../java/org/apache/wiki/tags/PageSizeTag.java     |  33 +-
 .../java/org/apache/wiki/tags/PermissionTag.java   | 103 +--
 .../java/org/apache/wiki/tags/WikiTagBase.java     |  68 +-
 .../java/org/apache/wiki/tasks/TasksManager.java   |   9 +-
 .../apache/wiki/tasks/pages/SaveWikiPageTask.java  |   2 +-
 .../java/org/apache/wiki/ui/CommandResolver.java   |   2 +-
 .../org/apache/wiki/ui/admin/beans/CoreBean.java   |  21 +-
 .../wiki/variables/DefaultVariableManager.java     |  12 +-
 .../wiki/workflow/DefaultWorkflowManager.java      | 259 +++++++
 .../org/apache/wiki/workflow/WorkflowManager.java  | 316 ++------
 .../org/apache/wiki/xmlrpc/AbstractRPCHandler.java |  66 +-
 .../org/apache/wiki/xmlrpc/MetaWeblogHandler.java  |  55 +-
 .../java/org/apache/wiki/xmlrpc/RPCHandler.java    | 144 ++--
 .../org/apache/wiki/xmlrpc/RPCHandlerUTF8.java     | 187 ++---
 .../src/main/resources/ini/classmappings.xml       |   2 +-
 .../src/test/java/org/apache/wiki/TestEngine.java  | 134 ++--
 .../test/java/org/apache/wiki/WikiEngineTest.java  | 677 +++--------------
 .../wiki/attachment/AttachmentManagerTest.java     |  31 +-
 .../apache/wiki/auth/AuthorizationManagerTest.java |  18 +-
 .../java/org/apache/wiki/auth/UserManagerTest.java |  16 +-
 .../wiki/auth/acl/DefaultAclManagerTest.java       |  37 +-
 .../org/apache/wiki/content/PageRenamerTest.java   |  58 +-
 .../apache/wiki/pages/DefaultPageManagerTest.java  | 299 +++++++-
 .../wiki/plugin/DefaultPluginManagerTest.java      | 171 ++---
 .../java/org/apache/wiki/plugin/GroupsTest.java    |  21 +-
 .../java/org/apache/wiki/plugin/IfPluginTest.java  |  31 +-
 .../org/apache/wiki/plugin/PageViewPluginTest.java |  33 +-
 .../apache/wiki/plugin/TableOfContentsTest.java    |  17 +-
 .../org/apache/wiki/plugin/WeblogPluginTest.java   |  13 +-
 .../apache/wiki/providers/CachingProviderTest.java |  30 +-
 .../wiki/providers/FileSystemProviderTest.java     |  16 +-
 .../wiki/providers/VersioningFileProviderTest.java | 154 ++--
 .../wiki/references/ReferenceManagerTest.java      |   2 +-
 .../apache/wiki/render/RenderingManagerTest.java   |  36 +-
 .../java/org/apache/wiki/rss/RSSGeneratorTest.java |  29 +-
 .../org/apache/wiki/search/SearchManagerTest.java  |   8 +-
 .../apache/wiki/stress/MassiveRepositoryTest.java  |  23 +-
 .../wiki/stress/StressTestVersioningProvider.java  |  28 +-
 .../org/apache/wiki/ui/CommandResolverTest.java    |   6 +-
 .../java/org/apache/wiki/ui/PageCommandTest.java   |   2 +-
 .../apache/wiki/workflow/ApprovalWorkflowTest.java |  25 +-
 .../org/apache/wiki/workflow/WorkflowTest.java     |  10 +-
 .../org/apache/wiki/xmlrpc/RPCHandlerTest.java     |  19 +-
 .../test/resources/jspwiki-vers-custom.properties  |   7 +-
 .../apache/wiki/render/MarkdownRendererTest.java   |  19 +-
 jspwiki-war/src/main/webapp/Comment.jsp            | 114 +--
 jspwiki-war/src/main/webapp/Delete.jsp             |   8 +-
 jspwiki-war/src/main/webapp/Edit.jsp               | 113 +--
 jspwiki-war/src/main/webapp/Login.jsp              |   3 +-
 jspwiki-war/src/main/webapp/PageModified.jsp       |   2 +-
 jspwiki-war/src/main/webapp/UserPreferences.jsp    |   4 +-
 jspwiki-war/src/main/webapp/rss.jsp                |   9 +-
 .../src/main/webapp/templates/210/DiffTab.jsp      |   2 +-
 .../src/main/webapp/templates/210/InfoContent.jsp  |   2 +-
 .../src/main/webapp/templates/210/PageTab.jsp      |   2 +-
 .../main/webapp/templates/210/editors/CKeditor.jsp |   6 +-
 .../src/main/webapp/templates/210/editors/FCK.jsp  |   6 +-
 .../main/webapp/templates/210/editors/TinyMCE.jsp  |   6 +-
 .../main/webapp/templates/210/editors/plain.jsp    |   6 +-
 .../main/webapp/templates/210/editors/wysiwyg.jsp  |   6 +-
 .../src/main/webapp/templates/default/DiffTab.jsp  |   2 +-
 .../main/webapp/templates/default/InfoContent.jsp  |   2 +-
 .../src/main/webapp/templates/default/Nav.jsp      |   2 +-
 .../src/main/webapp/templates/default/PageTab.jsp  |   2 +-
 .../src/main/webapp/templates/default/Sidebar.jsp  |   2 +-
 .../webapp/templates/default/editors/CKeditor.jsp  |   6 +-
 .../webapp/templates/default/editors/TinyMCE.jsp   |   6 +-
 .../webapp/templates/default/editors/plain.jsp     |   6 +-
 .../webapp/templates/default/editors/wysiwyg.jsp   |   6 +-
 125 files changed, 3206 insertions(+), 4568 deletions(-)
 copy {jspwiki-it-tests/jspwiki-selenide-tests/src/main/java/org/apache/wiki/its => jspwiki-main/src/main/java/org/apache/wiki/pages}/package.html (91%)
 create mode 100644 jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java


[jspwiki] 29/32: JSPWIKI-120: move saveText from WikiEngine to PageManager

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 28c2dafcb3558dce5b38db81062a2aa55392446e
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 9 21:07:24 2020 +0100

    JSPWIKI-120: move saveText from WikiEngine to PageManager
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  63 +--------
 .../org/apache/wiki/pages/DefaultPageManager.java  |  58 +++++++-
 .../java/org/apache/wiki/pages/PageManager.java    |  20 +++
 .../org/apache/wiki/plugin/BugReportHandler.java   |   2 +-
 .../org/apache/wiki/rpc/atom/AtomAPIServlet.java   |  31 ++---
 .../org/apache/wiki/xmlrpc/MetaWeblogHandler.java  |  23 +---
 .../src/test/java/org/apache/wiki/TestEngine.java  |   4 +-
 .../test/java/org/apache/wiki/WikiEngineTest.java  |   4 +-
 .../wiki/plugin/DefaultPluginManagerTest.java      | 150 ++++++---------------
 .../wiki/providers/VersioningFileProviderTest.java |  12 +-
 .../org/apache/wiki/search/SearchManagerTest.java  |   8 +-
 jspwiki-war/src/main/webapp/Comment.jsp            | 110 ++++++---------
 jspwiki-war/src/main/webapp/Edit.jsp               | 109 +++++----------
 .../src/main/webapp/templates/default/Sidebar.jsp  |   2 +-
 14 files changed, 225 insertions(+), 371 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 2e0a0bf..0cae15a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -753,6 +753,7 @@ 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 );
     }
 
@@ -1172,68 +1173,6 @@ public class WikiEngine  {
     }
 
     /**
-     *  Writes the WikiText of a page into the page repository. If the <code>jspwiki.properties</code> file contains
-     *  the property <code>jspwiki.approver.workflow.saveWikiPage</code> and its value resolves to a valid user,
-     *  {@link org.apache.wiki.auth.authorize.Group} or {@link org.apache.wiki.auth.authorize.Role}, this method will
-     *  place a {@link org.apache.wiki.workflow.Decision} in the approver's workflow inbox and throw a
-     *  {@link org.apache.wiki.workflow.DecisionRequiredException}. If the submitting user is authenticated and the
-     *  page save is rejected, a notification will be placed in the user's decision queue.
-     *
-     *  @since 2.1.28
-     *  @param context The current WikiContext
-     *  @param text    The Wiki markup for the page.
-     *  @throws WikiException if the save operation encounters an error during the save operation. If the page-save
-     *  operation requires approval, the exception will be of type {@link org.apache.wiki.workflow.DecisionRequiredException}.
-     *  Individual PageFilters, such as the {@link org.apache.wiki.filters.SpamFilter} may also throw a
-     *  {@link org.apache.wiki.api.exceptions.RedirectException}.
-     */
-    public void saveText( final WikiContext context, final String text ) throws WikiException {
-        // Check if page data actually changed; bail if not
-        final WikiPage page = context.getPage();
-        final String oldText = getPageManager().getPureText( page );
-        final String proposedText = TextUtil.normalizePostData( text );
-        if ( oldText != null && oldText.equals( proposedText ) ) {
-            return;
-        }
-
-        // Check if creation of empty pages is allowed; bail if not
-        final boolean allowEmpty = TextUtil.getBooleanProperty( m_properties, PROP_ALLOW_CREATION_OF_EMPTY_PAGES, false );
-        if ( !allowEmpty && !m_pageManager.wikiPageExists( page ) && text.trim().equals( "" ) ) {
-            return;
-        }
-
-        // Create approval workflow for page save; add the diffed, proposed and old text versions as
-        // Facts for the approver (if approval is required). If submitter is authenticated, any reject
-        // messages will appear in his/her workflow inbox.
-        final WorkflowBuilder builder = WorkflowBuilder.getBuilder( this );
-        final Principal submitter = context.getCurrentUser();
-        final Step prepTask = m_tasksManager.buildPreSaveWikiPageTask( context, proposedText );
-        final Step completionTask = m_tasksManager.buildSaveWikiPageTask();
-        final String diffText = m_differenceManager.makeDiff( context, oldText, proposedText );
-        final boolean isAuthenticated = context.getWikiSession().isAuthenticated();
-        final Fact[] facts = new Fact[ 5 ];
-        facts[ 0 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_PAGE_NAME, page.getName() );
-        facts[ 1 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_DIFF_TEXT, diffText );
-        facts[ 2 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_PROPOSED_TEXT, proposedText );
-        facts[ 3 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_CURRENT_TEXT, oldText);
-        facts[ 4 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_IS_AUTHENTICATED, isAuthenticated );
-        final String rejectKey = isAuthenticated ? WorkflowManager.WF_WP_SAVE_REJECT_MESSAGE_KEY : null;
-        final Workflow workflow = builder.buildApprovalWorkflow( submitter,
-                                                                 WorkflowManager.WF_WP_SAVE_APPROVER,
-                                                                 prepTask,
-                                                                 WorkflowManager.WF_WP_SAVE_DECISION_MESSAGE_KEY,
-                                                                 facts,
-                                                                 completionTask,
-                                                                 rejectKey );
-        m_workflowMgr.start( workflow );
-
-        // Let callers know if the page-save requires approval
-        if ( workflow.getCurrentStep() instanceof Decision ) {
-            throw new DecisionRequiredException( "The page contents must be approved before they become active." );
-        }
-    }
-
-    /**
      *  Returns this object's ReferenceManager.
      *  @return The current ReferenceManager instance.
      *
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index 1a7e4f7..c30113f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -21,6 +21,7 @@ package org.apache.wiki.pages;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiBackgroundThread;
+import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
@@ -44,6 +45,13 @@ import org.apache.wiki.providers.RepositoryModifiedException;
 import org.apache.wiki.providers.WikiPageProvider;
 import org.apache.wiki.util.ClassUtil;
 import org.apache.wiki.util.TextUtil;
+import org.apache.wiki.workflow.Decision;
+import org.apache.wiki.workflow.DecisionRequiredException;
+import org.apache.wiki.workflow.Fact;
+import org.apache.wiki.workflow.Step;
+import org.apache.wiki.workflow.Workflow;
+import org.apache.wiki.workflow.WorkflowBuilder;
+import org.apache.wiki.workflow.WorkflowManager;
 
 import java.io.IOException;
 import java.security.Permission;
@@ -194,7 +202,6 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      */
     public String getPureText( final String page, final int version ) {
         String result = null;
-
         try {
             result = getPageText( page, version );
         } catch( final ProviderException e ) {
@@ -204,7 +211,6 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
                 result = "";
             }
         }
-
         return result;
     }
 
@@ -217,6 +223,54 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         return TextUtil.replaceEntities( result );
     }
 
+    public void saveText( final WikiContext context, final String text ) throws WikiException {
+        // Check if page data actually changed; bail if not
+        final WikiPage page = context.getPage();
+        final String oldText = getPureText( page );
+        final String proposedText = TextUtil.normalizePostData( text );
+        if ( oldText != null && oldText.equals( proposedText ) ) {
+            return;
+        }
+
+        // Check if creation of empty pages is allowed; bail if not
+        final boolean allowEmpty = TextUtil.getBooleanProperty( m_engine.getWikiProperties(),
+                                                                WikiEngine.PROP_ALLOW_CREATION_OF_EMPTY_PAGES,
+                                                         false );
+        if ( !allowEmpty && !wikiPageExists( page ) && text.trim().equals( "" ) ) {
+            return;
+        }
+
+        // Create approval workflow for page save; add the diffed, proposed and old text versions as
+        // Facts for the approver (if approval is required). If submitter is authenticated, any reject
+        // messages will appear in his/her workflow inbox.
+        final WorkflowBuilder builder = WorkflowBuilder.getBuilder( m_engine );
+        final Principal submitter = context.getCurrentUser();
+        final Step prepTask = m_engine.getTasksManager().buildPreSaveWikiPageTask( context, proposedText );
+        final Step completionTask = m_engine.getTasksManager().buildSaveWikiPageTask();
+        final String diffText = m_engine.getDifferenceManager().makeDiff( context, oldText, proposedText );
+        final boolean isAuthenticated = context.getWikiSession().isAuthenticated();
+        final Fact[] facts = new Fact[ 5 ];
+        facts[ 0 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_PAGE_NAME, page.getName() );
+        facts[ 1 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_DIFF_TEXT, diffText );
+        facts[ 2 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_PROPOSED_TEXT, proposedText );
+        facts[ 3 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_CURRENT_TEXT, oldText);
+        facts[ 4 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_IS_AUTHENTICATED, isAuthenticated );
+        final String rejectKey = isAuthenticated ? WorkflowManager.WF_WP_SAVE_REJECT_MESSAGE_KEY : null;
+        final Workflow workflow = builder.buildApprovalWorkflow( submitter,
+                                                                 WorkflowManager.WF_WP_SAVE_APPROVER,
+                                                                 prepTask,
+                                                                 WorkflowManager.WF_WP_SAVE_DECISION_MESSAGE_KEY,
+                                                                 facts,
+                                                                 completionTask,
+                                                                 rejectKey );
+        m_engine.getWorkflowManager().start( workflow );
+
+        // Let callers know if the page-save requires approval
+        if ( workflow.getCurrentStep() instanceof Decision ) {
+            throw new DecisionRequiredException( "The page contents must be approved before they become active." );
+        }
+    }
+
     /**
      * Returns the WikiEngine to which this PageManager belongs to.
      *
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index 9173df8..80ddfc1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -18,8 +18,10 @@
  */
 package org.apache.wiki.pages;
 
+import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.ProviderException;
+import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.providers.WikiPageProvider;
 
@@ -134,6 +136,24 @@ public interface PageManager extends WikiEventListener {
     }
 
     /**
+     *  Writes the WikiText of a page into the page repository. If the <code>jspwiki.properties</code> file contains
+     *  the property <code>jspwiki.approver.workflow.saveWikiPage</code> and its value resolves to a valid user,
+     *  {@link org.apache.wiki.auth.authorize.Group} or {@link org.apache.wiki.auth.authorize.Role}, this method will
+     *  place a {@link org.apache.wiki.workflow.Decision} in the approver's workflow inbox and throw a
+     *  {@link org.apache.wiki.workflow.DecisionRequiredException}. If the submitting user is authenticated and the
+     *  page save is rejected, a notification will be placed in the user's decision queue.
+     *
+     *  @since 2.1.28, moved to PageManager on 2.11.0
+     *  @param context The current WikiContext
+     *  @param text    The Wiki markup for the page.
+     *  @throws WikiException if the save operation encounters an error during the save operation. If the page-save
+     *  operation requires approval, the exception will be of type {@link org.apache.wiki.workflow.DecisionRequiredException}.
+     *  Individual PageFilters, such as the {@link org.apache.wiki.filters.SpamFilter} may also throw a
+     *  {@link org.apache.wiki.api.exceptions.RedirectException}.
+     */
+    void saveText( WikiContext context, String text ) throws WikiException;
+
+    /**
      * Puts the page text into the repository.  Note that this method does NOT update
      * JSPWiki internal data structures, and therefore you should always use WikiEngine.saveText()
      *
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java
index 8ad5f9b..b725f7d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java
@@ -141,7 +141,7 @@ public class BugReportHandler implements WikiPlugin {
             final WikiPage newPage = new WikiPage( context.getEngine(), pageName );
             final WikiContext newContext = (WikiContext)context.clone();
             newContext.setPage( newPage );
-            context.getEngine().saveText( newContext, str.toString() );
+            context.getEngine().getPageManager().saveText( newContext, str.toString() );
 
             final MessageFormat formatter = new MessageFormat("");
             formatter.applyPattern( rb.getString("bugreporthandler.new") );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
index f568541..56dc601 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
@@ -156,21 +156,15 @@ public class AtomAPIServlet extends HttpServlet
 
             log.debug("Writing entry: "+text);
 
-            m_engine.saveText( context, text.toString() );
+            m_engine.getPageManager().saveText( context, text.toString() );
 
-        }
-        catch( FeedMarshallException e )
-        {
+        } catch( final FeedMarshallException e ) {
             log.error("Received faulty Atom entry",e);
             throw new ServletException("Faulty Atom entry",e);
-        }
-        catch( IOException e )
-        {
+        } catch( final IOException e ) {
             log.error("I/O exception",e);
             throw new ServletException("Could not get body of request",e);
-        }
-        catch( WikiException e )
-        {
+        } catch( final WikiException e ) {
             log.error("Provider exception while posting",e);
             throw new ServletException("JSPWiki cannot save the entry",e);
         }
@@ -220,9 +214,7 @@ public class AtomAPIServlet extends HttpServlet
 
     }
 
-    private Entry getBlogEntry( String entryid )
-        throws ProviderException
-    {
+    private Entry getBlogEntry( String entryid ) {
         WikiPage page = m_engine.getPageManager().getPage( entryid );
         WikiPage firstVersion = m_engine.getPageManager().getPage( entryid, 1 );
 
@@ -257,10 +249,7 @@ public class AtomAPIServlet extends HttpServlet
     /**
      *  Creates and outputs a full list of all available blogs
      */
-    private Feed listBlogs()
-        throws ProviderException,
-               IOException
-    {
+    private Feed listBlogs() throws ProviderException {
         Collection< WikiPage > pages = m_engine.getPageManager().getAllPages();
 
         Feed feed = SyndicationFactory.newSyndicationFeed();
@@ -328,18 +317,14 @@ public class AtomAPIServlet extends HttpServlet
     /**
      *  {@inheritDoc}
      */
-    public void doDelete( HttpServletRequest request, HttpServletResponse response )
-        throws ServletException
-    {
+    public void doDelete( HttpServletRequest request, HttpServletResponse response ) {
         log.debug("Received HTTP DELETE");
     }
 
     /**
      *  {@inheritDoc}
      */
-    public void doPut( HttpServletRequest request, HttpServletResponse response )
-        throws ServletException
-    {
+    public void doPut( HttpServletRequest request, HttpServletResponse response ) {
         log.debug("Received HTTP PUT");
     }
 }
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 37f43a6..c726b83 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
@@ -205,8 +205,7 @@ public class MetaWeblogHandler
 
         checkPermissions( page, username, password, "view" );
 
-        try
-        {
+        try {
             WeblogPlugin plugin = new WeblogPlugin();
 
             List<WikiPage> changed = plugin.findBlogEntries(m_context.getEngine(),
@@ -224,11 +223,8 @@ public class MetaWeblogHandler
                 result.put( "entry", makeEntry( p ) );
             }
 
-        }
-        catch( ProviderException e )
-        {
+        } catch( final ProviderException e ) {
             log.error( "Failed to list recent posts", e );
-
             throw new XmlRpcException( 0, e.getMessage() );
         }
 
@@ -277,7 +273,7 @@ public class MetaWeblogHandler
 
             log.debug("Writing entry: "+text);
 
-            engine.saveText( context, text.toString() );
+            engine.getPageManager().saveText( context, text.toString() );
         }
         catch( Exception e )
         {
@@ -320,16 +316,13 @@ public class MetaWeblogHandler
 
         AttachmentManager attmgr = engine.getAttachmentManager();
 
-        try
-        {
+        try {
             Attachment att = new Attachment( engine, blogid, name );
             att.setAuthor( username );
             attmgr.storeAttachment( att, new ByteArrayInputStream( data ) );
 
             url = engine.getURL( WikiContext.ATTACH, att.getName(), null, true );
-        }
-        catch( Exception e )
-        {
+        } catch( final Exception e ) {
             log.error( "Failed to upload attachment", e );
             throw new XmlRpcException( 0, "Failed to upload media object: "+e.getMessage() );
         }
@@ -374,10 +367,8 @@ public class MetaWeblogHandler
 
             log.debug("Updating entry: "+text);
 
-            engine.saveText( context, text.toString() );
-        }
-        catch( Exception e )
-        {
+            engine.getPageManager().saveText( context, text.toString() );
+        } catch( final Exception e ) {
             log.error("Failed to create weblog entry",e);
             throw new XmlRpcException( 0, "Failed to update weblog entry: "+e.getMessage() );
         }
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 f012adb..9aaf8d2 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -368,7 +368,7 @@ public class TestEngine extends WikiEngine
         // Create page and wiki context
         final WikiPage page = new WikiPage( this, pageName );
         final WikiContext context = new WikiContext( this, request, page );
-        saveText( context, content );
+        getPageManager().saveText( context, content );
     }
 
     public void saveTextAsJanne( final String pageName, final String content ) throws WikiException {
@@ -381,7 +381,7 @@ public class TestEngine extends WikiEngine
         final WikiPage page = new WikiPage( this, pageName );
         page.setAuthor(Users.JANNE);
         final WikiContext context = new WikiContext( this, request, page );
-        saveText( context, content );
+        getPageManager().saveText( context, content );
     }
 
     /**
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 d2718b0..779e7d7 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -365,13 +365,13 @@ public class WikiEngineTest {
         final WikiPage p = new WikiPage( m_engine, NAME1 );
         final WikiContext context = new WikiContext(m_engine,p);
         context.getPage().setAttribute( WikiPage.CHANGENOTE, "Test change" );
-        m_engine.saveText( context, "test" );
+        m_engine.getPageManager().saveText( context, "test" );
 
         for( int i = 0; i < 5; i++ ) {
             final WikiPage p2 = ( WikiPage )m_engine.getPageManager().getPage( NAME1 ).clone();
             p2.removeAttribute( WikiPage.CHANGENOTE );
             context.setPage( p2 );
-            m_engine.saveText( context, "test" + i );
+            m_engine.getPageManager().saveText( context, "test" + i );
         }
 
         final WikiPage p3 = m_engine.getPageManager().getPage( NAME1, -1 );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
index 9a0a14e..ca5aac5 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
@@ -45,173 +45,109 @@ public class DefaultPluginManagerTest {
     }
 
     @AfterEach
-    public void tearDown() throws ProviderException
-    {
+    public void tearDown() throws ProviderException {
         engine.getPageManager().deletePage("Testpage");
     }
 
     @Test
-    public void testSimpleInsert()
-        throws Exception
-    {
-        String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.SamplePlugin WHERE text=foobar}");
-
+    public void testSimpleInsert() throws Exception {
+        final String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.SamplePlugin WHERE text=foobar}");
         Assertions.assertEquals( "foobar", res );
     }
 
     @Test
-    public void testSimpleInsertNoPackage()
-        throws Exception
-    {
-        String res = manager.execute( context,
-                                      "{INSERT SamplePlugin WHERE text=foobar}");
-
-        Assertions.assertEquals( "foobar",
-                      res );
+    public void testSimpleInsertNoPackage() throws Exception {
+        final String res = manager.execute( context, "{INSERT SamplePlugin WHERE text=foobar}");
+        Assertions.assertEquals( "foobar", res );
     }
 
 
     @Test
-    public void testSimpleInsertNoPackage2()
-        throws Exception
-    {
+    public void testSimpleInsertNoPackage2() throws Exception {
         props.setProperty( DefaultPluginManager.PROP_SEARCHPATH, "com.foo" );
-        DefaultPluginManager m = new DefaultPluginManager( engine, props );
-        String res = m.execute( context,
-                                "{INSERT SamplePlugin2 WHERE text=foobar}");
-
-        Assertions.assertEquals( "foobar",
-                      res );
+        final DefaultPluginManager m = new DefaultPluginManager( engine, props );
+        final String res = m.execute( context,"{INSERT SamplePlugin2 WHERE text=foobar}" );
+        Assertions.assertEquals( "foobar", res );
     }
 
     @Test
-    public void testSimpleInsertNoPackage3()
-        throws Exception
-    {
+    public void testSimpleInsertNoPackage3() throws Exception {
         props.setProperty( DefaultPluginManager.PROP_SEARCHPATH, "com.foo" );
-        DefaultPluginManager m = new DefaultPluginManager( engine, props );
-        String res = m.execute( context,
-                                "{INSERT SamplePlugin3 WHERE text=foobar}");
-
-        Assertions.assertEquals( "foobar",
-                      res );
+        final DefaultPluginManager m = new DefaultPluginManager( engine, props );
+        final String res = m.execute( context,"{INSERT SamplePlugin3 WHERE text=foobar}" );
+        Assertions.assertEquals( "foobar", res );
     }
 
     /** Check that in all cases org.apache.wiki.plugin is searched. */
     @Test
-    public void testSimpleInsertNoPackage4()
-        throws Exception
-    {
+    public void testSimpleInsertNoPackage4() throws Exception {
         props.setProperty( DefaultPluginManager.PROP_SEARCHPATH, "com.foo,blat.blaa" );
-        DefaultPluginManager m = new DefaultPluginManager( engine, props );
-        String res = m.execute( context,
-                                "{INSERT SamplePlugin WHERE text=foobar}");
-
-        Assertions.assertEquals( "foobar",
-                      res );
+        final DefaultPluginManager m = new DefaultPluginManager( engine, props );
+        final String res = m.execute( context,"{INSERT SamplePlugin WHERE text=foobar}" );
+        Assertions.assertEquals( "foobar", res );
     }
 
 
     @Test
-    public void testSimpleInsert2()
-        throws Exception
-    {
-        String res = manager.execute( context,
-                                      "{INSERT   org.apache.wiki.plugin.SamplePlugin  WHERE   text = foobar2, moo=blat}");
-
-        Assertions.assertEquals( "foobar2",
-                      res );
+    public void testSimpleInsert2() throws Exception {
+        final String res = manager.execute( context,"{INSERT   org.apache.wiki.plugin.SamplePlugin  WHERE   text = foobar2, moo=blat}");
+        Assertions.assertEquals( "foobar2", res );
     }
 
     /** Missing closing brace */
     @Test
-    public void testSimpleInsert3()
-        throws Exception
-    {
-        String res = manager.execute( context,
-                                      "{INSERT   org.apache.wiki.plugin.SamplePlugin  WHERE   text = foobar2, moo=blat");
-
-        Assertions.assertEquals( "foobar2",
-                      res );
+    public void testSimpleInsert3() throws Exception {
+        final String res = manager.execute( context, "{INSERT   org.apache.wiki.plugin.SamplePlugin  WHERE   text = foobar2, moo=blat");
+        Assertions.assertEquals( "foobar2", res );
     }
 
     @Test
-    public void testQuotedArgs()
-        throws Exception
-    {
-        String res = manager.execute( context,
-                                      "{INSERT SamplePlugin WHERE text='this is a space'}");
-
-        Assertions.assertEquals( "this is a space",
-                      res );
+    public void testQuotedArgs() throws Exception {
+        final String res = manager.execute( context, "{INSERT SamplePlugin WHERE text='this is a space'}");
+        Assertions.assertEquals( "this is a space", res );
     }
 
     @Test
-    public void testQuotedArgs2()
-        throws Exception
-    {
-        String res = manager.execute( context,
-                                      "{INSERT SamplePlugin WHERE text='this \\'is a\\' space'}");
-
-        Assertions.assertEquals( "this 'is a' space",
-                      res );
+    public void testQuotedArgs2() throws Exception {
+        final String res = manager.execute( context, "{INSERT SamplePlugin WHERE text='this \\'is a\\' space'}" );
+        Assertions.assertEquals( "this 'is a' space", res );
     }
 
     @Test
-    public void testNumberArgs()
-        throws Exception
-    {
-        String res = manager.execute( context,
-                                      "{INSERT SamplePlugin WHERE text=15}");
-
-        Assertions.assertEquals( "15",
-                      res );
+    public void testNumberArgs() throws Exception {
+        final String res = manager.execute( context, "{INSERT SamplePlugin WHERE text=15}" );
+        Assertions.assertEquals( "15", res );
     }
 
     @Test
-    public void testNoInsert()
-        throws Exception
-    {
-        String res = manager.execute( context,
-                                      "{SamplePlugin WHERE text=15}");
-
-        Assertions.assertEquals( "15",
-                      res );
+    public void testNoInsert() throws Exception {
+        final String res = manager.execute( context, "{SamplePlugin WHERE text=15}" );
+        Assertions.assertEquals( "15", res );
     }
 
     // This should be read from tests/etc/ini/jspwiki_module.xml
     @Test
-    public void testAlias()
-        throws Exception
-    {
-        String res = manager.execute( context, "{samplealias text=15}");
-
+    public void testAlias() throws Exception {
+        final String res = manager.execute( context, "{samplealias text=15}");
         Assertions.assertEquals( "15", res );
     }
 
     @Test
-    public void testAlias2()
-        throws Exception
-    {
-        String res = manager.execute( context, "{samplealias2 text=xyzzy}");
-
+    public void testAlias2() throws Exception {
+        final String res = manager.execute( context, "{samplealias2 text=xyzzy}");
         Assertions.assertEquals( "xyzzy", res );
     }
 
     @Test
-    public void testInitPlugin() throws Exception
-    {
+    public void testInitPlugin() throws Exception {
         manager.execute( context, "{JavaScriptPlugin}");
-
         Assertions.assertTrue( JavaScriptPlugin.c_inited );
     }
 
     @Test
-    public void testParserPlugin() throws Exception
-    {
-        engine.saveText(context, "[{SamplePlugin render=true}]");
+    public void testParserPlugin() throws Exception {
+        engine.getPageManager().saveText(context, "[{SamplePlugin render=true}]");
         engine.getHTML( "Testpage" );
-
         Assertions.assertTrue( SamplePlugin.c_rendered );
     }
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java b/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
index cb17e9c..688ae5f 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
@@ -530,7 +530,7 @@ public class VersioningFileProviderTest
         p.setAttribute(WikiPage.CHANGENOTE, "Test change" );
         WikiContext context = new WikiContext(engine,p);
 
-        engine.saveText( context, "test" );
+        engine.getPageManager().saveText( context, "test" );
 
         WikiPage p2 = engine.getPageManager().getPage( NAME1 );
 
@@ -547,10 +547,10 @@ public class VersioningFileProviderTest
         WikiContext context = new WikiContext(engine,p);
 
         context.getPage().setAttribute(WikiPage.CHANGENOTE, "Test change" );
-        engine.saveText( context, "test" );
+        engine.getPageManager().saveText( context, "test" );
 
         context.getPage().setAttribute(WikiPage.CHANGENOTE, "Change 2" );
-        engine.saveText( context, "test2" );
+        engine.getPageManager().saveText( context, "test2" );
 
         WikiPage p2 = engine.getPageManager().getPage( NAME1, 1 );
 
@@ -570,7 +570,7 @@ public class VersioningFileProviderTest
 
         context.getPage().setAttribute( WikiPage.CHANGENOTE, "Test change" );
 
-        engine.saveText( context, "test" );
+        engine.getPageManager().saveText( context, "test" );
 
         for( int i = 0; i < 5; i++ )
         {
@@ -579,12 +579,12 @@ public class VersioningFileProviderTest
 
             context.setPage( p2 );
 
-            engine.saveText( context, "test"+i );
+            engine.getPageManager().saveText( context, "test"+i );
         }
 
         WikiPage p3 = engine.getPageManager().getPage( NAME1, -1 );
 
-        Assertions.assertEquals( null, p3.getAttribute(WikiPage.CHANGENOTE) );
+        Assertions.assertEquals( null, (String)p3.getAttribute(WikiPage.CHANGENOTE) );
     }
 
     /*
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 1f7a935..9944ed4 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
@@ -122,8 +122,8 @@ public class SearchManagerTest {
         final MockHttpServletRequest request = m_engine.newHttpRequest();
         request.getParameterMap().put( "page", new String[]{ "TestPage" } );
         final WikiContext ctx = m_engine.createContext( request, WikiContext.EDIT );
-        m_engine.saveText( ctx, txt );
-        m_engine.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." );
+        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." );
 
         Collection< SearchResult > res = new ArrayList<>();
         Awaitility.await( "testSimpleSearch3" ).until( findsResultsFor( res, "Babylon" ) );
@@ -144,14 +144,14 @@ public class SearchManagerTest {
         final MockHttpServletRequest request = m_engine.newHttpRequest();
         request.getParameterMap().put( "page", new String[]{ "TestPage" } );
         final WikiContext ctx = m_engine.createContext( request, WikiContext.EDIT );
-        m_engine.saveText( ctx, txt );
+        m_engine.getPageManager().saveText( ctx, txt );
 
         Collection< SearchResult > res = new ArrayList<>();
         Awaitility.await( "testSimpleSearch4" ).until( findsResultsFor( res, "mankind" ) );
 
         Assertions.assertEquals( 1, res.size(), "result not found" );
 
-        m_engine.saveText( ctx, "[{ALLOW view Authenticated}] It was the dawn of the third age of mankind... page is blocked" );
+        m_engine.getPageManager().saveText( ctx, "[{ALLOW view Authenticated}] It was the dawn of the third age of mankind... page is blocked" );
 
         res = m_mgr.findPages( "mankind" , ctx );
         Assertions.assertNotNull( res, "null result" );
diff --git a/jspwiki-war/src/main/webapp/Comment.jsp b/jspwiki-war/src/main/webapp/Comment.jsp
index d1b90a1..5ef57e3 100644
--- a/jspwiki-war/src/main/webapp/Comment.jsp
+++ b/jspwiki-war/src/main/webapp/Comment.jsp
@@ -43,14 +43,12 @@
 <%!
     Logger log = Logger.getLogger("JSPWiki");
 
-	String findParam( PageContext ctx, String key )
-	{
+	String findParam( PageContext ctx, String key ) {
 	    ServletRequest req = ctx.getRequest();
 
 	    String val = req.getParameter( key );
 
-	    if( val == null )
-	    {
+	    if( val == null ) {
 	        val = (String)ctx.findAttribute( key );
 	    }
 
@@ -73,8 +71,7 @@
     WikiSession wikiSession = wikiContext.getWikiSession();
     String storedUser = wikiSession.getUserPrincipal().getName();
 
-    if( wikiSession.isAnonymous() )
-    {
+    if( wikiSession.isAnonymous() ) {
         storedUser  = TextUtil.replaceEntities( request.getParameter( "author" ) );
     }
 
@@ -91,8 +88,7 @@
 
     session.removeAttribute( EditorManager.REQ_EDITEDTEXT );
 
-    if( latestversion == null )
-    {
+    if( latestversion == null ) {
         latestversion = wikiContext.getPage();
     }
 
@@ -101,8 +97,7 @@
     //  session.
     //
 
-    if( remember == null )
-    {
+    if( remember == null ) {
         remember = (String)session.getAttribute("remember");
     }
 
@@ -114,16 +109,16 @@
 
     session.setAttribute("remember",remember);
 
-    if( author == null )
-    {
+    if( author == null ) {
         author = storedUser;
     }
-    if( author == null || author.length() == 0 ) author = "AnonymousCoward";
+    if( author == null || author.length() == 0 ) {
+        author = "AnonymousCoward";
+    }
 
     session.setAttribute("author",author);
 
-    if( link == null )
-    {
+    if( link == null ) {
         link = HttpUtil.retrieveCookieValue( request, "link" );
         if( link == null ) link = "";
         link = TextUtil.urlDecodeUTF8(link);
@@ -131,16 +126,16 @@
 
     session.setAttribute( "link", link );
 
-    if( changenote != null )
+    if( changenote != null ) {
        session.setAttribute( "changenote", changenote );
+    }
 
     //
     //  Branch
     //
     log.debug("preview="+preview+", ok="+ok);
 
-    if( ok != null )
-    {
+    if( ok != null ) {
         log.info("Saving page "+pagereq+". User="+storedUser+", host="+HttpUtil.getRemoteAddress(request) );
 
         //  Modifications are written here before actual saving
@@ -153,14 +148,12 @@
 
         String spamhash = request.getParameter( SpamFilter.getHashFieldName(request) );
 
-        if( !SpamFilter.checkHash(wikiContext,pageContext) )
-        {
+        if( !SpamFilter.checkHash(wikiContext,pageContext) ) {
             return;
         }
 
         //
-        //  We expire ALL locks at this moment, simply because someone has
-        //  already broken it.
+        //  We expire ALL locks at this moment, simply because someone has already broken it.
         //
         PageLock lock = wiki.getPageManager().getCurrentLock( wikipage );
         wiki.getPageManager().unlockPage( lock );
@@ -169,18 +162,17 @@
         //
         //  Set author and changenote information
         //
-
         modifiedPage.setAuthor( storedUser );
 
-        if( changenote != null )
+        if( changenote != null ) {
             modifiedPage.setAttribute( WikiPage.CHANGENOTE, changenote );
-        else
+        } else {
             modifiedPage.removeAttribute( WikiPage.CHANGENOTE );
+        }
 
         //
         //  Build comment part
         //
-
         StringBuffer pageText = new StringBuffer(wiki.getPageManager().getPureText( wikipage ));
 
         log.debug("Page initial contents are "+pageText.length()+" chars");
@@ -188,8 +180,7 @@
         //
         //  Add a line on top only if we need to separate it from the content.
         //
-        if( pageText.length() > 0 )
-        {
+        if( pageText.length() > 0 ) {
             pageText.append( "\n\n----\n\n" );
         }
 
@@ -200,22 +191,18 @@
         //  WYSIWYG editor sends us its greetings
         //
         String htmlText = findParam( pageContext, "htmlPageText" );
-        if( htmlText != null && cancel == null )
-        {
+        if( htmlText != null && cancel == null ) {
         	commentText = new HtmlStringToWikiTranslator().translate(htmlText,wikiContext);
         }
 
         pageText.append( commentText );
 
         log.debug("Author name ="+author);
-        if( author != null && author.length() > 0 )
-        {
+        if( author != null && author.length() > 0 ) {
             String signature = author;
 
-            if( link != null && link.length() > 0 )
-            {
+            if( link != null && link.length() > 0 ) {
                 link = HttpUtil.guessValidURI( link );
-
                 signature = "["+author+"|"+link+"]";
             }
 
@@ -226,57 +213,43 @@
 
         }
 
-        if( TextUtil.isPositive(remember) )
-        {
-            if( link != null )
-            {
+        if( TextUtil.isPositive(remember) ) {
+            if( link != null ) {
                 Cookie linkcookie = new Cookie("link", TextUtil.urlEncodeUTF8(link) );
                 linkcookie.setMaxAge(1001*24*60*60);
                 response.addCookie( linkcookie );
             }
 
             CookieAssertionLoginModule.setUserCookie( response, author );
-        }
-        else
-        {
+        } else {
             session.removeAttribute("link");
             session.removeAttribute("author");
         }
 
-        try
-        {
+        try {
             wikiContext.setPage( modifiedPage );
-            wiki.saveText( wikiContext, pageText.toString() );
-        }
-        catch( DecisionRequiredException e )
-        {
+            wiki.getPageManager().saveText( wikiContext, pageText.toString() );
+        } catch( DecisionRequiredException e ) {
         	String redirect = wikiContext.getURL(WikiContext.VIEW,"ApprovalRequiredForPageChanges");
             response.sendRedirect( redirect );
             return;
-        }
-        catch( RedirectException e )
-        {
+        } catch( RedirectException e ) {
             session.setAttribute( VariableManager.VAR_MSG, e.getMessage() );
             response.sendRedirect( e.getRedirect() );
             return;
         }
         response.sendRedirect(wiki.getViewURL(pagereq));
         return;
-    }
-    else if( preview != null )
-    {
+    } 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;","&") );
         return;
-    }
-    else if( cancel != null )
-    {
+    } else if( cancel != null ) {
         log.debug("Cancelled editing "+pagereq);
         PageLock lock = (PageLock) session.getAttribute( "lock-"+pagereq );
 
-        if( lock != null )
-        {
+        if( lock != null ) {
             wiki.getPageManager().unlockPage( lock );
             session.removeAttribute( "lock-"+pagereq );
         }
@@ -287,18 +260,15 @@
     log.info("Commenting page "+pagereq+". User="+request.getRemoteUser()+", host="+HttpUtil.getRemoteAddress(request) );
 
     //
-    //  Determine and store the date the latest version was changed.  Since
-    //  the newest version is the one that is changed, we need to track
-    //  that instead of the edited version.
+    //  Determine and store the date the latest version was changed.  Since the newest version is the one that is changed,
+    //  we need to track that instead of the edited version.
     //
     long lastchange = 0;
 
     Date d = latestversion.getLastModified();
     if( d != null ) lastchange = d.getTime();
 
-    pageContext.setAttribute( "lastchange",
-                              Long.toString( lastchange ),
-                              PageContext.REQUEST_SCOPE );
+    pageContext.setAttribute( "lastchange", Long.toString( lastchange ), PageContext.REQUEST_SCOPE );
 
     //  This is a hack to get the preview to work.
     // pageContext.setAttribute( "comment", Boolean.TRUE, PageContext.REQUEST_SCOPE );
@@ -306,11 +276,9 @@
     //
     //  Attempt to lock the page.
     //
-    PageLock lock = wiki.getPageManager().lockPage( wikipage,
-                                                    storedUser );
+    PageLock lock = wiki.getPageManager().lockPage( wikipage, storedUser );
 
-    if( lock != null )
-    {
+    if( lock != null ) {
         session.setAttribute( "lock-"+pagereq, lock );
     }
 
@@ -319,8 +287,6 @@
     response.setHeader( "Cache-control", "max-age=0" );
     response.setDateHeader( "Expires", new Date().getTime() );
     response.setDateHeader( "Last-Modified", new Date().getTime() );
-    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 bcaf43e..b572cae 100644
--- a/jspwiki-war/src/main/webapp/Edit.jsp
+++ b/jspwiki-war/src/main/webapp/Edit.jsp
@@ -35,14 +35,10 @@
 <%!
     Logger log = Logger.getLogger("JSPWiki");
 
-    String findParam( PageContext ctx, String key )
-    {
+    String findParam( PageContext ctx, String key ) {
         ServletRequest req = ctx.getRequest();
-
         String val = req.getParameter( key );
-
-        if( val == null )
-        {
+        if( val == null ) {
             val = (String)ctx.findAttribute( key );
         }
 
@@ -54,7 +50,9 @@
     WikiEngine wiki = WikiEngine.getInstance( getServletConfig() );
     // Create wiki context and check for authorization
     WikiContext wikiContext = wiki.createContext( request, WikiContext.EDIT );
-    if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) return;
+    if( !wiki.getAuthorizationManager().hasAccess( wikiContext, response ) ) {
+        return;
+    }
     if( wikiContext.getCommand().getTarget() == null ) {
         response.sendRedirect( wikiContext.getURL( wikiContext.getRequestContext(), wikiContext.getName() ) );
         return;
@@ -76,9 +74,7 @@
     String spamhash = findParam( pageContext, SpamFilter.getHashFieldName(request) );
     String captcha = (String)session.getAttribute("captcha");
 
-    if ( !wikiSession.isAuthenticated() && wikiSession.isAnonymous()
-         && author != null )
-    {
+    if ( !wikiSession.isAuthenticated() && wikiSession.isAnonymous() && author != null ) {
         user  = TextUtil.replaceEntities( findParam( pageContext, "author" ) );
     }
 
@@ -86,16 +82,14 @@
     //  WYSIWYG editor sends us its greetings
     //
     String htmlText = findParam( pageContext, "htmlPageText" );
-    if( htmlText != null && cancel == null )
-    {
+    if( htmlText != null && cancel == null ) {
         text = new HtmlStringToWikiTranslator().translate(htmlText,wikiContext);
     }
 
     WikiPage wikipage = wikiContext.getPage();
     WikiPage latestversion = wiki.getPageManager().getPage( pagereq );
 
-    if( latestversion == null )
-    {
+    if( latestversion == null ) {
         latestversion = wikiContext.getPage();
     }
 
@@ -112,16 +106,14 @@
     //log.debug("Request content type+"+request.getContentType());
     log.debug("preview="+preview+", ok="+ok);
 
-    if( ok != null || captcha != null )
-    {
+    if( ok != null || captcha != null ) {
         log.info("Saving page "+pagereq+". User="+user+", host="+HttpUtil.getRemoteAddress(request) );
 
         //
         //  Check for session expiry
         //
 
-        if( !SpamFilter.checkHash(wikiContext,pageContext) )
-        {
+        if( !SpamFilter.checkHash(wikiContext,pageContext) ) {
             return;
         }
 
@@ -133,8 +125,7 @@
 
         String h = SpamFilter.getSpamHash( latestversion, request );
 
-        if( !h.equals(spamhash) )
-        {
+        if( !h.equals(spamhash) ) {
             //
             // Someone changed the page while we were editing it!
             //
@@ -147,8 +138,7 @@
         }
 
         //
-        //  We expire ALL locks at this moment, simply because someone has
-        //  already broken it.
+        //  We expire ALL locks at this moment, simply because someone has already broken it.
         //
         PageLock lock = wiki.getPageManager().getCurrentLock( wikipage );
         wiki.getPageManager().unlockPage( lock );
@@ -157,28 +147,24 @@
         //
         //  Set author information and other metadata
         //
-
         modifiedPage.setAuthor( user );
 
-        if( changenote == null ) changenote = (String) session.getAttribute("changenote");
+        if( changenote == null ) {
+            changenote = (String) session.getAttribute("changenote");
+        }
 
         session.removeAttribute("changenote");
 
-        if( changenote != null && changenote.length() > 0 )
-        {
+        if( changenote != null && changenote.length() > 0 ) {
             modifiedPage.setAttribute( WikiPage.CHANGENOTE, changenote );
-        }
-        else
-        {
+        } else {
             modifiedPage.removeAttribute( WikiPage.CHANGENOTE );
         }
 
         //
         //  Figure out the actual page text
         //
-
-        if( text == null )
-        {
+        if( text == null ) {
             throw new ServletException( "No parameter text set!" );
         }
 
@@ -186,38 +172,26 @@
         //  If this is an append, then we just append it to the page.
         //  If it is a full edit, then we will replace the previous contents.
         //
-
-        try
-        {
+        try {
             wikiContext.setPage( modifiedPage );
 
-            if( captcha != null )
-            {
+            if( captcha != null ) {
                 wikiContext.setVariable( "captcha", Boolean.TRUE );
                 session.removeAttribute( "captcha" );
             }
 
-            if( append != null )
-            {
+            if( append != null ) {
                 StringBuffer pageText = new StringBuffer(wiki.getPageManager().getText( pagereq ));
-
                 pageText.append( text );
-
-                wiki.saveText( wikiContext, pageText.toString() );
-            }
-            else
-            {
-                wiki.saveText( wikiContext, text );
+                wiki.getPageManager().saveText( wikiContext, pageText.toString() );
+            } else {
+                wiki.getPageManager().saveText( wikiContext, text );
             }
-        }
-        catch( DecisionRequiredException ex )
-        {
+        } catch( DecisionRequiredException ex ) {
         	String redirect = wikiContext.getURL(WikiContext.VIEW,"ApprovalRequiredForPageChanges");
             response.sendRedirect( redirect );
             return;
-        }
-        catch( RedirectException ex )
-        {
+        } catch( RedirectException ex ) {
             // FIXME: Cut-n-paste code.
             wikiContext.getWikiSession().addMessage( ex.getMessage() ); // FIXME: should work, but doesn't
             session.setAttribute( "message", ex.getMessage() );
@@ -234,27 +208,23 @@
 
         response.sendRedirect(wiki.getViewURL(pagereq));
         return;
-    }
-    else if( preview != null )
-    {
+    } else if( preview != null ) {
         log.debug("Previewing "+pagereq);
         session.setAttribute(EditorManager.REQ_EDITEDTEXT, EditorManager.getEditedText(pageContext));
         session.setAttribute("author",user);
         session.setAttribute("link",link != null ? link : "" );
 
-        if( htmlText != null ) session.setAttribute( EditorManager.REQ_EDITEDTEXT, text );
+        if( htmlText != null ) {
+            session.setAttribute( EditorManager.REQ_EDITEDTEXT, text );
+        }
 
         session.setAttribute("changenote", changenote != null ? changenote : "" );
         response.sendRedirect( wiki.getURL(WikiContext.PREVIEW,pagereq,null,false) );
         return;
-    }
-    else if( cancel != null )
-    {
+    } else if( cancel != null ) {
         log.debug("Cancelled editing "+pagereq);
         PageLock lock = (PageLock) session.getAttribute( "lock-"+pagereq );
-
-        if( lock != null )
-        {
+        if( lock != null ) {
             wiki.getPageManager().unlockPage( lock );
             session.removeAttribute( "lock-"+pagereq );
         }
@@ -274,23 +244,16 @@
     //
     String lastchange = SpamFilter.getSpamHash( latestversion, request );
 
-    pageContext.setAttribute( "lastchange",
-                              lastchange,
-                              PageContext.REQUEST_SCOPE );
+    pageContext.setAttribute( "lastchange", lastchange, PageContext.REQUEST_SCOPE );
 
     //
     //  Attempt to lock the page.
     //
-    PageLock lock = wiki.getPageManager().lockPage( wikipage,
-                                                    user );
-
-    if( lock != null )
-    {
+    PageLock lock = wiki.getPageManager().lockPage( wikipage, user );
+    if( lock != null ) {
         session.setAttribute( "lock-"+pagereq, lock );
     }
 
-    String contentPage = wiki.getTemplateManager().findJSP( pageContext,
-                                                            wikiContext.getTemplate(),
-                                                            "EditTemplate.jsp" );
+    String contentPage = wiki.getTemplateManager().findJSP( pageContext, wikiContext.getTemplate(), "EditTemplate.jsp" );
 
 %><wiki:Include page="<%=contentPage%>" />
\ No newline at end of file
diff --git a/jspwiki-war/src/main/webapp/templates/default/Sidebar.jsp b/jspwiki-war/src/main/webapp/templates/default/Sidebar.jsp
index 369105c..12bcb73 100644
--- a/jspwiki-war/src/main/webapp/templates/default/Sidebar.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/Sidebar.jsp
@@ -27,7 +27,7 @@
 
 <div class="sidebar">
 
-  <c:set var="isweblog"><%= WikiContext.findContext( pageContext ).getPage().getAttribute( /*ATTR_ISWEBLOG*/ "weblogplugin.isweblog" ) %></c:set>
+  <c:set var="isweblog"><%= ( String )WikiContext.findContext( pageContext ).getPage().getAttribute( /*ATTR_ISWEBLOG*/ "weblogplugin.isweblog" ) %></c:set>
   <c:if test="${isweblog}">
   <wiki:Calendar pageformat="'${param.page}_blogentry_'ddMMyy'_1'"
                  urlformat="'Wiki.jsp?page=${param.page}&weblog.startDate='ddMMyy'&weblog.days=1'"/>


[jspwiki] 24/32: remove getEngine from PageManager, you should already have access to it if you've grabbed the PageManager

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 27f6209bdb8c6902ab06dd5689b0e5540f2a060d
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 8 00:23:13 2020 +0100

    remove getEngine from PageManager, you should already have access to it if you've grabbed the PageManager
    
    Also, it doesn't extend WikiEventListener anymore, just DefaultPageManager implements it
---
 .../org/apache/wiki/event/WikiEventListener.java   |   9 +-
 .../org/apache/wiki/pages/DefaultPageManager.java  |  21 +++--
 .../java/org/apache/wiki/pages/PageManager.java    |  23 +----
 .../org/apache/wiki/plugin/WeblogEntryPlugin.java  | 100 +++++++--------------
 4 files changed, 52 insertions(+), 101 deletions(-)

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 5b2542d..6fbbfae 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
@@ -21,20 +21,19 @@ package org.apache.wiki.event;
 
 import  java.util.EventListener;
 
+
 /**
   * Defines an interface for an object that listens for WikiEvents.
   *
   * @since   2.3.92
   */
-public interface WikiEventListener extends EventListener
-{
+public interface WikiEventListener extends EventListener {
 
    /**
      * Fired when a WikiEvent is triggered by an event source.
      *
-     * @param event    a WikiEvent object
+     * @param event a WikiEvent object
      */
     void actionPerformed( WikiEvent event );
 
-
-} // end com.ecryd.jspwiki.event.WikiEventListener
+}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index 229889e..2090371 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -35,6 +35,7 @@ import org.apache.wiki.auth.acl.AclEntry;
 import org.apache.wiki.auth.acl.AclEntryImpl;
 import org.apache.wiki.auth.user.UserProfile;
 import org.apache.wiki.event.WikiEvent;
+import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.event.WikiSecurityEvent;
@@ -75,7 +76,7 @@ import java.util.concurrent.ConcurrentHashMap;
 // FIXME: This class currently only functions just as an extra layer over providers,
 //        complicating things.  We need to move more provider-specific functionality
 //        from WikiEngine (which is too big now) into this class.
-public class DefaultPageManager extends ModuleManager implements PageManager {
+public class DefaultPageManager extends ModuleManager implements PageManager, WikiEventListener {
 
     private static final Logger LOG = Logger.getLogger( DefaultPageManager.class );
 
@@ -218,11 +219,11 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
     }
 
     /**
-     * {@inheritDoc}
-     * @see org.apache.wiki.pages.PageManager#getEngine()
+     * Returns the WikiEngine to which this PageManager belongs to.
+     *
+     * @return The WikiEngine object.
      */
-    @Override
-    public WikiEngine getEngine() {
+    protected WikiEngine getEngine() {
         return m_engine;
     }
 
@@ -636,8 +637,14 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
     	return null;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.wiki.pages.PageManager#actionPerformed(org.apache.wiki.event.WikiEvent)
+    /**
+     * Listens for {@link org.apache.wiki.event.WikiSecurityEvent#PROFILE_NAME_CHANGED}
+     * events. If a user profile's name changes, each page ACL is inspected. If an entry contains
+     * a name that has changed, it is replaced with the new one. No events are emitted
+     * as a consequence of this method, because the page contents are still the same; it is
+     * only the representations of the names within the ACL that are changing.
+     *
+     * @param event The event
      */
     @Override
     public void actionPerformed( final WikiEvent event ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index 632e3b4..0c48a48 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -18,11 +18,8 @@
  */
 package org.apache.wiki.pages;
 
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.ProviderException;
-import org.apache.wiki.event.WikiEvent;
-import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.providers.WikiPageProvider;
 
 import java.util.Collection;
@@ -30,7 +27,7 @@ import java.util.List;
 import java.util.Set;
 
 
-public interface PageManager extends WikiEventListener {
+public interface PageManager {
 
     /** The property value for setting the current page provider.  Value is {@value}. */
     String PROP_PAGEPROVIDER = "jspwiki.pageProvider";
@@ -136,13 +133,6 @@ public interface PageManager extends WikiEventListener {
     }
 
     /**
-     * Returns the WikiEngine to which this PageManager belongs to.
-     *
-     * @return The WikiEngine object.
-     */
-    WikiEngine getEngine();
-
-    /**
      * Puts the page text into the repository.  Note that this method does NOT update
      * JSPWiki internal data structures, and therefore you should always use WikiEngine.saveText()
      *
@@ -356,17 +346,6 @@ public interface PageManager extends WikiEventListener {
     void deletePage( WikiPage page ) throws ProviderException;
 
     /**
-     * Listens for {@link org.apache.wiki.event.WikiSecurityEvent#PROFILE_NAME_CHANGED}
-     * events. If a user profile's name changes, each page ACL is inspected. If an entry contains
-     * a name that has changed, it is replaced with the new one. No events are emitted
-     * as a consequence of this method, because the page contents are still the same; it is
-     * only the representations of the names within the ACL that are changing.
-     *
-     * @param event The event
-     */
-    void actionPerformed(WikiEvent event);
-
-    /**
      * Returns the configured {@link PageSorter}.
      * 
      * @return the configured {@link PageSorter}.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.java
index 2630372..7e71e6e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.java
@@ -18,13 +18,6 @@
  */
 package org.apache.wiki.plugin;
 
-import java.text.SimpleDateFormat;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.ResourceBundle;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -33,10 +26,15 @@ import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.pages.PageLock;
-import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.util.TextUtil;
 
+import java.text.SimpleDateFormat;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Map;
+import java.util.ResourceBundle;
+
 /**
  * Builds a simple weblog.
  * <p/>
@@ -49,8 +47,8 @@ import org.apache.wiki.util.TextUtil;
  * @since 1.9.21
  */
 public class WeblogEntryPlugin implements WikiPlugin {
-    private static Logger log = Logger.getLogger(WeblogEntryPlugin.class);
 
+    private static final Logger log = Logger.getLogger(WeblogEntryPlugin.class);
     private static final int MAX_BLOG_ENTRIES = 10000; // Just a precaution.
 
     /**
@@ -58,8 +56,7 @@ public class WeblogEntryPlugin implements WikiPlugin {
      */
     public static final String PARAM_ENTRYTEXT = "entrytext";
     /**
-     * Optional parameter: page that actually contains the blog.
-     * This lets us provide a "new entry" link for a blog page
+     * Optional parameter: page that actually contains the blog. This lets us provide a "new entry" link for a blog page
      * somewhere else than on the page itself.
      */
     // "page" for uniform naming with WeblogPlugin...
@@ -69,97 +66,66 @@ public class WeblogEntryPlugin implements WikiPlugin {
     public static final String PARAM_BLOGNAME = "page";
 
     /**
-     * Returns a new page name for entries.  It goes through the list of
-     * all blog pages, and finds out the next in line.
+     * Returns a new page name for entries.  It goes through the list of all blog pages, and finds out the next in line.
      *
      * @param engine   A WikiEngine
      * @param blogName The page (or blog) name.
      * @return A new name.
      * @throws ProviderException If something goes wrong.
      */
-    public String getNewEntryPage(WikiEngine engine, String blogName)
-            throws ProviderException {
-        SimpleDateFormat fmt = new SimpleDateFormat(WeblogPlugin.DEFAULT_DATEFORMAT);
-        String today = fmt.format(new Date());
+    public String getNewEntryPage( final WikiEngine engine, final String blogName ) throws ProviderException {
+        final SimpleDateFormat fmt = new SimpleDateFormat(WeblogPlugin.DEFAULT_DATEFORMAT);
+        final String today = fmt.format(new Date());
+        final int entryNum = findFreeEntry( engine, blogName, today );
 
-        int entryNum = findFreeEntry(engine.getPageManager(),
-                blogName,
-                today);
-
-
-        String blogPage = WeblogPlugin.makeEntryPage(blogName,
-                today,
-                "" + entryNum);
-
-        return blogPage;
+        return WeblogPlugin.makeEntryPage( blogName, today,"" + entryNum );
     }
 
     /**
      * {@inheritDoc}
      */
-    public String execute(WikiContext context, Map<String, String> params)
-            throws PluginException {
-        ResourceBundle rb = Preferences.getBundle(context, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
+    public String execute( final WikiContext context, final Map< String, String > params ) throws PluginException {
+        final ResourceBundle rb = Preferences.getBundle(context, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
+        final WikiEngine engine = context.getEngine();
 
         String weblogName = params.get(PARAM_BLOGNAME);
         if (weblogName == null) {
             weblogName = context.getPage().getName();
         }
-        WikiEngine engine = context.getEngine();
 
-        StringBuilder sb = new StringBuilder();
-
-        String entryText = TextUtil.replaceEntities( params.get(PARAM_ENTRYTEXT) );
+        String entryText = TextUtil.replaceEntities( params.get( PARAM_ENTRYTEXT ) );
         if (entryText == null) {
             entryText = rb.getString("weblogentryplugin.newentry");
         }
 
-        String url = context.getURL(WikiContext.NONE, "NewBlogEntry.jsp", "page=" + engine.encodeName(weblogName));
-
-        sb.append("<a href=\"" + url + "\">" + entryText + "</a>");
-
-        return sb.toString();
+        final String url = context.getURL(WikiContext.NONE, "NewBlogEntry.jsp", "page=" + engine.encodeName( weblogName ) );
+        return "<a href=\"" + url + "\">" + entryText + "</a>";
     }
 
-    private int findFreeEntry(PageManager mgr,
-                              String baseName,
-                              String date)
-            throws ProviderException {
-        Collection< WikiPage > everyone = mgr.getAllPages();
+    private int findFreeEntry( final WikiEngine engine, final String baseName, final String date ) throws ProviderException {
+        final Collection< WikiPage > everyone = engine.getPageManager().getAllPages();
+        final String startString = WeblogPlugin.makeEntryPage(baseName, date, "");
         int max = 0;
 
-        String startString = WeblogPlugin.makeEntryPage(baseName, date, "");
-
-        for (Iterator< WikiPage > i = everyone.iterator(); i.hasNext(); ) {
-            WikiPage p = i.next();
-
-            if (p.getName().startsWith(startString)) {
+        for( final WikiPage p : everyone ) {
+            if( p.getName().startsWith( startString ) ) {
                 try {
-                    String probableId = p.getName().substring(startString.length());
-
-                    int id = Integer.parseInt(probableId);
-
-                    if (id > max) {
+                    final String probableId = p.getName().substring( startString.length() );
+                    final int id = Integer.parseInt( probableId );
+                    if( id > max ) {
                         max = id;
                     }
-                } catch (NumberFormatException e) {
-                    log.debug("Was not a log entry: " + p.getName());
+                } catch( final NumberFormatException e ) {
+                    log.debug( "Was not a log entry: " + p.getName() );
                 }
             }
         }
 
-        //
         //  Find the first page that has no page lock.
-        //
         int idx = max + 1;
-
-        while (idx < MAX_BLOG_ENTRIES) {
-            WikiPage page = new WikiPage(mgr.getEngine(),
-                    WeblogPlugin.makeEntryPage(baseName,
-                            date,
-                            Integer.toString(idx)));
-            PageLock lock = mgr.getCurrentLock(page);
-
+        while( idx < MAX_BLOG_ENTRIES ) {
+            final WikiPage page = new WikiPage( engine, WeblogPlugin.makeEntryPage( baseName, date, Integer.toString( idx ) ) );
+            final PageLock lock = engine.getPageManager().getCurrentLock(page);
             if (lock == null) {
                 break;
             }


[jspwiki] 02/32: JSPWIKI-120: getCurrentProvider() moved from WikiEngine to PageManager; getCurrentProviderInfo deleted from WikiEngine - use PageManager.getProviderDescription() instead

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 fcd0f5d33bac29d42ced17050673529ec3fea119
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 20:52:10 2020 +0100

    JSPWIKI-120: getCurrentProvider() moved from WikiEngine to PageManager; getCurrentProviderInfo deleted from WikiEngine - use PageManager.getProviderDescription() instead
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 23 ----------------------
 .../org/apache/wiki/pages/DefaultPageManager.java  | 14 +++++++++++--
 .../java/org/apache/wiki/pages/PageManager.java    |  7 +++++++
 .../wiki/variables/DefaultVariableManager.java     | 10 ++++------
 4 files changed, 23 insertions(+), 31 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 19a2eaa..836e10d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -1553,29 +1553,6 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the provider name.
-     *  @return The full class name of the current page provider.
-     */
-
-    public String getCurrentProvider()
-    {
-        return m_pageManager.getProvider().getClass().getName();
-    }
-
-    /**
-     *  Return information about current provider.  This method just calls
-     *  the corresponding PageManager method, which in turn calls the
-     *  provider method.
-     *
-     *  @return A textual description of the current provider.
-     *  @since 1.6.4
-     */
-    public String getCurrentProviderInfo()
-    {
-        return m_pageManager.getProviderDescription();
-    }
-
-    /**
      *  Returns a Collection of WikiPages, sorted in time
      *  order of last change (i.e. first object is the most
      *  recently changed).  This method also includes attachments.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index e4f97b9..d704b7f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -315,7 +315,16 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         return null;
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
+     * @see org.apache.wiki.pages.PageManager#getCurrentProvider()
+     */
+    public String getCurrentProvider() {
+        return getProvider().getClass().getName();
+    }
+
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getProviderDescription()
      */
     @Override
@@ -323,7 +332,8 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         return m_provider.getProviderInfo();
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getTotalPageCount()
      */
     @Override
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index 7337c8d..a78abca 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -138,6 +138,13 @@ public interface PageManager extends WikiEventListener {
     List<WikiPage> getVersionHistory(String pageName) throws ProviderException;
 
     /**
+     *  Returns the provider name.
+     *
+     *  @return The full class name of the current page provider.
+     */
+    String getCurrentProvider();
+
+    /**
      * Returns a human-readable description of the current provider.
      *
      * @return A human-readable description.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
index 171760d..2f82aa8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
@@ -346,14 +346,12 @@ public class DefaultVariableManager implements VariableManager {
             return Integer.toString( m_context.getEngine().getPageCount() );
         }
 
-        public String getPageprovider()
-        {
-            return m_context.getEngine().getCurrentProvider();
+        public String getPageprovider() {
+            return m_context.getEngine().getPageManager().getCurrentProvider();
         }
 
-        public String getPageproviderdescription()
-        {
-            return m_context.getEngine().getCurrentProviderInfo();
+        public String getPageproviderdescription() {
+            return m_context.getEngine().getPageManager().getProviderDescription();
         }
 
         public String getAttachmentprovider() {


[jspwiki] 23/32: rename WorkflowManager as DefaultWorkflowManager and extract interface (WorkflowManager) 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 86778fd4433435f8c3ab77e8379b99f92bc04298
Author: juanpablo <ju...@apache.org>
AuthorDate: Tue Jan 7 22:31:29 2020 +0100

    rename WorkflowManager as DefaultWorkflowManager and extract interface (WorkflowManager) from it
---
 .../wiki/workflow/DefaultWorkflowManager.java      | 260 +++++++++++++++++
 .../org/apache/wiki/workflow/WorkflowManager.java  | 315 ++++-----------------
 .../src/main/resources/ini/classmappings.xml       |   2 +-
 3 files changed, 312 insertions(+), 265 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
new file mode 100644
index 0000000..bec5649
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
@@ -0,0 +1,260 @@
+/* 
+    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.workflow;
+
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.exceptions.WikiException;
+import org.apache.wiki.auth.acl.UnresolvedPrincipal;
+import org.apache.wiki.event.WikiEvent;
+import org.apache.wiki.event.WikiEventListener;
+import org.apache.wiki.event.WorkflowEvent;
+
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+
+/**
+ * <p>
+ * Monitor class that tracks running Workflows. The WorkflowManager also keeps track of the names of
+ * users or groups expected to approve particular Workflows.
+ * </p>
+ */
+public class DefaultWorkflowManager implements WorkflowManager, WikiEventListener {
+
+    private final DecisionQueue m_queue = new DecisionQueue();
+    private final Set<Workflow> m_workflows;
+    private final Map<String, Principal> m_approvers;
+    private final List<Workflow> m_completed;
+    private WikiEngine m_engine = null;
+
+    /**
+     * Constructs a new WorkflowManager, with an empty workflow cache. New Workflows are automatically assigned unique identifiers,
+     * starting with 1.
+     */
+    public DefaultWorkflowManager() {
+        m_next = 1;
+        m_workflows = ConcurrentHashMap.newKeySet();
+        m_approvers = new ConcurrentHashMap<>();
+        m_completed = new CopyOnWriteArrayList<>();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void start( final Workflow workflow ) throws WikiException {
+        m_workflows.add( workflow );
+        workflow.setWorkflowManager( this );
+        workflow.setId( nextId() );
+        workflow.start();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Set< Workflow > getWorkflows() {
+        final Set< Workflow > workflows = ConcurrentHashMap.newKeySet();
+        workflows.addAll( m_workflows );
+        return workflows;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List< Workflow > getCompletedWorkflows() {
+        return new CopyOnWriteArrayList< >( m_completed );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void initialize( final WikiEngine engine, final Properties props ) {
+        m_engine = engine;
+
+        // Identify the workflows requiring approvals
+        for( final Object o : props.keySet() ) {
+            final String prop = ( String )o;
+            if( prop.startsWith( PROPERTY_APPROVER_PREFIX ) ) {
+                // For the key, everything after the prefix is the workflow name
+                final String key = prop.substring( PROPERTY_APPROVER_PREFIX.length() );
+                if( key.length() > 0 ) {
+                    // Only use non-null/non-blank approvers
+                    final String approver = props.getProperty( prop );
+                    if( approver != null && approver.length() > 0 ) {
+                        m_approvers.put( key, new UnresolvedPrincipal( approver ) );
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public boolean requiresApproval( final String messageKey ) {
+        return  m_approvers.containsKey( messageKey );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public Principal getApprover( final String messageKey ) throws WikiException {
+        Principal approver = m_approvers.get( messageKey );
+        if ( approver == null ) {
+            throw new WikiException( "Workflow '" + messageKey + "' does not require approval." );
+        }
+
+        // Try to resolve UnresolvedPrincipals
+        if ( approver instanceof UnresolvedPrincipal ) {
+            final String name = approver.getName();
+            approver = m_engine.getAuthorizationManager().resolvePrincipal( name );
+
+            // If still unresolved, throw exception; otherwise, freshen our cache
+            if ( approver instanceof UnresolvedPrincipal ) {
+                throw new WikiException( "Workflow approver '" + name + "' cannot not be resolved." );
+            }
+
+            m_approvers.put( messageKey, approver );
+        }
+        return approver;
+    }
+
+    /**
+     * Protected helper method that returns the associated WikiEngine
+     *
+     * @return the wiki engine
+     */
+    protected WikiEngine getEngine() {
+        if ( m_engine == null ) {
+            throw new IllegalStateException( "WikiEngine cannot be null; please initialize WorkflowManager first." );
+        }
+        return m_engine;
+    }
+
+    /**
+     * Returns the DecisionQueue associated with this WorkflowManager
+     *
+     * @return the decision queue
+     */
+    public DecisionQueue getDecisionQueue()
+    {
+        return m_queue;
+    }
+
+    private volatile int m_next;
+
+    /**
+     * Returns the next available unique identifier, which is subsequently
+     * incremented.
+     *
+     * @return the id
+     */
+    private synchronized int nextId() {
+        final int current = m_next;
+        m_next++;
+        return current;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public List< Workflow > getOwnerWorkflows( final WikiSession session ) {
+        final List< Workflow > workflows = new ArrayList<>();
+        if ( session.isAuthenticated() ) {
+            final Principal[] sessionPrincipals = session.getPrincipals();
+            for( final Workflow w : m_workflows ) {
+                final Principal owner = w.getOwner();
+                for ( final Principal sessionPrincipal : sessionPrincipals ) {
+                    if ( sessionPrincipal.equals( owner ) ) {
+                        workflows.add( w );
+                        break;
+                    }
+                }
+            }
+        }
+        return workflows;
+    }
+
+    /**
+     * Listens for {@link WorkflowEvent} objects emitted by Workflows. In particular, this
+     * method listens for {@link WorkflowEvent#CREATED},
+     * {@link WorkflowEvent#ABORTED} and {@link WorkflowEvent#COMPLETED}
+     * events. If a workflow is created, it is automatically added to the cache. If one is aborted or completed, it 
+     * is automatically removed.
+     * 
+     * @param event the event passed to this listener
+     */
+    @Override
+    public void actionPerformed( final WikiEvent event ) {
+        if( event instanceof WorkflowEvent ) {
+            final Workflow workflow = event.getSrc();
+            switch ( event.getType() ) {
+                 // Remove from manager
+                 case WorkflowEvent.ABORTED   :
+                 case WorkflowEvent.COMPLETED : remove( workflow ); break;
+                // Add to manager
+                case WorkflowEvent.CREATED    : add( workflow ); break;
+                default: break;
+            }
+        }
+    }
+
+    /**
+     * Protected helper method that adds a newly created Workflow to the cache, and sets its {@code workflowManager} and
+     * {@code Id} properties if not set.
+     *
+     * @param workflow the workflow to add
+     */
+    protected void add( final Workflow workflow ) {
+        if ( workflow.getWorkflowManager() == null ) {
+            workflow.setWorkflowManager( this );
+        }
+        if ( workflow.getId() == Workflow.ID_NOT_SET ) {
+            workflow.setId( nextId() );
+        }
+        m_workflows.add( workflow );
+    }
+
+    /**
+     * Protected helper method that removes a specified Workflow from the cache, and moves it to the workflow history list. This method
+     * defensively checks to see if the workflow has not yet been removed.
+     *
+     * @param workflow the workflow to remove
+     */
+    protected void remove( final Workflow workflow ) {
+        if( m_workflows.contains( workflow ) ) {
+            m_workflows.remove( workflow );
+            m_completed.add( workflow );
+        }
+    }
+
+}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
index cb05a7e..8fe46cb 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
@@ -18,345 +18,132 @@
  */
 package org.apache.wiki.workflow;
 
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.exceptions.WikiException;
+
 import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
-import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.apache.wiki.WikiEngine;
-import org.apache.wiki.WikiSession;
-import org.apache.wiki.api.exceptions.WikiException;
-import org.apache.wiki.auth.acl.UnresolvedPrincipal;
-import org.apache.wiki.event.WikiEvent;
-import org.apache.wiki.event.WikiEventListener;
-import org.apache.wiki.event.WorkflowEvent;
 
 
 /**
  * <p>
- * Monitor class that tracks running Workflows. The WorkflowManager also keeps track of the names of
- * users or groups expected to approve particular Workflows.
+ * Monitor class that tracks running Workflows. The WorkflowManager also keeps track of the names of users or groups expected to approve
+ * particular Workflows.
  * </p>
  */
-public class WorkflowManager implements WikiEventListener {
+public interface WorkflowManager {
 
     /** The workflow attribute which stores the wikiContext. */
-    public static final String WF_WP_SAVE_ATTR_PRESAVE_WIKI_CONTEXT = "wikiContext";
+    String WF_WP_SAVE_ATTR_PRESAVE_WIKI_CONTEXT = "wikiContext";
     /** The name of the key from jspwiki.properties which defines who shall approve the workflow of storing a wikipage.  Value is <tt>{@value}</tt> */
-    public static final String WF_WP_SAVE_APPROVER = "workflow.saveWikiPage";
+    String WF_WP_SAVE_APPROVER = "workflow.saveWikiPage";
     /** The message key for storing the Decision text for saving a page.  Value is {@value}. */
-    public static final String WF_WP_SAVE_DECISION_MESSAGE_KEY = "decision.saveWikiPage";
+    String WF_WP_SAVE_DECISION_MESSAGE_KEY = "decision.saveWikiPage";
     /** The message key for rejecting the decision to save the page.  Value is {@value}. */
-    public static final String WF_WP_SAVE_REJECT_MESSAGE_KEY = "notification.saveWikiPage.reject";
+    String WF_WP_SAVE_REJECT_MESSAGE_KEY = "notification.saveWikiPage.reject";
     /** Fact name for storing the page name.  Value is {@value}. */
-    public static final String WF_WP_SAVE_FACT_PAGE_NAME = "fact.pageName";
+    String WF_WP_SAVE_FACT_PAGE_NAME = "fact.pageName";
     /** Fact name for storing a diff text. Value is {@value}. */
-    public static final String WF_WP_SAVE_FACT_DIFF_TEXT = "fact.diffText";
+    String WF_WP_SAVE_FACT_DIFF_TEXT = "fact.diffText";
     /** Fact name for storing the current text.  Value is {@value}. */
-    public static final String WF_WP_SAVE_FACT_CURRENT_TEXT = "fact.currentText";
+    String WF_WP_SAVE_FACT_CURRENT_TEXT = "fact.currentText";
     /** Fact name for storing the proposed (edited) text.  Value is {@value}. */
-    public static final String WF_WP_SAVE_FACT_PROPOSED_TEXT = "fact.proposedText";
+    String WF_WP_SAVE_FACT_PROPOSED_TEXT = "fact.proposedText";
     /** Fact name for storing whether the user is authenticated or not.  Value is {@value}. */
-    public static final String WF_WP_SAVE_FACT_IS_AUTHENTICATED = "fact.isAuthenticated";
+    String WF_WP_SAVE_FACT_IS_AUTHENTICATED = "fact.isAuthenticated";
 
     /** The workflow attribute which stores the user profile. */
-    public static final String WF_UP_CREATE_SAVE_ATTR_SAVED_PROFILE = "userProfile";
+    String WF_UP_CREATE_SAVE_ATTR_SAVED_PROFILE = "userProfile";
     /** The name of the key from jspwiki.properties which defines who shall approve the workflow of creating a user profile.  Value is <tt>{@value}</tt> */
-    public static final String WF_UP_CREATE_SAVE_APPROVER = "workflow.createUserProfile";
+    String WF_UP_CREATE_SAVE_APPROVER = "workflow.createUserProfile";
     /** The message key for storing the Decision text for saving a user profile.  Value is {@value}. */
-    public static final String WF_UP_CREATE_SAVE_DECISION_MESSAGE_KEY = "decision.createUserProfile";
+    String WF_UP_CREATE_SAVE_DECISION_MESSAGE_KEY = "decision.createUserProfile";
     /** Fact name for storing a the submitter name. Value is {@value}. */
-    public static final String WF_UP_CREATE_SAVE_FACT_SUBMITTER = "fact.submitter";
+    String WF_UP_CREATE_SAVE_FACT_SUBMITTER = "fact.submitter";
     /** Fact name for storing the preferences' login name. Value is {@value}. */
-    public static final String WF_UP_CREATE_SAVE_FACT_PREFS_LOGIN_NAME = "prefs.loginname";
+    String WF_UP_CREATE_SAVE_FACT_PREFS_LOGIN_NAME = "prefs.loginname";
     /** Fact name for storing the preferences' full name. Value is {@value}. */
-    public static final String WF_UP_CREATE_SAVE_FACT_PREFS_FULL_NAME = "prefs.fullname";
+    String WF_UP_CREATE_SAVE_FACT_PREFS_FULL_NAME = "prefs.fullname";
     /** Fact name for storing the preferences' email. Value is {@value}. */
-    public static final String WF_UP_CREATE_SAVE_FACT_PREFS_EMAIL = "prefs.email";
-
-    private final DecisionQueue m_queue = new DecisionQueue();
-
-    private final Set<Workflow> m_workflows;
-
-    private final Map<String, Principal> m_approvers;
-
-    private final List<Workflow> m_completed;
+    String WF_UP_CREATE_SAVE_FACT_PREFS_EMAIL = "prefs.email";
 
     /** The prefix to use for looking up <code>jspwiki.properties</code> approval roles. */
-    protected static final String PROPERTY_APPROVER_PREFIX = "jspwiki.approver.";
-
-    /**
-     * Constructs a new WorkflowManager, with an empty workflow cache. New
-     * Workflows are automatically assigned unique identifiers, starting with 1.
-     */
-    public WorkflowManager()
-    {
-        m_next = 1;
-        m_workflows = ConcurrentHashMap.newKeySet();
-        m_approvers = new ConcurrentHashMap<>();
-        m_completed = new CopyOnWriteArrayList<>();
-    }
+    String PROPERTY_APPROVER_PREFIX = "jspwiki.approver.";
 
     /**
-     * Adds a new workflow to the set of workflows and starts it. The new
-     * workflow is automatically assigned a unique ID. If another workflow with
-     * the same ID already exists, this method throws a WikIException.
+     * Adds a new workflow to the set of workflows and starts it. The new workflow is automatically assigned a unique ID. If another
+     * workflow with the same ID already exists, this method throws a WikIException.
+     *
      * @param workflow the workflow to start
-     * @throws WikiException if a workflow the automatically assigned
-     * ID already exist; this should not happen normally
+     * @throws WikiException if a workflow the automatically assigned ID already exist; this should not happen normally
      */
-    public void start( Workflow workflow ) throws WikiException
-    {
-        m_workflows.add( workflow );
-        workflow.setWorkflowManager( this );
-        workflow.setId( nextId() );
-        workflow.start();
-    }
+    void start( Workflow workflow ) throws WikiException;
 
     /**
      * Returns a collection of the currently active workflows.
      *
      * @return the current workflows
      */
-    public Collection< Workflow > getWorkflows() {
-        Set< Workflow > workflows = ConcurrentHashMap.newKeySet();
-        workflows.addAll( m_workflows );
-        return workflows;
-    }
+    Set< Workflow > getWorkflows();
 
     /**
      * Returns a collection of finished workflows; that is, those that have aborted or completed.
+     *
      * @return the finished workflows
      */
-    public List< Workflow > getCompletedWorkflows() {
-        return new CopyOnWriteArrayList< >( m_completed );
-    }
-
-    private WikiEngine m_engine = null;
+    List< Workflow > getCompletedWorkflows();
 
     /**
-     * Initializes the WorkflowManager using a specfied WikiEngine and
-     * properties. Any properties that begin with
-     * {@link #PROPERTY_APPROVER_PREFIX} will be assumed to be
-     * Decisions that require approval. For a given property key, everything
-     * after the prefix denotes the Decision's message key. The property
-     * value indicates the Principal (Role, GroupPrincipal, WikiPrincipal) that
-     * must approve the Decision. For example, if the property key/value pair
-     * is <code>jspwiki.approver.workflow.saveWikiPage=Admin</code>,
-     * the Decision's message key is <code>workflow.saveWikiPage</code>.
-     * The Principal <code>Admin</code> will be resolved via
+     * Initializes the WorkflowManager using a specfied WikiEngine and properties. Any properties that begin with
+     * {@link #PROPERTY_APPROVER_PREFIX} will be assumed to be Decisions that require approval. For a given property key, everything
+     * after the prefix denotes the Decision's message key. The property value indicates the Principal (Role, GroupPrincipal, WikiPrincipal)
+     * that must approve the Decision. For example, if the property key/value pair is {@code jspwiki.approver.workflow.saveWikiPage=Admin},
+     * the Decision's message key is <code>workflow.saveWikiPage</code>. The Principal <code>Admin</code> will be resolved via
      * {@link org.apache.wiki.auth.AuthorizationManager#resolvePrincipal(String)}.
+     *
      * @param engine the wiki engine to associate with this WorkflowManager
      * @param props the wiki engine's properties
      */
-    public void initialize( WikiEngine engine, Properties props )
-    {
-        m_engine = engine;
-
-        // Identify the workflows requiring approvals
-        for ( Iterator<?> it = props.keySet().iterator(); it.hasNext(); )
-        {
-            String prop = (String) it.next();
-            if ( prop.startsWith( PROPERTY_APPROVER_PREFIX ) )
-            {
-
-                // For the key, everything after the prefix is the workflow name
-                String key = prop.substring( PROPERTY_APPROVER_PREFIX.length() );
-                if ( key != null && key.length() > 0 )
-                {
-
-                    // Only use non-null/non-blank approvers
-                    String approver = props.getProperty( prop );
-                    if ( approver != null && approver.length() > 0 )
-                    {
-                        m_approvers.put( key, new UnresolvedPrincipal( approver ) );
-                    }
-                }
-            }
-        }
-    }
+    void initialize( WikiEngine engine, Properties props );
 
     /**
-     * Returns <code>true</code> if a workflow matching a particular key
-     * contains an approval step.
+     * Returns <code>true</code> if a workflow matching a particular key contains an approval step.
      *
-     * @param messageKey
-     *            the name of the workflow; corresponds to the value returned by
-     *            {@link Workflow#getMessageKey()}.
+     * @param messageKey the name of the workflow; corresponds to the value returned by {@link Workflow#getMessageKey()}.
      * @return the result
      */
-    public boolean requiresApproval( String messageKey )
-    {
-        return  m_approvers.containsKey( messageKey );
-    }
+    boolean requiresApproval( String messageKey );
 
     /**
-     * Looks up and resolves the actor who approves a Decision for a particular
-     * Workflow, based on the Workflow's message key. If not found, or if
-     * Principal is Unresolved, throws WikiException. This particular
-     * implementation always returns the GroupPrincipal <code>Admin</code>
+     * Looks up and resolves the actor who approves a Decision for a particular Workflow, based on the Workflow's message key.
+     * If not found, or if Principal is Unresolved, throws WikiException. This particular implementation always returns the
+     * GroupPrincipal <code>Admin</code>
      *
      * @param messageKey the Decision's message key
      * @return the actor who approves Decisions
      * @throws WikiException if the message key was not found, or the
      * Principal value corresponding to the key could not be resolved
      */
-    public Principal getApprover( String messageKey ) throws WikiException
-    {
-        Principal approver = m_approvers.get( messageKey );
-        if ( approver == null )
-        {
-            throw new WikiException( "Workflow '" + messageKey + "' does not require approval." );
-        }
-
-        // Try to resolve UnresolvedPrincipals
-        if ( approver instanceof UnresolvedPrincipal )
-        {
-            String name = approver.getName();
-            approver = m_engine.getAuthorizationManager().resolvePrincipal( name );
-
-            // If still unresolved, throw exception; otherwise, freshen our
-            // cache
-            if ( approver instanceof UnresolvedPrincipal )
-            {
-                throw new WikiException( "Workflow approver '" + name + "' cannot not be resolved." );
-            }
-
-            m_approvers.put( messageKey, approver );
-        }
-        return approver;
-    }
-
-    /**
-     * Protected helper method that returns the associated WikiEngine
-     *
-     * @return the wiki engine
-     */
-    protected WikiEngine getEngine()
-    {
-        if ( m_engine == null )
-        {
-            throw new IllegalStateException( "WikiEngine cannot be null; please initialize WorkflowManager first." );
-        }
-        return m_engine;
-    }
+    Principal getApprover( String messageKey ) throws WikiException;
 
     /**
      * Returns the DecisionQueue associated with this WorkflowManager
      *
      * @return the decision queue
      */
-    public DecisionQueue getDecisionQueue()
-    {
-        return m_queue;
-    }
-
-    private volatile int m_next;
+    DecisionQueue getDecisionQueue();
 
     /**
-     * Returns the next available unique identifier, which is subsequently
-     * incremented.
+     * Returns the current workflows a wiki session owns. These are workflows whose {@link Workflow#getOwner()} method returns a Principal
+     * also possessed by the wiki session (see {@link org.apache.wiki.WikiSession#getPrincipals()}). If the wiki session is not
+     * authenticated, this method returns an empty Collection.
      *
-     * @return the id
-     */
-    private synchronized int nextId()
-    {
-        int current = m_next;
-        m_next++;
-        return current;
-    }
-
-    /**
-     * Returns the current workflows a wiki session owns. These are workflows whose
-     * {@link Workflow#getOwner()} method returns a Principal also possessed by the
-     * wiki session (see {@link org.apache.wiki.WikiSession#getPrincipals()}). If the
-     * wiki session is not authenticated, this method returns an empty Collection.
      * @param session the wiki session
      * @return the collection workflows the wiki session owns, which may be empty
      */
-    public Collection< Workflow > getOwnerWorkflows( WikiSession session ) {
-        List<Workflow> workflows = new ArrayList<>();
-        if ( session.isAuthenticated() ) {
-            Principal[] sessionPrincipals = session.getPrincipals();
-            for ( Workflow w : m_workflows ) {
-                Principal owner = w.getOwner();
-                for ( Principal sessionPrincipal : sessionPrincipals ) {
-                    if ( sessionPrincipal.equals( owner ) ) {
-                        workflows.add( w );
-                        break;
-                    }
-                }
-            }
-        }
-        return workflows;
-    }
-
-    /**
-     * Listens for {@link org.apache.wiki.event.WorkflowEvent} objects emitted by Workflows. In particular, this 
-     * method listens for {@link org.apache.wiki.event.WorkflowEvent#CREATED}, 
-     * {@link org.apache.wiki.event.WorkflowEvent#ABORTED} and {@link org.apache.wiki.event.WorkflowEvent#COMPLETED} 
-     * events. If a workflow is created, it is automatically added to the cache. If one is aborted or completed, it 
-     * is automatically removed.
-     * 
-     * @param event the event passed to this listener
-     */
-    @Override
-    public void actionPerformed(WikiEvent event) {
-        if (event instanceof WorkflowEvent) {
-            Workflow workflow = event.getSrc();
-            switch ( event.getType() ) {
-                case WorkflowEvent.ABORTED:
-                    // Remove from manager
-                    remove( workflow );
-                    break;
-                case WorkflowEvent.COMPLETED:
-                    // Remove from manager
-                    remove( workflow );
-                    break;
-                case WorkflowEvent.CREATED:
-                    // Add to manager
-                    add( workflow );
-                    break;
-                default:
-                    break;
-            }
-        }
-    }
-
-    /**
-     * Protected helper method that adds a newly created Workflow to the cache, and sets its 
-     * <code>workflowManager</code> and <code>Id</code> properties if not set.
-     *
-     * @param workflow the workflow to add
-     */
-    protected void add( Workflow workflow ) {
-        if ( workflow.getWorkflowManager() == null ) {
-            workflow.setWorkflowManager( this );
-        }
-        if ( workflow.getId() == Workflow.ID_NOT_SET ) {
-            workflow.setId( nextId() );
-        }
-        m_workflows.add( workflow );
-    }
-
-    /**
-     * Protected helper method that removes a specified Workflow from the cache,
-     * and moves it to the workflow history list. This method defensively
-     * checks to see if the workflow has not yet been removed.
-     *
-     * @param workflow the workflow to remove
-     */
-    protected void remove(Workflow workflow) {
-        if ( m_workflows.contains( workflow ) ) {
-            m_workflows.remove( workflow );
-            m_completed.add( workflow );
-        }
-    }
+    List< Workflow > getOwnerWorkflows( WikiSession session );
 
 }
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index 192a1ea..e005819 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -129,6 +129,6 @@
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.workflow.WorkflowManager</requestedClass>
-    <mappedClass>org.apache.wiki.workflow.WorkflowManager</mappedClass>
+    <mappedClass>org.apache.wiki.workflow.DefaultWorkflowManager</mappedClass>
   </mapping>
 </classmappings>


[jspwiki] 04/32: apply formats 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 27d799e6757c6af935d7bf1e8b25e6c6d0dfda7c
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 21:10:38 2020 +0100

    apply formats and fixes suggested by IntelliJ
---
 .../org/apache/wiki/pages/DefaultPageManager.java  | 204 ++++++++++-----------
 1 file changed, 100 insertions(+), 104 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index d704b7f..945c401 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -74,15 +74,13 @@ import java.util.concurrent.ConcurrentHashMap;
 //        from WikiEngine (which is too big now) into this class.
 public class DefaultPageManager extends ModuleManager implements PageManager {
 
-    private static final Logger LOG = Logger.getLogger(DefaultPageManager.class);
+    private static final Logger LOG = Logger.getLogger( DefaultPageManager.class );
 
     private WikiPageProvider m_provider;
 
-    protected ConcurrentHashMap<String, PageLock> m_pageLocks = new ConcurrentHashMap<>();
+    protected ConcurrentHashMap< String, PageLock > m_pageLocks = new ConcurrentHashMap<>();
 
-    //private WikiEngine m_engine;   //inherited protected field from the ModuleManager
-
-    private int m_expiryTime = 60;
+    private int m_expiryTime;
 
     private LockReaper m_reaper = null;
 
@@ -184,7 +182,8 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         return text;
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getEngine()
      */
     @Override
@@ -192,11 +191,12 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         return m_engine;
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#putPageText(org.apache.wiki.WikiPage, java.lang.String)
      */
     @Override
-    public void putPageText(WikiPage page, String content) throws ProviderException {
+    public void putPageText( final WikiPage page, final String content ) throws ProviderException {
         if (page == null || page.getName() == null || page.getName().length() == 0) {
             throw new ProviderException("Illegal page name");
         }
@@ -204,11 +204,12 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         m_provider.putPageText(page, content);
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#lockPage(org.apache.wiki.WikiPage, java.lang.String)
      */
     @Override
-    public PageLock lockPage(WikiPage page, String user) {
+    public PageLock lockPage( final WikiPage page, final String user) {
         if (m_reaper == null) {
             //
             //  Start the lock reaper lazily.  We don't want to start it in
@@ -227,7 +228,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
             //
             //  Lock is available, so make a lock.
             //
-            Date d = new Date();
+            final Date d = new Date();
             lock = new PageLock(page, user, d, new Date(d.getTime() + m_expiryTime * 60 * 1000L));
             m_pageLocks.put(page.getName(), lock);
             LOG.debug("Locked page " + page.getName() + " for " + user);
@@ -239,44 +240,42 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         return lock;
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#unlockPage(org.apache.wiki.pages.PageLock)
      */
     @Override
-    public void unlockPage(PageLock lock) {
+    public void unlockPage( final PageLock lock ) {
         if (lock == null) {
             return;
         }
 
-        m_pageLocks.remove(lock.getPage());
-        LOG.debug("Unlocked page " + lock.getPage());
+        m_pageLocks.remove( lock.getPage() );
+        LOG.debug( "Unlocked page " + lock.getPage() );
 
-        fireEvent(WikiPageEvent.PAGE_UNLOCK, lock.getPage());
+        fireEvent( WikiPageEvent.PAGE_UNLOCK, lock.getPage() );
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getCurrentLock(org.apache.wiki.WikiPage)
      */
     @Override
-    public PageLock getCurrentLock(WikiPage page) {
-        return m_pageLocks.get(page.getName());
+    public PageLock getCurrentLock( final WikiPage page ) {
+        return m_pageLocks.get( page.getName() );
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getActiveLocks()
      */
     @Override
-    public List<PageLock> getActiveLocks() {
-        ArrayList<PageLock> result = new ArrayList<>();
-
-        for (PageLock lock : m_pageLocks.values()) {
-            result.add(lock);
-        }
-
-        return result;
+    public List< PageLock > getActiveLocks() {
+        return  new ArrayList<>( m_pageLocks.values() );
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getPageInfo(java.lang.String, int)
      */
     @Override
@@ -303,13 +302,14 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         return page;
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getVersionHistory(java.lang.String)
      */
     @Override
-    public List< WikiPage > getVersionHistory(String pageName) throws ProviderException {
-        if (pageExists(pageName)) {
-            return m_provider.getVersionHistory(pageName);
+    public List< WikiPage > getVersionHistory( final String pageName ) throws ProviderException {
+        if( pageExists( pageName ) ) {
+            return m_provider.getVersionHistory( pageName );
         }
 
         return null;
@@ -340,17 +340,18 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
     public int getTotalPageCount() {
         try {
             return m_provider.getAllPages().size();
-        } catch (ProviderException e) {
-            LOG.error("Unable to count pages: ", e);
+        } catch( final ProviderException e ) {
+            LOG.error( "Unable to count pages: ", e );
             return -1;
         }
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#pageExists(java.lang.String)
      */
     @Override
-    public boolean pageExists(String pageName) throws ProviderException {
+    public boolean pageExists( final String pageName ) throws ProviderException {
         if (pageName == null || pageName.length() == 0) {
             throw new ProviderException("Illegal page name");
         }
@@ -358,11 +359,12 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         return m_provider.pageExists(pageName);
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#pageExists(java.lang.String, int)
      */
     @Override
-    public boolean pageExists(String pageName, int version) throws ProviderException {
+    public boolean pageExists( final String pageName, final int version ) throws ProviderException {
         if (pageName == null || pageName.length() == 0) {
             throw new ProviderException("Illegal page name");
         }
@@ -381,7 +383,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
     @Override
     public void deleteVersion( final WikiPage page ) throws ProviderException {
         if( page instanceof Attachment ) {
-            m_engine.getAttachmentManager().deleteVersion( (Attachment) page );
+            m_engine.getAttachmentManager().deleteVersion( ( Attachment )page );
         } else {
             m_provider.deleteVersion(page.getName(), page.getVersion());
             // FIXME: If this was the latest, reindex Lucene
@@ -423,10 +425,10 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * @see org.apache.wiki.pages.PageManager#deletePage(org.apache.wiki.WikiPage)
      */
     @Override
-    public void deletePage(WikiPage page) throws ProviderException {
-        fireEvent(WikiPageEvent.PAGE_DELETE_REQUEST, page.getName());
-        m_provider.deletePage(page.getName());
-        fireEvent(WikiPageEvent.PAGE_DELETED, page.getName());
+    public void deletePage( final WikiPage page ) throws ProviderException {
+        fireEvent( WikiPageEvent.PAGE_DELETE_REQUEST, page.getName() );
+        m_provider.deletePage( page.getName() );
+        fireEvent( WikiPageEvent.PAGE_DELETED, page.getName() );
     }
 
     /**
@@ -440,24 +442,24 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
          *
          * @param engine WikiEngine to own this thread.
          */
-        public LockReaper(WikiEngine engine) {
+        public LockReaper( final WikiEngine engine) {
             super(engine, 60);
             setName("JSPWiki Lock Reaper");
         }
 
         @Override
-        public void backgroundTask() throws Exception {
-            Collection<PageLock> entries = m_pageLocks.values();
-            for (Iterator<PageLock> i = entries.iterator(); i.hasNext(); ) {
-                PageLock p = i.next();
+        public void backgroundTask() {
+            final Collection< PageLock > entries = m_pageLocks.values();
+            for( final Iterator<PageLock> i = entries.iterator(); i.hasNext(); ) {
+                final PageLock p = i.next();
 
                 if ( p.isExpired() ) {
                     i.remove();
 
-                    LOG.debug("Reaped lock: " + p.getPage() +
-                              " by " + p.getLocker() +
-                              ", acquired " + p.getAcquisitionTime() +
-                              ", and expired " + p.getExpiryTime());
+                    LOG.debug( "Reaped lock: " + p.getPage() +
+                               " by " + p.getLocker() +
+                               ", acquired " + p.getAcquisitionTime() +
+                               ", and expired " + p.getExpiryTime() );
                 }
             }
         }
@@ -473,9 +475,9 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * @param pagename the wiki page name as a String
      * @see org.apache.wiki.event.WikiPageEvent
      */
-    protected final void fireEvent(int type, String pagename) {
-        if (WikiEventManager.isListening(this)) {
-            WikiEventManager.fireEvent(this, new WikiPageEvent(m_engine, type, pagename));
+    protected final void fireEvent( final int type, final String pagename ) {
+        if( WikiEventManager.isListening( this ) ) {
+            WikiEventManager.fireEvent( this, new WikiPageEvent( m_engine, type, pagename ) );
         }
     }
 
@@ -492,7 +494,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      *  {@inheritDoc}
      */
     @Override
-    public WikiModuleInfo getModuleInfo(String moduleName) {
+    public WikiModuleInfo getModuleInfo( final String moduleName ) {
     	return null;
     }
 
@@ -500,72 +502,68 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * @see org.apache.wiki.pages.PageManager#actionPerformed(org.apache.wiki.event.WikiEvent)
      */
     @Override
-    public void actionPerformed(WikiEvent event) {
-        if (!(event instanceof WikiSecurityEvent)) {
+    public void actionPerformed( final WikiEvent event ) {
+        if( !( event instanceof WikiSecurityEvent ) ) {
             return;
         }
 
-        WikiSecurityEvent se = (WikiSecurityEvent) event;
-        if (se.getType() == WikiSecurityEvent.PROFILE_NAME_CHANGED) {
-            UserProfile[] profiles = (UserProfile[]) se.getTarget();
-            Principal[] oldPrincipals = new Principal[]
-                    {new WikiPrincipal(profiles[0].getLoginName()),
-                            new WikiPrincipal(profiles[0].getFullname()),
-                            new WikiPrincipal(profiles[0].getWikiName())};
-            Principal newPrincipal = new WikiPrincipal(profiles[1].getFullname());
+        final WikiSecurityEvent se = ( WikiSecurityEvent ) event;
+        if( se.getType() == WikiSecurityEvent.PROFILE_NAME_CHANGED ) {
+            final UserProfile[] profiles = (UserProfile[]) se.getTarget();
+            final Principal[] oldPrincipals = new Principal[] { new WikiPrincipal( profiles[ 0 ].getLoginName() ),
+                                                                new WikiPrincipal( profiles[ 0 ].getFullname()),
+                                                                new WikiPrincipal( profiles[ 0 ].getWikiName() ) };
+            final Principal newPrincipal = new WikiPrincipal( profiles[ 1 ].getFullname() );
 
             // Examine each page ACL
             try {
                 int pagesChanged = 0;
-                Collection< WikiPage > pages = getAllPages();
-                for (Iterator< WikiPage > it = pages.iterator(); it.hasNext(); ) {
-                    WikiPage page = it.next();
-                    boolean aclChanged = changeAcl(page, oldPrincipals, newPrincipal);
-                    if (aclChanged) {
+                final Collection< WikiPage > pages = getAllPages();
+                for( final WikiPage page : pages ) {
+                    final boolean aclChanged = changeAcl( page, oldPrincipals, newPrincipal );
+                    if( aclChanged ) {
                         // If the Acl needed changing, change it now
                         try {
-                            m_engine.getAclManager().setPermissions(page, page.getAcl());
-                        } catch (WikiSecurityException e) {
+                            m_engine.getAclManager().setPermissions( page, page.getAcl() );
+                        } catch( final WikiSecurityException e ) {
                             LOG.error("Could not change page ACL for page " + page.getName() + ": " + e.getMessage(), e);
                         }
                         pagesChanged++;
                     }
                 }
-                LOG.info("Profile name change for '" + newPrincipal.toString() +
-                        "' caused " + pagesChanged + " page ACLs to change also.");
-            } catch (ProviderException e) {
+                LOG.info( "Profile name change for '" + newPrincipal.toString() + "' caused " + pagesChanged + " page ACLs to change also." );
+            } catch( final ProviderException e ) {
                 // Oooo! This is really bad...
-                LOG.error("Could not change user name in Page ACLs because of Provider error:" + e.getMessage(), e);
+                LOG.error( "Could not change user name in Page ACLs because of Provider error:" + e.getMessage(), e );
             }
         }
     }
 
     /**
-     * For a single wiki page, replaces all Acl entries matching a supplied array of Principals
-     * with a new Principal.
+     * For a single wiki page, replaces all Acl entries matching a supplied array of Principals with a new Principal.
      *
-     * @param page          the wiki page whose Acl is to be modified
-     * @param oldPrincipals an array of Principals to replace; all AclEntry objects whose
-     *                      {@link AclEntry#getPrincipal()} method returns one of these Principals will be replaced
-     * @param newPrincipal  the Principal that should receive the old Principals' permissions
+     * @param page the wiki page whose Acl is to be modified
+     * @param oldPrincipals an array of Principals to replace; all AclEntry objects whose {@link AclEntry#getPrincipal()} method returns
+     *                      one of these Principals will be replaced
+     * @param newPrincipal the Principal that should receive the old Principals' permissions
      * @return <code>true</code> if the Acl was actually changed; <code>false</code> otherwise
      */
-    protected boolean changeAcl(WikiPage page, Principal[] oldPrincipals, Principal newPrincipal) {
-        Acl acl = page.getAcl();
+    protected boolean changeAcl( final WikiPage page, final Principal[] oldPrincipals, final Principal newPrincipal ) {
+        final Acl acl = page.getAcl();
         boolean pageChanged = false;
-        if (acl != null) {
-            Enumeration<AclEntry> entries = acl.entries();
-            Collection<AclEntry> entriesToAdd = new ArrayList<>();
-            Collection<AclEntry> entriesToRemove = new ArrayList<>();
-            while (entries.hasMoreElements()) {
-                AclEntry entry = entries.nextElement();
-                if (ArrayUtils.contains(oldPrincipals, entry.getPrincipal())) {
+        if( acl != null ) {
+            final Enumeration< AclEntry > entries = acl.entries();
+            final Collection< AclEntry > entriesToAdd = new ArrayList<>();
+            final Collection< AclEntry > entriesToRemove = new ArrayList<>();
+            while( entries.hasMoreElements() ) {
+                final AclEntry entry = entries.nextElement();
+                if( ArrayUtils.contains(oldPrincipals, entry.getPrincipal() ) ) {
                     // Create new entry
-                    AclEntry newEntry = new AclEntryImpl();
-                    newEntry.setPrincipal(newPrincipal);
-                    Enumeration<Permission> permissions = entry.permissions();
-                    while (permissions.hasMoreElements()) {
-                        Permission permission = permissions.nextElement();
+                    final AclEntry newEntry = new AclEntryImpl();
+                    newEntry.setPrincipal( newPrincipal );
+                    final Enumeration<Permission> permissions = entry.permissions();
+                    while( permissions.hasMoreElements() ) {
+                        final Permission permission = permissions.nextElement();
                         newEntry.addPermission(permission);
                     }
                     pageChanged = true;
@@ -573,13 +571,11 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
                     entriesToAdd.add(newEntry);
                 }
             }
-            for (Iterator<AclEntry> ix = entriesToRemove.iterator(); ix.hasNext(); ) {
-                AclEntry entry = ix.next();
-                acl.removeEntry(entry);
+            for( final AclEntry entry : entriesToRemove ) {
+                acl.removeEntry( entry );
             }
-            for (Iterator<AclEntry> ix = entriesToAdd.iterator(); ix.hasNext(); ) {
-                AclEntry entry = ix.next();
-                acl.addEntry(entry);
+            for( final AclEntry entry : entriesToAdd ) {
+                acl.addEntry( entry );
             }
         }
         return pageChanged;


[jspwiki] 30/32: remove FIXME tag - actually done! :-)

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 5e84989bf962b8e5d324ae4312ebb7e7d1405ddd
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 9 21:10:31 2020 +0100

    remove FIXME tag - actually done! :-)
---
 .../main/java/org/apache/wiki/pages/DefaultPageManager.java  | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index c30113f..324d347 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -71,18 +71,14 @@ import java.util.concurrent.ConcurrentHashMap;
 
 
 /**
- * Manages the WikiPages.  This class functions as an unified interface towards
- * the page providers.  It handles initialization and management of the providers,
- * and provides utility methods for accessing the contents.
+ * Manages the WikiPages.  This class functions as an unified interface towards the page providers.  It handles initialization
+ * and management of the providers, and provides utility methods for accessing the contents.
  * <p/>
- * Saving a page is a two-stage Task; first the pre-save operations and then the
- * actual save.  See the descriptions of the tasks for further information.
+ * Saving a page is a two-stage Task; first the pre-save operations and then the actual save.  See the descriptions of the tasks
+ * for further information.
  *
  * @since 2.0
  */
-// FIXME: This class currently only functions just as an extra layer over providers,
-//        complicating things.  We need to move more provider-specific functionality
-//        from WikiEngine (which is too big now) into this class.
 public class DefaultPageManager extends ModuleManager implements PageManager {
 
     private static final Logger LOG = Logger.getLogger( DefaultPageManager.class );


[jspwiki] 09/32: Improvements on TestEngine

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 3a4c6a55b9646ef1a4b5386dcd26d1459c502e68
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 4 15:15:43 2020 +0100

    Improvements on TestEngine
    
    * includes class and method creating the TestEngine on page, attachment and work directories, so its easier to locate which test created which folders
    * ensure page, attachment and work directories are always created under target/ folder
---
 .../src/test/java/org/apache/wiki/TestEngine.java  | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 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 0437b48..6140d83 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -125,7 +125,7 @@ public class TestEngine extends WikiEngine
     public static TestEngine build( final Properties props ) {
         try {
             return new TestEngine( props );
-        } catch(  WikiException we ) {
+        } catch( final WikiException we ) {
             throw new UnsupportedOperationException( "Unable to build TestEngine: " + we.getMessage(), we );
         }
     }
@@ -421,16 +421,28 @@ public class TestEngine extends WikiEngine
     }
 
     private static String cleanNewDirFrom( final String pageDir, final long millis ) {
+        final String testEngineCreationOrigin = getTestEngineCreationOrigin();
         if( StringUtils.isBlank( pageDir ) ) {
-            return "";
+            return "target/" + millis + "-" + testEngineCreationOrigin;
         }
         if( pageDir.lastIndexOf( '/' ) == -1 ) {
-            return "target/" + millis + "-" + pageDir;
+            return "target/" + millis + "-" + testEngineCreationOrigin + "-" + pageDir;
         }
         final String stripNumbers = pageDir.substring( pageDir.lastIndexOf( '/' ) );
         return pageDir.substring( 0, pageDir.lastIndexOf( '/' ) + 1 )
-             + millis // place all related tests' folders one next to the others
-             + stripNumbers.replaceAll( "\\d", StringUtils.EMPTY );
+             + millis
+             + "-" + testEngineCreationOrigin
+             + stripNumbers.replaceAll( "\\d", StringUtils.EMPTY ); // place all related tests' folders one next to the others
+    }
+
+    private static String getTestEngineCreationOrigin() {
+        for( final StackTraceElement trace : Thread.currentThread().getStackTrace() ) {
+            if( !( trace.getClassName().contains( TestEngine.class.getSimpleName() ) ||
+                   trace.getClassName().contains( Thread.class.getSimpleName() ) ) ) {
+                return trace.getClassName() + "-" + trace.getMethodName();
+            }
+        }
+        return "Unable to locate TestEngine creation";
     }
 
 }


[jspwiki] 08/32: include missing jspwiki.basicAttachmentProvider.storageDir, used on some tests

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 028006375998fdb568641bf4d0e40488705bec1c
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 4 15:12:10 2020 +0100

    include missing jspwiki.basicAttachmentProvider.storageDir, used on some tests
---
 jspwiki-main/src/test/resources/jspwiki-vers-custom.properties | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/jspwiki-main/src/test/resources/jspwiki-vers-custom.properties b/jspwiki-main/src/test/resources/jspwiki-vers-custom.properties
index 9cdd587..caa3a0c 100644
--- a/jspwiki-main/src/test/resources/jspwiki-vers-custom.properties
+++ b/jspwiki-main/src/test/resources/jspwiki-vers-custom.properties
@@ -19,9 +19,10 @@
 # WikiEngineTest, and VersioningFileProviderTest
 # overriding certain default values in src/main/resources/ini/jspwiki.properties
 #
-jspwiki.pageProvider = VersioningFileProvider
+jspwiki.basicAttachmentProvider.storageDir = target/test-classes/testrepository-att
 jspwiki.fileSystemProvider.pageDir = target/test-classes/testrepository
-jspwiki.workDir = target/test-classes/testworkdir
-log4j.appender.FileLog.File = target/test-classes/jspwikitests.log
+jspwiki.pageProvider = VersioningFileProvider
 # Stress/Massive tests very slow without switch to BasicSearchProvider
 jspwiki.searchProvider = BasicSearchProvider
+jspwiki.workDir = target/test-classes/testworkdir
+log4j.appender.FileLog.File = target/test-classes/jspwikitests.log


[jspwiki] 11/32: JSPWIKI-120: move getPureText methods to PageManager

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 8081873f58ca62ce4d4748de587e25e4a74eb099
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 4 18:44:11 2020 +0100

    JSPWIKI-120: move getPureText methods to PageManager
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 69 +++-------------------
 .../apache/wiki/auth/acl/DefaultAclManager.java    | 24 ++++----
 .../apache/wiki/content/DefaultPageRenamer.java    |  4 +-
 .../apache/wiki/diff/DefaultDifferenceManager.java |  4 +-
 .../java/org/apache/wiki/filters/SpamFilter.java   | 25 ++++----
 .../org/apache/wiki/pages/DefaultPageManager.java  | 35 +++++++++--
 .../java/org/apache/wiki/pages/PageManager.java    | 35 ++++++++++-
 .../main/java/org/apache/wiki/plugin/IfPlugin.java |  2 +-
 .../java/org/apache/wiki/plugin/InsertPage.java    | 12 ++--
 .../org/apache/wiki/plugin/TableOfContents.java    | 27 ++++-----
 .../java/org/apache/wiki/plugin/WeblogPlugin.java  | 10 +---
 .../wiki/references/DefaultReferenceManager.java   |  2 +-
 .../java/org/apache/wiki/rss/RSSGenerator.java     |  2 +-
 .../apache/wiki/search/LuceneSearchProvider.java   |  2 +-
 .../java/org/apache/wiki/tags/PageSizeTag.java     | 32 ++++------
 .../java/org/apache/wiki/xmlrpc/RPCHandler.java    | 13 ++--
 .../org/apache/wiki/xmlrpc/RPCHandlerUTF8.java     | 32 +++-------
 .../org/apache/wiki/content/PageRenamerTest.java   | 16 ++---
 .../apache/wiki/render/RenderingManagerTest.java   | 15 ++---
 .../apache/wiki/stress/MassiveRepositoryTest.java  |  2 +-
 .../wiki/stress/StressTestVersioningProvider.java  |  2 +-
 21 files changed, 160 insertions(+), 205 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 387ce65..56b5e33 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -1198,9 +1198,8 @@ public class WikiEngine  {
      * @param version  Version of the page to fetch
      * @return WikiText.
      */
-    public String getText( String page, int version )
-    {
-        String result = getPureText( page, version );
+    public String getText( final String page, final int version ) {
+        final String result = getPageManager().getPureText( page, version );
 
         //
         //  Replace ampersand first, or else all quotes and stuff
@@ -1210,9 +1209,7 @@ public class WikiEngine  {
         result = TextUtil.replaceString( result, "&", "&amp;" );
         */
 
-        result = TextUtil.replaceEntities( result );
-
-        return result;
+        return TextUtil.replaceEntities( result );
     }
 
     /**
@@ -1229,65 +1226,13 @@ public class WikiEngine  {
      *  @param context The WikiContext
      *  @param page    A page reference (not an attachment)
      *  @return The page content as HTMLized String.
-     *  @see   #getPureText(WikiPage)
+     *  @see PageManager#getPureText(WikiPage)
      */
-    public String getText( WikiContext context, WikiPage page )
+    public String getText( final WikiContext context, final WikiPage page )
     {
         return getText( page.getName(), page.getVersion() );
     }
 
-
-    /**
-     *  Returns the pure text of a page, no conversions.  Use this
-     *  if you are writing something that depends on the parsing
-     *  of the page.  Note that you should always check for page
-     *  existence through pageExists() before attempting to fetch
-     *  the page contents.
-     *
-     *  @param page    The name of the page to fetch.
-     *  @param version If WikiPageProvider.LATEST_VERSION, then uses the
-     *  latest version.
-     *  @return The page contents.  If the page does not exist,
-     *          returns an empty string.
-     */
-    // FIXME: Should throw an exception on unknown page/version?
-    public String getPureText( String page, int version )
-    {
-        String result = null;
-
-        try
-        {
-            result = m_pageManager.getPageText( page, version );
-        }
-        catch( ProviderException e )
-        {
-            // FIXME
-        }
-        finally
-        {
-            if( result == null )
-                result = "";
-        }
-
-        return result;
-    }
-
-    /**
-     *  Returns the pure text of a page, no conversions.  Use this
-     *  if you are writing something that depends on the parsing
-     *  the page. Note that you should always check for page
-     *  existence through pageExists() before attempting to fetch
-     *  the page contents.
-     *
-     *  @param page A handle to the WikiPage
-     *  @return String of WikiText.
-     *  @since 2.1.13.
-     */
-    public String getPureText( final WikiPage page )
-    {
-        return getPureText( page.getName(), page.getVersion() );
-    }
-
     /**
      *  Returns the converted HTML of the page using a different
      *  context than the default context.
@@ -1297,7 +1242,7 @@ public class WikiEngine  {
      *  @return HTML-rendered version of the page.
      */
     public String getHTML( final WikiContext context, final WikiPage page ) {
-        final String pagedata = getPureText( page.getName(), page.getVersion() );
+        final String pagedata = getPageManager().getPureText( page.getName(), page.getVersion() );
         return textToHTML( context, pagedata );
     }
 
@@ -1500,7 +1445,7 @@ public class WikiEngine  {
     public void saveText( WikiContext context, String text ) throws WikiException {
         // Check if page data actually changed; bail if not
         WikiPage page = context.getPage();
-        String oldText = getPureText( page );
+        String oldText = getPageManager().getPureText( page );
         String proposedText = TextUtil.normalizePostData( text );
         if ( oldText != null && oldText.equals( proposedText ) ) {
             return;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
index 8cdad24..860eafa 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
@@ -205,24 +205,24 @@ public class DefaultAclManager implements AclManager {
      * @throws WikiSecurityException of the Acl cannot be set
      * @since 2.5
      */
-    public void setPermissions(WikiPage page, Acl acl) throws WikiSecurityException {
-        PageManager pageManager = m_engine.getPageManager();
+    public void setPermissions( final WikiPage page, final Acl acl ) throws WikiSecurityException {
+        final PageManager pageManager = m_engine.getPageManager();
 
         // Forcibly expire any page locks
-        PageLock lock = pageManager.getCurrentLock(page);
-        if (lock != null) {
-            pageManager.unlockPage(lock);
+        final PageLock lock = pageManager.getCurrentLock( page );
+        if( lock != null ) {
+            pageManager.unlockPage( lock );
         }
 
         // Remove all of the existing ACLs.
-        String pageText = m_engine.getPureText(page);
-        Matcher matcher = DefaultAclManager.ACL_PATTERN.matcher(pageText);
-        String cleansedText = matcher.replaceAll("");
-        String newText = DefaultAclManager.printAcl(page.getAcl()) + cleansedText;
+        final String pageText = m_engine.getPageManager().getPureText( page );
+        final Matcher matcher = DefaultAclManager.ACL_PATTERN.matcher( pageText );
+        final String cleansedText = matcher.replaceAll("" );
+        final String newText = DefaultAclManager.printAcl( page.getAcl() ) + cleansedText;
         try {
-            pageManager.putPageText(page, newText);
-        } catch (ProviderException e) {
-            throw new WikiSecurityException("Could not set Acl. Reason: ProviderExcpetion " + e.getMessage(), e);
+            pageManager.putPageText( page, newText );
+        } catch( final ProviderException e ) {
+            throw new WikiSecurityException( "Could not set Acl. Reason: ProviderExcpetion " + e.getMessage(), e );
         }
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
index e15de8c..e586d45 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
@@ -110,7 +110,7 @@ public class DefaultPageRenamer implements PageRenamer {
         }
         toPage.setAttribute( WikiPage.CHANGENOTE, fromPage.getName() + " ==> " + toPage.getName() );
         toPage.setAuthor( context.getCurrentUser().getName() );
-        engine.getPageManager().putPageText( toPage, engine.getPureText( toPage ) );
+        engine.getPageManager().putPageText( toPage, engine.getPageManager().getPureText( toPage ) );
 
         //  Update the references
         engine.getReferenceManager().pageRemoved( fromPage );
@@ -173,7 +173,7 @@ public class DefaultPageRenamer implements PageRenamer {
             
             final WikiPage p = engine.getPageManager().getPage( pageName );
 
-            final String sourceText = engine.getPureText( p );
+            final String sourceText = engine.getPageManager().getPureText( p );
             String newText = replaceReferrerString( context, sourceText, fromPage.getName(), toPage.getName() );
 
             m_camelCase = TextUtil.getBooleanProperty( engine.getWikiProperties(), JSPWikiMarkupParser.PROP_CAMELCASELINKS, m_camelCase );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
index c9c6c6a..62229b9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
@@ -113,8 +113,8 @@ public class DefaultDifferenceManager implements DifferenceManager {
      */
     public String getDiff( final WikiContext context, final int version1, final int version2 ) {
         final String page = context.getPage().getName();
-        String page1 = context.getEngine().getPureText( page, version1 );
-        final String page2 = context.getEngine().getPureText( page, version2 );
+        String page1 = context.getEngine().getPageManager().getPureText( page, version1 );
+        final String page2 = context.getEngine().getPageManager().getPureText( page, version2 );
 
         // Kludge to make diffs for new pages to work this way.
         if( version1 == WikiPageProvider.LATEST_VERSION ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
index 4dd287d..bc1acc7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
@@ -862,27 +862,26 @@ public class SpamFilter extends BasicPageFilter {
      *  @param newText
      *  @return Empty string, if there is no change.
      */
-    private static Change getChange( WikiContext context, String newText ) {
-        WikiPage page = context.getPage();
-        StringBuffer change = new StringBuffer();
-        WikiEngine engine = context.getEngine();
+    private static Change getChange( final WikiContext context, final String newText ) {
+        final WikiPage page = context.getPage();
+        final StringBuffer change = new StringBuffer();
+        final WikiEngine engine = context.getEngine();
         // Get current page version
 
-        Change ch = new Change();
+        final Change ch = new Change();
         
         try {
-            String oldText = engine.getPureText( page.getName(), WikiProvider.LATEST_VERSION );
-
-            String[] first  = Diff.stringToArray( oldText );
-            String[] second = Diff.stringToArray( newText );
-            Revision rev = Diff.diff( first, second, new MyersDiff() );
+            final String oldText = engine.getPageManager().getPureText( page.getName(), WikiProvider.LATEST_VERSION );
+            final String[] first  = Diff.stringToArray( oldText );
+            final String[] second = Diff.stringToArray( newText );
+            final Revision rev = Diff.diff( first, second, new MyersDiff() );
 
             if( rev == null || rev.size() == 0 ) {
                 return ch;
             }
             
             for( int i = 0; i < rev.size(); i++ ) {
-                Delta d = rev.getDelta( i );
+                final Delta d = rev.getDelta( i );
 
                 if( d instanceof AddDelta ) {
                     d.getRevised().toString( change, "", "\r\n" );
@@ -896,14 +895,14 @@ public class SpamFilter extends BasicPageFilter {
                     ch.m_removals++;
                 }
             }
-        } catch( DifferentiationFailedException e ) {
+        } catch( final DifferentiationFailedException e ) {
             log.error( "Diff failed", e );
         }
 
         //
         //  Don't forget to include the change note, too
         //
-        String changeNote = ( String )page.getAttribute( WikiPage.CHANGENOTE );
+        final String changeNote = ( String )page.getAttribute( WikiPage.CHANGENOTE );
 
         if( changeNote != null ) {
             change.append( "\r\n" );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index 5d605ed..3d5248e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -139,7 +139,8 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
 
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getProvider()
      */
     @Override
@@ -147,7 +148,8 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         return m_provider;
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getAllPages()
      */
     @Override
@@ -155,18 +157,19 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         return m_provider.getAllPages();
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getPageText(java.lang.String, int)
      */
     @Override
-    public String getPageText( final String pageName, final int version) throws ProviderException {
+    public String getPageText( final String pageName, final int version ) throws ProviderException {
         if (pageName == null || pageName.length() == 0) {
-            throw new ProviderException("Illegal page name");
+            throw new ProviderException( "Illegal page name" );
         }
         String text;
 
         try {
-            text = m_provider.getPageText(pageName, version);
+            text = m_provider.getPageText( pageName, version );
         } catch ( final RepositoryModifiedException e ) {
             //  This only occurs with the latest version.
             LOG.info( "Repository has been modified externally while fetching page " + pageName );
@@ -184,6 +187,26 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
 
     /**
      * {@inheritDoc}
+     * @see org.apache.wiki.pages.PageManager#getPureText(String, int)
+     */
+    public String getPureText( final String page, final int version ) {
+        String result = null;
+
+        try {
+            result = getPageText( page, version );
+        } catch( final ProviderException e ) {
+            LOG.error( "ProviderException getPureText for page " + page + " [version " + version + "]", e );
+        } finally {
+            if( result == null ) {
+                result = "";
+            }
+        }
+
+        return result;
+    }
+
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getEngine()
      */
     @Override
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index c7a9674..6ff9dcd 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -56,9 +56,8 @@ public interface PageManager extends WikiEventListener {
     Collection< WikiPage > getAllPages() throws ProviderException;
 
     /**
-     * Fetches the page text from the repository.  This method also does some sanity checks,
-     * like checking for the pageName validity, etc.  Also, if the page repository has been
-     * modified externally, it is smart enough to handle such occurrences.
+     * Fetches the page text from the repository.  This method also does some sanity checks, like checking for the pageName validity, etc.
+     * Also, if the page repository has been modified externally, it is smart enough to handle such occurrences.
      *
      * @param pageName The name of the page to fetch.
      * @param version  The version to find
@@ -68,6 +67,36 @@ public interface PageManager extends WikiEventListener {
     String getPageText( String pageName, int version ) throws ProviderException;
 
     /**
+     *  Returns the pure text of a page, no conversions.  Use this if you are writing something that depends on the parsing
+     *  of the page. Note that you should always check for page existence through pageExists() before attempting to fetch
+     *  the page contents.
+     *
+     *  This method is pretty similar to {@link #getPageText(String, int)}, except that it doesn't throw {@link ProviderException},
+     *  it logs and swallows them.
+     *
+     *  @param page The name of the page to fetch.
+     *  @param version If WikiPageProvider.LATEST_VERSION, then uses the latest version.
+     *  @return The page contents.  If the page does not exist, returns an empty string.
+     */
+    String getPureText( String page, int version );
+
+    /**
+     *  Returns the pure text of a page, no conversions.  Use this if you are writing something that depends on the parsing
+     *  the page. Note that you should always check for page existence through pageExists() before attempting to fetch
+     *  the page contents.
+     *
+     *  This method is pretty similar to {@link #getPageText(String, int)}, except that it doesn't throw {@link ProviderException},
+     *  it logs and swallows them.
+     *
+     *  @param page A handle to the WikiPage
+     *  @return String of WikiText.
+     *  @since 2.1.13, moved to PageManager on 2.11.0.
+     */
+    default String getPureText( final WikiPage page ) {
+        return getPureText( page.getName(), page.getVersion() );
+    }
+
+    /**
      * Returns the WikiEngine to which this PageManager belongs to.
      *
      * @return The WikiEngine object.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/IfPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/IfPlugin.java
index 2275b94..a4902f7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/IfPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/IfPlugin.java
@@ -172,7 +172,7 @@ public class IfPlugin implements WikiPlugin
         include |= checkIP(context, ip);
 
         if( page != null ) {
-            final String content = context.getEngine().getPureText(page, WikiProvider.LATEST_VERSION).trim();
+            final String content = context.getEngine().getPageManager().getPureText(page, WikiProvider.LATEST_VERSION).trim();
             include |= checkContains(content,contains);
             include |= checkIs(content,is);
             include |= checkExists(context,page,exists);
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java
index 3c92e9f..e34e990 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java
@@ -183,17 +183,13 @@ public class InsertPage
                 WikiContext includedContext = (WikiContext) context.clone();
                 includedContext.setPage( page );
 
-                String pageData = engine.getPureText( page );
+                String pageData = engine.getPageManager().getPureText( page );
                 String moreLink = "";
 
-                if( section != -1 )
-                {
-                    try
-                    {
+                if( section != -1 ) {
+                    try {
                         pageData = TextUtil.getSection( pageData, section );
-                    }
-                    catch( IllegalArgumentException e )
-                    {
+                    } catch( final IllegalArgumentException e ) {
                         throw new PluginException( e.getMessage() );
                     }
                 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java
index e7a4f9c..ff21a4b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/TableOfContents.java
@@ -18,10 +18,6 @@
  */
 package org.apache.wiki.plugin;
 
-import java.io.IOException;
-import java.util.Map;
-import java.util.ResourceBundle;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiContext;
@@ -36,6 +32,10 @@ import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.util.TextUtil;
 
+import java.io.IOException;
+import java.util.Map;
+import java.util.ResourceBundle;
+
 /**
  *  Provides a table of contents.
  *  <p>Parameters : </p>
@@ -214,17 +214,16 @@ public class TableOfContents
             m_lastLevel = Heading.HEADING_LARGE;
         }
 
-        try
-        {
-            String wikiText = engine.getPureText( page );
-            boolean runFilters = "true".equals( engine.getVariableManager().getValue( context, WikiEngine.PROP_RUNFILTERS, "true" ) );
+        try {
+            String wikiText = engine.getPageManager().getPureText( page );
+            final boolean runFilters = "true".equals( engine.getVariableManager().getValue( context, WikiEngine.PROP_RUNFILTERS, "true" ) );
 
             if( runFilters ) {
 				try {
-					FilterManager fm = engine.getFilterManager();
+					final FilterManager fm = engine.getFilterManager();
 					wikiText = fm.doPreTranslateFiltering(context, wikiText);
 
-				} catch (Exception e) {
+				} catch( final Exception e ) {
 					log.error("Could not construct table of contents: Filter Error", e);
 					throw new PluginException("Unable to construct table of contents (see logs)");
 				}
@@ -232,14 +231,12 @@ public class TableOfContents
 
             context.setVariable( VAR_ALREADY_PROCESSING, "x" );
 
-            MarkupParser parser = engine.getRenderingManager().getParser( context, wikiText );
+            final MarkupParser parser = engine.getRenderingManager().getParser( context, wikiText );
             parser.addHeadingListener( this );
             parser.parse();
 
-            sb.append( "<ul>\n"+m_buf.toString()+"</ul>\n" );
-        }
-        catch( IOException e )
-        {
+            sb.append( "<ul>\n" ).append( m_buf.toString() ).append( "</ul>\n" );
+        } catch( final IOException e ) {
             log.error("Could not construct table of contents", e);
             throw new PluginException("Unable to construct table of contents (see logs)");
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
index 214a265..63e3cd8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
@@ -450,13 +450,9 @@ public class WeblogPlugin
         buffer.append("</div>\n");
     }
 
-    private int guessNumberOfComments( WikiEngine engine, String commentpage )
-        throws ProviderException
-    {
-        String pagedata = engine.getPureText( commentpage, WikiProvider.LATEST_VERSION );
-
-        if( pagedata == null || pagedata.trim().length() == 0 )
-        {
+    private int guessNumberOfComments( final WikiEngine engine, final String commentpage ) {
+        final String pagedata = engine.getPageManager().getPureText( commentpage, WikiProvider.LATEST_VERSION );
+        if( pagedata == null || pagedata.trim().length() == 0 ) {
             return 0;
         }
 
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 6c69498..8d867cb 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
@@ -501,7 +501,7 @@ public class DefaultReferenceManager extends BasicPageFilter implements Referenc
      *  @param page wiki page for which references should be updated
      */
     public void updateReferences( final WikiPage page ) {
-        final String pageData = m_engine.getPureText( page.getName(), WikiProvider.LATEST_VERSION );
+        final String pageData = m_engine.getPageManager().getPureText( page.getName(), WikiProvider.LATEST_VERSION );
         updateReferences( page.getName(), scanWikiLinks( page, pageData ) );
     }
 
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 1c21260..174f0b6 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
@@ -519,7 +519,7 @@ public class RSSGenerator {
             //  Title
             //
 
-            String pageText = m_engine.getPureText(page.getName(), WikiProvider.LATEST_VERSION );
+            String pageText = m_engine.getPageManager().getPureText(page.getName(), WikiProvider.LATEST_VERSION );
 
             String title = "";
             int firstLine = pageText.indexOf('\n');
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
index 2815e37..e6e4711 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
@@ -478,7 +478,7 @@ public class LuceneSearchProvider implements SearchProvider {
             if( page instanceof Attachment ) {
                 text = getAttachmentContent( (Attachment) page );
             } else {
-                text = m_engine.getPureText( page );
+                text = m_engine.getPageManager().getPureText( page );
             }
 
             if( text != null ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/PageSizeTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/PageSizeTag.java
index 1caf82e..617a7ad 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/PageSizeTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/PageSizeTag.java
@@ -18,47 +18,39 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.ProviderException;
 
+import java.io.IOException;
+
 /**
  *  Returns the currently requested page or attachment size.
  *
  *  @since 2.0
  */
-public class PageSizeTag
-    extends WikiTagBase
-{
+public class PageSizeTag extends WikiTagBase {
+
     private static final long serialVersionUID = 0L;
     private static final Logger log = Logger.getLogger( PageSizeTag.class );
     
-    public final int doWikiStartTag()
-        throws IOException
-    {
-        WikiEngine engine = m_wikiContext.getEngine();
-        WikiPage   page   = m_wikiContext.getPage();
+    public final int doWikiStartTag() throws IOException {
+        final WikiEngine engine = m_wikiContext.getEngine();
+        final WikiPage page = m_wikiContext.getPage();
 
-        try
-        {
-            if( page != null )
-            {
+        try {
+            if( page != null ) {
                 long size = page.getSize();
 
-                if( size == -1 && engine.pageExists(page) ) // should never happen with attachments
-                {
-                    size = engine.getPureText( page.getName(), page.getVersion() ).length();
+                if( size == -1 && engine.pageExists(page) ) { // should never happen with attachments
+                    size = engine.getPageManager().getPureText( page.getName(), page.getVersion() ).length();
                     page.setSize( size );
                 }
 
                 pageContext.getOut().write( Long.toString(size) );
             }
-        }
-        catch( ProviderException e )
-        {
+        } catch( final ProviderException e ) {
             log.warn("Providers did not work: ",e);
             pageContext.getOut().write("Error determining page size: "+e.getMessage());
         }
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 0dc2359..3cb0a83 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
@@ -210,13 +210,8 @@ public class RPCHandler
         return encodeWikiPage( m_engine.getPageManager().getPage( pagename, version ) );
     }
 
-    public byte[] getPage( String pagename )
-        throws XmlRpcException
-    {
-        pagename = parsePageCheckCondition( pagename );
-
-        String text = m_engine.getPureText( pagename, -1 );
-
+    public byte[] getPage( final String pagename ) throws XmlRpcException {
+        final String text = m_engine.getPageManager().getPureText( parsePageCheckCondition( pagename ), -1 );
         return toRPCBase64( text );
     }
 
@@ -225,7 +220,7 @@ public class RPCHandler
     {
         pagename = parsePageCheckCondition( pagename );
 
-        return toRPCBase64( m_engine.getPureText( pagename, version ) );
+        return toRPCBase64( m_engine.getPageManager().getPureText( pagename, version ) );
     }
 
     public byte[] getPageHTML( String pagename )
@@ -250,7 +245,7 @@ public class RPCHandler
         pagename = parsePageCheckCondition( pagename );
 
         WikiPage page = m_engine.getPageManager().getPage( pagename );
-        String pagedata = m_engine.getPureText( page );
+        String pagedata = m_engine.getPageManager().getPureText( page );
 
         LinkCollector localCollector = new LinkCollector();
         LinkCollector extCollector   = new LinkCollector();
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 3b5cff0..9444453 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
@@ -109,7 +109,7 @@ public class RPCHandlerUTF8
         checkPermission( PagePermission.VIEW );
 
         Collection< WikiPage > pages = m_engine.getRecentChanges();
-        Vector<Hashtable<String, Object>> result = new Vector<Hashtable<String, Object>>();
+        Vector<Hashtable<String, Object>> result = new Vector<>();
 
         Calendar cal = Calendar.getInstance();
         cal.setTime( since );
@@ -171,30 +171,16 @@ public class RPCHandlerUTF8
         return encodeWikiPage( m_engine.getPageManager().getPage( pagename, version ) );
     }
 
-    public String getPage( String pagename )
-        throws XmlRpcException
-    {
-        pagename = parsePageCheckCondition( pagename );
-
-        String text = m_engine.getPureText( pagename, -1 );
-
-        return text;
+    public String getPage( final String pagename ) throws XmlRpcException {
+        return m_engine.getPageManager().getPureText( parsePageCheckCondition( pagename ), -1 );
     }
 
-    public String getPageVersion( String pagename, int version )
-        throws XmlRpcException
-    {
-        pagename = parsePageCheckCondition( pagename );
-
-        return m_engine.getPureText( pagename, version );
+    public String getPageVersion( final String pagename, final int version ) throws XmlRpcException {
+        return m_engine.getPageManager().getPureText( parsePageCheckCondition( pagename ), version );
     }
 
-    public String getPageHTML( String pagename )
-        throws XmlRpcException
-    {
-        pagename = parsePageCheckCondition( pagename );
-
-        return m_engine.getHTML( pagename );
+    public String getPageHTML( final String pagename ) throws XmlRpcException  {
+        return m_engine.getHTML( parsePageCheckCondition( pagename ) );
     }
 
     public String getPageHTMLVersion( String pagename, int version )
@@ -211,7 +197,7 @@ public class RPCHandlerUTF8
         pagename = parsePageCheckCondition( pagename );
 
         WikiPage page = m_engine.getPageManager().getPage( pagename );
-        String pagedata = m_engine.getPureText( page );
+        String pagedata = m_engine.getPageManager().getPureText( page );
 
         LinkCollector localCollector = new LinkCollector();
         LinkCollector extCollector   = new LinkCollector();
@@ -226,7 +212,7 @@ public class RPCHandlerUTF8
                              extCollector,
                              attCollector );
 
-        Vector<Hashtable<String, String>> result = new Vector<Hashtable<String, String>>();
+        Vector<Hashtable<String, String>> result = new Vector<>();
 
         // FIXME: Contains far too much common with RPCHandler.  Refactor!
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
index d6d2fb1..6bd2659 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
@@ -107,7 +107,7 @@ public class PageRenamerTest
 
         m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", true);
 
-        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
+        String data = m_engine.getPageManager().getPureText("TestPage2", WikiProvider.LATEST_VERSION);
 
         Assertions.assertEquals( "[FooTest]", data.trim(), "no rename" );
 
@@ -133,7 +133,7 @@ public class PageRenamerTest
 
         m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", true);
 
-        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
+        String data = m_engine.getPageManager().getPureText("TestPage2", WikiProvider.LATEST_VERSION);
 
         Assertions.assertEquals( "FooTest", data.trim(), "no rename" );
         Collection< String > refs = m_engine.getReferenceManager().findReferrers("TestPage");
@@ -158,7 +158,7 @@ public class PageRenamerTest
 
         m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", true);
 
-        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
+        String data = m_engine.getPageManager().getPureText("TestPage2", WikiProvider.LATEST_VERSION);
 
         Assertions.assertEquals( "[FooTest#heading1]", data.trim(), "no rename" );
         Collection< String > refs = m_engine.getReferenceManager().findReferrers("TestPage");
@@ -183,7 +183,7 @@ public class PageRenamerTest
 
         m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", true);
 
-        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
+        String data = m_engine.getPageManager().getPureText("TestPage2", WikiProvider.LATEST_VERSION);
 
         Assertions.assertEquals( "[FooTest] [FooTest] [linktext|FooTest] FooTest [linktext|FooTest] [FooTest#Anchor] [FooTest] FooTest [FooTest]",
                                  data.trim(), 
@@ -211,7 +211,7 @@ public class PageRenamerTest
 
         m_engine.getPageRenamer().renamePage(context, "Test", "TestPage", true);
 
-        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION );
+        String data = m_engine.getPageManager().getPureText("TestPage2", WikiProvider.LATEST_VERSION );
 
         Assertions.assertEquals( "[TestPage] [TestPage#anchor] test Test [TestPage] [link|TestPage] [link|TestPage]", data.trim(), "wrong data" );
     }
@@ -231,7 +231,7 @@ public class PageRenamerTest
 
         m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", true);
 
-        String data = m_engine.getPureText("TestPage2", WikiProvider.LATEST_VERSION);
+        String data = m_engine.getPageManager().getPureText("TestPage2", WikiProvider.LATEST_VERSION);
 
         Assertions.assertEquals( "[FooTest/foo.txt] [linktext|FooTest/bar.jpg]", data.trim(), "no rename" );
 
@@ -481,7 +481,7 @@ public class PageRenamerTest
 
         rename( "TestPageReferred", "TestPageReferredNew" );
 
-        String data = m_engine.getPureText( "TestPageReferring", WikiProvider.LATEST_VERSION );
+        String data = m_engine.getPageManager().getPureText( "TestPageReferring", WikiProvider.LATEST_VERSION );
         Assertions.assertEquals( "[Test Page Referred|TestPageReferredNew]", data.trim(), "page not renamed" );
 
         Collection< String > refs = m_engine.getReferenceManager().findReferrers( "TestPageReferred" );
@@ -502,7 +502,7 @@ public class PageRenamerTest
 
         rename( "Link one", "Link uno" );
 
-        String data = m_engine.getPureText( "RenameTest", WikiProvider.LATEST_VERSION );
+        String data = m_engine.getPageManager().getPureText( "RenameTest", WikiProvider.LATEST_VERSION );
         Assertions.assertEquals( "[link one|Link uno] [link two]", data.trim(), "page not renamed" );
 
         Collection< String > refs = m_engine.getReferenceManager().findReferrers( "Link one" );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
index 06962d9..35e2948 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
@@ -59,7 +59,7 @@ public class RenderingManagerTest {
         for( int i = 0; i < 300; i++ )
         {
             WikiPage page = m_engine.getPageManager().getPage( "TestPage" );
-            String pagedata = m_engine.getPureText( page );
+            String pagedata = m_engine.getPageManager().getPureText( page );
 
             WikiContext context = new WikiContext( m_engine, page );
 
@@ -79,14 +79,11 @@ public class RenderingManagerTest {
         sw.reset();
         sw.start();
 
-        for( int i = 0; i < 300; i++ )
-        {
-            WikiPage page = m_engine.getPageManager().getPage( "TestPage" );
-            String pagedata = m_engine.getPureText( page );
-
-            WikiContext context = new WikiContext( m_engine, page );
-
-            String html = m_manager.getHTML( context, pagedata );
+        for( int i = 0; i < 300; i++ ) {
+            final WikiPage page = m_engine.getPageManager().getPage( "TestPage" );
+            final String pagedata = m_engine.getPageManager().getPureText( page );
+            final WikiContext context = new WikiContext( m_engine, page );
+            final String html = m_manager.getHTML( context, pagedata );
 
             Assertions.assertNotNull("cached got null response",html);
         }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java b/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java
index 08c65f0..0957019 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java
@@ -134,7 +134,7 @@ public class MassiveRepositoryTest {
         {
             String page = getName( random.nextInt( numPages ) );
             
-            String content = engine.getPureText( page, WikiProvider.LATEST_VERSION );
+            String content = engine.getPageManager().getPureText( page, WikiProvider.LATEST_VERSION );
             
             content = TextUtil.replaceString( content, "X", "XX" );
             
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java b/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java
index 20ed0ac..dd81de0 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java
@@ -106,7 +106,7 @@ public class StressTestVersioningProvider {
         mark.start();
 
         for( WikiPage page : pages ) {
-            String foo = engine.getPureText( page );
+            String foo = engine.getPageManager().getPureText( page );
             Assertions.assertNotNull( foo );
         }
         mark.stop();


[jspwiki] 12/32: '' is not a valid dir name, so we replace it with 'init'

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 99c5c7d278132d500e1aad298072c1ae2d98bbeb
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Jan 5 00:44:06 2020 +0100

    '<init>' is not a valid dir name, so we replace it with 'init'
---
 jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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 6140d83..e2c3849 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -439,7 +439,8 @@ public class TestEngine extends WikiEngine
         for( final StackTraceElement trace : Thread.currentThread().getStackTrace() ) {
             if( !( trace.getClassName().contains( TestEngine.class.getSimpleName() ) ||
                    trace.getClassName().contains( Thread.class.getSimpleName() ) ) ) {
-                return trace.getClassName() + "-" + trace.getMethodName();
+                return trace.getClassName() + "-" + trace.getMethodName().replace( "<", "" ) // <init> -> init
+                                                                         .replace( ">", "" );
             }
         }
         return "Unable to locate TestEngine creation";


[jspwiki] 15/32: simplify test a tiny bit

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 f41a53964b3e8cadf89f5693f23425a834d1fa72
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Jan 5 01:21:28 2020 +0100

    simplify test a tiny bit
---
 jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

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 ec66eb4..f41e275 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -64,9 +64,7 @@ public class WikiEngineTest {
 
     @Test
     public void testNonExistentDirectory() throws Exception {
-        final String tmpdir = "./target";
-        final String dirname = "non-existent-directory";
-        final String newdir = tmpdir + File.separator + dirname;
+        final String newdir = "." + File.separator + "target" + File.separator + "non-existent-directory";
 
         props.setProperty( FileSystemProvider.PROP_PAGEDIR, newdir );
         m_engine = new TestEngine( props );


[jspwiki] 10/32: clean up + simplify tests

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 54814dcafb47a764d53e79fff0ba83e221bb9f9c
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 4 15:16:04 2020 +0100

    clean up + simplify tests
---
 .../test/java/org/apache/wiki/WikiEngineTest.java  | 350 +++++++--------------
 1 file changed, 118 insertions(+), 232 deletions(-)

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 ce676ce..ec66eb4 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -23,7 +23,6 @@ import net.sf.ehcache.CacheManager;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.pages.PageManager;
-import org.apache.wiki.providers.BasicAttachmentProvider;
 import org.apache.wiki.providers.FileSystemProvider;
 import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.util.TextUtil;
@@ -52,7 +51,7 @@ public class WikiEngineTest {
 
     @AfterEach
     public void tearDown() {
-        final String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
+        final String files = m_engine.getWikiProperties().getProperty( FileSystemProvider.PROP_PAGEDIR );
 
         if( files != null ) {
             final File f = new File( files );
@@ -70,9 +69,9 @@ public class WikiEngineTest {
         final String newdir = tmpdir + File.separator + dirname;
 
         props.setProperty( FileSystemProvider.PROP_PAGEDIR, newdir );
-        new TestEngine( props );
+        m_engine = new TestEngine( props );
 
-        final File f = new File( props.getProperty( FileSystemProvider.PROP_PAGEDIR ) );
+        final File f = new File( m_engine.getWikiProperties().getProperty( FileSystemProvider.PROP_PAGEDIR ) );
         Assertions.assertTrue( f.exists(), "didn't create it" );
         Assertions.assertTrue( f.isDirectory(), "isn't a dir" );
 
@@ -123,84 +122,65 @@ public class WikiEngineTest {
 
     @Test
     public void testPutPage() throws Exception {
-        String text = "Foobar.\r\n";
-        String name = NAME1;
-
+        final String text = "Foobar.\r\n";
+        final String name = NAME1;
         m_engine.saveText( name, text );
 
-        Assertions.assertEquals( true, m_engine.pageExists( name ), "page does not exist" );
+        Assertions.assertTrue( m_engine.pageExists( name ), "page does not exist" );
         Assertions.assertEquals( text, m_engine.getText( name ), "wrong content" );
     }
 
     @Test
-    public void testPutPageEntities()
-        throws Exception
-    {
-        String text = "Foobar. &quot;\r\n";
-        String name = NAME1;
-
+    public void testPutPageEntities() throws Exception {
+        final String text = "Foobar. &quot;\r\n";
+        final String name = NAME1;
         m_engine.saveText( name, text );
 
-        Assertions.assertEquals( true, m_engine.pageExists( name ), "page does not exist" );
+        Assertions.assertTrue( m_engine.pageExists( name ), "page does not exist" );
         Assertions.assertEquals( "Foobar. &amp;quot;\r\n", m_engine.getText( name ), "wrong content" );
     }
 
     /**
-     *  Cgeck that basic " is changed.
+     *  Check that basic " is changed.
      */
     @Test
-    public void testPutPageEntities2()
-        throws Exception
-    {
-        String text = "Foobar. \"\r\n";
-        String name = NAME1;
-
+    public void testPutPageEntities2() throws Exception {
+        final String text = "Foobar. \"\r\n";
+        final String name = NAME1;
         m_engine.saveText( name, text );
 
-        Assertions.assertEquals( true, m_engine.pageExists( name ), "page does not exist" );
+        Assertions.assertTrue( m_engine.pageExists( name ), "page does not exist" );
         Assertions.assertEquals( "Foobar. &quot;\r\n", m_engine.getText( name ), "wrong content" );
     }
 
     @Test
-    public void testGetHTML()
-        throws Exception
-    {
-        String text = "''Foobar.''";
-        String name = NAME1;
-
+    public void testGetHTML() throws Exception {
+        final String text = "''Foobar.''";
+        final String name = NAME1;
         m_engine.saveText( name, text );
 
-        String data = m_engine.getHTML( name );
-
+        final String data = m_engine.getHTML( name );
         Assertions.assertEquals( "<i>Foobar.</i>\n", data );
     }
 
     @Test
-    public void testEncodeNameLatin1()
-    {
-        String name = "abc\u00e5\u00e4\u00f6";
-
+    public void testEncodeNameLatin1() {
+        final String name = "abc\u00e5\u00e4\u00f6";
         Assertions.assertEquals( "abc%E5%E4%F6", m_engine.encodeName(name) );
     }
 
     @Test
-    public void testEncodeNameUTF8()
-        throws Exception
-    {
-        String name = "\u0041\u2262\u0391\u002E";
-
+    public void testEncodeNameUTF8() throws Exception {
+        final String name = "\u0041\u2262\u0391\u002E";
         props.setProperty( WikiEngine.PROP_ENCODING, "UTF-8" );
-
-        WikiEngine engine = new TestEngine( props );
+        final WikiEngine engine = new TestEngine( props );
 
         Assertions.assertEquals( "A%E2%89%A2%CE%91.", engine.encodeName(name) );
     }
 
     @Test
-    public void testBeautifyTitle()
-    {
-        String src = "WikiNameThingy";
-
+    public void testBeautifyTitle() {
+        final String src = "WikiNameThingy";
         Assertions.assertEquals("Wiki Name Thingy", m_engine.beautifyTitle( src ) );
     }
 
@@ -208,10 +188,8 @@ public class WikiEngineTest {
      *  Acronyms should be treated wisely.
      */
     @Test
-    public void testBeautifyTitleAcronym()
-    {
-        String src = "JSPWikiPage";
-
+    public void testBeautifyTitleAcronym() {
+        final String src = "JSPWikiPage";
         Assertions.assertEquals("JSP Wiki Page", m_engine.beautifyTitle( src ) );
     }
 
@@ -219,26 +197,20 @@ public class WikiEngineTest {
      *  Acronyms should be treated wisely.
      */
     @Test
-    public void testBeautifyTitleAcronym2()
-    {
-        String src = "DELETEME";
-
+    public void testBeautifyTitleAcronym2() {
+        final String src = "DELETEME";
         Assertions.assertEquals("DELETEME", m_engine.beautifyTitle( src ) );
     }
 
     @Test
-    public void testBeautifyTitleAcronym3()
-    {
-        String src = "JSPWikiFAQ";
-
+    public void testBeautifyTitleAcronym3() {
+        final String src = "JSPWikiFAQ";
         Assertions.assertEquals("JSP Wiki FAQ", m_engine.beautifyTitle( src ) );
     }
 
     @Test
-    public void testBeautifyTitleNumbers()
-    {
-        String src = "TestPage12";
-
+    public void testBeautifyTitleNumbers() {
+        final String src = "TestPage12";
         Assertions.assertEquals("Test Page 12", m_engine.beautifyTitle( src ) );
     }
 
@@ -246,10 +218,8 @@ public class WikiEngineTest {
      *  English articles too.
      */
     @Test
-    public void testBeautifyTitleArticle()
-    {
-        String src = "ThisIsAPage";
-
+    public void testBeautifyTitleArticle() {
+        final String src = "ThisIsAPage";
         Assertions.assertEquals("This Is A Page", m_engine.beautifyTitle( src ) );
     }
 
@@ -257,38 +227,26 @@ public class WikiEngineTest {
      *  Checks, if ReferenceManager is informed of new attachments.
      */
     @Test
-    public void testAttachmentRefs()
-        throws Exception
-    {
-        ReferenceManager refMgr = m_engine.getReferenceManager();
-        AttachmentManager attMgr = m_engine.getAttachmentManager();
-
+    public void testAttachmentRefs() throws Exception {
+        final ReferenceManager refMgr = m_engine.getReferenceManager();
+        final AttachmentManager attMgr = m_engine.getAttachmentManager();
         m_engine.saveText( NAME1, "fooBar");
 
-        Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
+        final Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
         att.setAuthor( "FirstPost" );
         attMgr.storeAttachment( att, m_engine.makeAttachmentFile() );
 
-        try
-        {
-            // and check post-conditions
-            Collection< String > c = refMgr.findUncreated();
-            Assertions.assertTrue( c==null || c.size()==0, "attachment exists: "+c );
-
-            c = refMgr.findUnreferenced();
-            Assertions.assertEquals( 2, c.size(), "unreferenced count" );
-            Iterator< String > i = c.iterator();
-            String first = i.next();
-            String second = i.next();
-            Assertions.assertTrue(  (first.equals( NAME1 ) && second.equals( NAME1+"/TestAtt.txt"))
-                                 || (first.equals( NAME1+"/TestAtt.txt" ) && second.equals( NAME1 )), "unreferenced" );
-        }
-        finally
-        {
-            // do cleanup
-            String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
-            TestEngine.deleteAll( new File( files, NAME1+BasicAttachmentProvider.DIR_EXTENSION ) );
-        }
+        // and check post-conditions
+        Collection< String > c = refMgr.findUncreated();
+        Assertions.assertTrue( c==null || c.size()==0, "attachment exists: " + c );
+
+        c = refMgr.findUnreferenced();
+        Assertions.assertEquals( 2, c.size(), "unreferenced count" );
+        final Iterator< String > i = c.iterator();
+        final String first = i.next();
+        final String second = i.next();
+        Assertions.assertTrue(  ( first.equals( NAME1 ) && second.equals( NAME1 + "/TestAtt.txt" ) )
+                             || ( first.equals( NAME1 + "/TestAtt.txt" ) && second.equals( NAME1 ) ), "unreferenced" );
     }
 
     /**
@@ -312,11 +270,9 @@ public class WikiEngineTest {
     */
 
     @Test
-    public void testAttachmentRefs2()
-        throws Exception
-    {
-        ReferenceManager refMgr = m_engine.getReferenceManager();
-        AttachmentManager attMgr = m_engine.getAttachmentManager();
+    public void testAttachmentRefs2() throws Exception {
+        final ReferenceManager refMgr = m_engine.getReferenceManager();
+        final AttachmentManager attMgr = m_engine.getAttachmentManager();
 
         m_engine.saveText( NAME1, "[TestAtt.txt]");
 
@@ -333,249 +289,179 @@ public class WikiEngineTest {
 
         // now we create the attachment
 
-        Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
+        final Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
         att.setAuthor( "FirstPost" );
         attMgr.storeAttachment( att, m_engine.makeAttachmentFile() );
-        try
-        {
-            // and check post-conditions
-            c = refMgr.findUncreated();
-            Assertions.assertTrue( c==null || c.size()==0, "attachment exists: " );
 
-            c = refMgr.findReferrers( "TestAtt.txt" );
-            Assertions.assertTrue( c==null || c.size()==0, "no normal page" );
+        // and check post-conditions
+        c = refMgr.findUncreated();
+        Assertions.assertTrue( c==null || c.size()==0, "attachment exists: " );
 
-            c = refMgr.findReferrers( NAME1+"/TestAtt.txt" );
-            Assertions.assertTrue( c!=null && c.iterator().next().equals( NAME1 ), "attachment exists now" );
+        c = refMgr.findReferrers( "TestAtt.txt" );
+        Assertions.assertTrue( c==null || c.size()==0, "no normal page" );
 
-            c = refMgr.findUnreferenced();
-            Assertions.assertTrue( c.size()==1 && c.iterator().next().equals( NAME1 ), "unreferenced" );
-        }
-        finally
-        {
-            // do cleanup
-            String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
-            TestEngine.deleteAll( new File( files, NAME1+BasicAttachmentProvider.DIR_EXTENSION ) );
-        }
+        c = refMgr.findReferrers( NAME1+"/TestAtt.txt" );
+        Assertions.assertTrue( c!=null && c.iterator().next().equals( NAME1 ), "attachment exists now" );
+
+        c = refMgr.findUnreferenced();
+        Assertions.assertTrue( c.size()==1 && c.iterator().next().equals( NAME1 ), "unreferenced" );
     }
 
     /**
      *  Checks, if ReferenceManager is informed if a link to an attachment is added.
      */
     @Test
-    public void testAttachmentRefs3()
-        throws Exception
-    {
-        ReferenceManager refMgr = m_engine.getReferenceManager();
-        AttachmentManager attMgr = m_engine.getAttachmentManager();
+    public void testAttachmentRefs3() throws Exception {
+        final ReferenceManager refMgr = m_engine.getReferenceManager();
+        final AttachmentManager attMgr = m_engine.getAttachmentManager();
 
         m_engine.saveText( NAME1, "fooBar");
 
-        Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
+        final Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
         att.setAuthor( "FirstPost" );
         attMgr.storeAttachment( att, m_engine.makeAttachmentFile() );
 
         m_engine.saveText( NAME1, " ["+NAME1+"/TestAtt.txt] ");
 
-        try
-        {
-            // and check post-conditions
-            Collection< String > c = refMgr.findUncreated();
-            Assertions.assertTrue( c==null || c.size()==0, "attachment exists" );
+        // and check post-conditions
+        Collection< String > c = refMgr.findUncreated();
+        Assertions.assertTrue( c==null || c.size()==0, "attachment exists" );
 
-            c = refMgr.findUnreferenced();
-            Assertions.assertEquals( c.size(), 1, "unreferenced count" );
-            Assertions.assertTrue( c.iterator().next().equals( NAME1 ), "unreferenced" );
-        }
-        finally
-        {
-            // do cleanup
-            String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
-            TestEngine.deleteAll( new File( files, NAME1+BasicAttachmentProvider.DIR_EXTENSION ) );
-        }
+        c = refMgr.findUnreferenced();
+        Assertions.assertEquals( c.size(), 1, "unreferenced count" );
+        Assertions.assertEquals( NAME1, c.iterator().next(), "unreferenced" );
     }
 
     /**
      *  Checks, if ReferenceManager is informed if a third page references an attachment.
      */
     @Test
-    public void testAttachmentRefs4()
-        throws Exception
-    {
-        ReferenceManager refMgr = m_engine.getReferenceManager();
-        AttachmentManager attMgr = m_engine.getAttachmentManager();
+    public void testAttachmentRefs4() throws Exception {
+        final ReferenceManager refMgr = m_engine.getReferenceManager();
+        final AttachmentManager attMgr = m_engine.getAttachmentManager();
 
         m_engine.saveText( NAME1, "[TestPage2]");
 
-        Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
+        final Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
         att.setAuthor( "FirstPost" );
         attMgr.storeAttachment( att, m_engine.makeAttachmentFile() );
-
         m_engine.saveText( "TestPage2", "["+NAME1+"/TestAtt.txt]");
 
-        try
-        {
-            // and check post-conditions
-            Collection< String > c = refMgr.findUncreated();
-            Assertions.assertTrue( c==null || c.size()==0, "attachment exists" );
+        // and check post-conditions
+        Collection< String > c = refMgr.findUncreated();
+        Assertions.assertTrue( c==null || c.size()==0, "attachment exists" );
 
-            c = refMgr.findUnreferenced();
-            Assertions.assertEquals( c.size(), 1, "unreferenced count" );
-            Assertions.assertTrue( c.iterator().next().equals( NAME1 ), "unreferenced" );
-        }
-        finally
-        {
-            // do cleanup
-            String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
-            TestEngine.deleteAll( new File( files, NAME1+BasicAttachmentProvider.DIR_EXTENSION ) );
-            new File( files, "TestPage2"+FileSystemProvider.FILE_EXT ).delete();
-        }
+        c = refMgr.findUnreferenced();
+        Assertions.assertEquals( c.size(), 1, "unreferenced count" );
+        Assertions.assertEquals( NAME1, c.iterator().next(), "unreferenced" );
     }
 
     /**
      *  Tests BugReadingOfVariableNotWorkingForOlderVersions
-     * @throws Exception
      */
     @Test
-    public void testOldVersionVars()
-        throws Exception
-    {
-        Properties props = TestEngine.getTestProperties("/jspwiki-vers-custom.properties");
-
+    public void testOldVersionVars() throws Exception {
+        final Properties props = TestEngine.getTestProperties("/jspwiki-vers-custom.properties");
         props.setProperty( PageManager.PROP_USECACHE, "true" );
-
-        TestEngine engine = new TestEngine( props );
-
+        final TestEngine engine = new TestEngine( props );
         engine.saveText( NAME1, "[{SET foo=bar}]" );
-
         engine.saveText( NAME1, "[{SET foo=notbar}]");
 
-        WikiPage v1 = engine.getPageManager().getPage( NAME1, 1 );
-        WikiPage v2 = engine.getPageManager().getPage( NAME1, 2 );
+        final WikiPage v1 = engine.getPageManager().getPage( NAME1, 1 );
+        final WikiPage v2 = engine.getPageManager().getPage( NAME1, 2 );
 
         Assertions.assertEquals( "bar", v1.getAttribute("foo"), "V1" );
-
-        // FIXME: The following must run as well
         Assertions.assertEquals( "notbar", v2.getAttribute("foo"), "V2" );
 
         engine.getPageManager().deletePage( NAME1 );
     }
 
     @Test
-    public void testSpacedNames1()
-        throws Exception
-    {
+    public void testSpacedNames1() throws Exception {
         m_engine.saveText("This is a test", "puppaa");
-
         Assertions.assertEquals( "puppaa", m_engine.getText("This is a test").trim(), "normal" );
     }
 
 
     @Test
-    public void testParsedVariables() throws Exception
-    {
+    public void testParsedVariables() throws Exception {
         m_engine.saveText( "TestPage", "[{SET foo=bar}][{SamplePlugin text='{$foo}'}]");
-
-        String res = m_engine.getHTML( "TestPage" );
+        final String res = m_engine.getHTML( "TestPage" );
 
         Assertions.assertEquals( "bar\n", res );
     }
 
     /**
      * Tests BugReferenceToRenamedPageNotCleared
-     *
-     * @throws Exception
      */
     @Test
-    public void testRename() throws Exception
-    {
+    public void testRename() throws Exception {
         m_engine.saveText( "RenameBugTestPage", "Mary had a little generic object" );
         m_engine.saveText( "OldNameTestPage", "Linked to RenameBugTestPage" );
 
         Collection< String > pages = m_engine.getReferenceManager().findReferrers( "RenameBugTestPage" );
         Assertions.assertEquals( "OldNameTestPage", pages.iterator().next(), "has one" );
 
-        WikiContext ctx = new WikiContext( m_engine, m_engine.getPageManager().getPage("OldNameTestPage") );
-
+        final WikiContext ctx = new WikiContext( m_engine, m_engine.getPageManager().getPage("OldNameTestPage") );
         m_engine.getPageRenamer().renamePage( ctx, "OldNameTestPage", "NewNameTestPage", true );
 
         Assertions.assertFalse( m_engine.pageExists( "OldNameTestPage"), "did not vanish" );
         Assertions.assertTrue( m_engine.pageExists( "NewNameTestPage"), "did not appear" );
 
         pages = m_engine.getReferenceManager().findReferrers( "RenameBugTestPage" );
-
         Assertions.assertEquals( 1, pages.size(),  "wrong # of referrers" );
-
         Assertions.assertEquals( "NewNameTestPage", pages.iterator().next(), "has wrong referrer" );
     }
 
     @Test
-    public void testChangeNoteOldVersion2() throws Exception
-    {
-        WikiPage p = new WikiPage( m_engine, NAME1 );
-
-        WikiContext context = new WikiContext(m_engine,p);
-
+    public void testChangeNoteOldVersion2() throws Exception {
+        final WikiPage p = new WikiPage( m_engine, NAME1 );
+        final WikiContext context = new WikiContext(m_engine,p);
         context.getPage().setAttribute( WikiPage.CHANGENOTE, "Test change" );
-
         m_engine.saveText( context, "test" );
 
-        for( int i = 0; i < 5; i++ )
-        {
-            WikiPage p2 = (WikiPage)m_engine.getPageManager().getPage( NAME1 ).clone();
-            p2.removeAttribute(WikiPage.CHANGENOTE);
-
+        for( int i = 0; i < 5; i++ ) {
+            final WikiPage p2 = ( WikiPage )m_engine.getPageManager().getPage( NAME1 ).clone();
+            p2.removeAttribute( WikiPage.CHANGENOTE );
             context.setPage( p2 );
-
-            m_engine.saveText( context, "test"+i );
+            m_engine.saveText( context, "test" + i );
         }
 
-        WikiPage p3 = m_engine.getPageManager().getPage( NAME1, -1 );
-
-        Assertions.assertEquals( null, p3.getAttribute(WikiPage.CHANGENOTE) );
+        final WikiPage p3 = m_engine.getPageManager().getPage( NAME1, -1 );
+        Assertions.assertNull( p3.getAttribute( WikiPage.CHANGENOTE ) );
     }
 
     @Test
-    public void testCreatePage() throws Exception
-    {
-        String text = "Foobar.\r\n";
-        String name = "mrmyxpltz";
-
-        Assertions.assertEquals( false, m_engine.pageExists( name ), "page should not exist right now" );
+    public void testCreatePage() throws Exception {
+        final String text = "Foobar.\r\n";
+        final String name = "mrmyxpltz";
+        Assertions.assertFalse( m_engine.pageExists( name ), "page should not exist right now" );
 
         m_engine.saveText( name, text );
-
-        Assertions.assertEquals( true, m_engine.pageExists( name ), "page does not exist" );
+        Assertions.assertTrue( m_engine.pageExists( name ), "page does not exist" );
     }
 
     @Test
-    public void testCreateEmptyPage() throws Exception
-    {
-        String text = "";
-        String name = "mrmxyzptlk";
-
-        Assertions.assertEquals( false, m_engine.pageExists( name ), "page should not exist right now" );
+    public void testCreateEmptyPage() throws Exception {
+        final String text = "";
+        final String name = "mrmxyzptlk";
+        Assertions.assertFalse( m_engine.pageExists( name ), "page should not exist right now" );
 
         m_engine.saveText( name, text );
-
-        Assertions.assertEquals( false, m_engine.pageExists( name ), "page should not exist right now neither" );
+        Assertions.assertFalse( m_engine.pageExists( name ), "page should not exist right now neither" );
     }
 
     @Test
-    public void testSaveExistingPageWithEmptyContent() throws Exception
-    {
-        String text = "Foobar.\r\n";
-        String name = NAME1;
-
+    public void testSaveExistingPageWithEmptyContent() throws Exception {
+        final String text = "Foobar.\r\n";
+        final String name = NAME1;
         m_engine.saveText( name, text );
 
-        Assertions.assertEquals( true, m_engine.pageExists( name ), "page does not exist" );
-
+        Assertions.assertTrue( m_engine.pageExists( name ), "page does not exist" );
         // saveText uses normalizePostData to assure it conforms to certain rules
         Assertions.assertEquals( TextUtil.normalizePostData( text ), m_engine.getText( name ), "wrong content" );
 
         m_engine.saveText( name, "" );
-
         Assertions.assertEquals( TextUtil.normalizePostData( "" ), m_engine.getText( name ), "wrong content" );
     }
 


[jspwiki] 16/32: JSPWIKI-120: move getRecentChanges from WikiEngine to PageManager

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 686c57aa209237799e739303009e6916ef45e399
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Jan 5 01:48:31 2020 +0100

    JSPWIKI-120: move getRecentChanges from WikiEngine to PageManager
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  27 ----
 .../org/apache/wiki/pages/DefaultPageManager.java  |  21 +++
 .../java/org/apache/wiki/pages/PageManager.java    |   9 ++
 .../apache/wiki/plugin/RecentChangesPlugin.java    |   2 +-
 .../java/org/apache/wiki/rss/RSSGenerator.java     |  39 ++----
 .../org/apache/wiki/xmlrpc/AbstractRPCHandler.java |  66 ++++-----
 .../java/org/apache/wiki/xmlrpc/RPCHandler.java    |  18 ++-
 .../org/apache/wiki/xmlrpc/RPCHandlerUTF8.java     | 149 +++++++--------------
 8 files changed, 129 insertions(+), 202 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 56b5e33..8e60b4c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -43,7 +43,6 @@ import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.pages.PageManager;
-import org.apache.wiki.pages.PageTimeComparator;
 import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.parser.WikiDocument;
 import org.apache.wiki.providers.WikiPageProvider;
@@ -92,9 +91,7 @@ import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
 import java.util.TimeZone;
-import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 
 
@@ -1489,30 +1486,6 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns a Collection of WikiPages, sorted in time
-     *  order of last change (i.e. first object is the most
-     *  recently changed).  This method also includes attachments.
-     *
-     *  @return Set of WikiPage objects.
-     */
-    public Set< WikiPage > getRecentChanges() {
-        try {
-            final Collection< WikiPage >   pages = m_pageManager.getAllPages();
-            final Collection< Attachment >  atts = m_attachmentManager.getAllAttachments();
-
-            final TreeSet< WikiPage > sortedPages = new TreeSet<>( new PageTimeComparator() );
-
-            sortedPages.addAll( pages );
-            sortedPages.addAll( atts );
-
-            return sortedPages;
-        } catch( final ProviderException e ) {
-            log.error( "Unable to fetch all pages: ",e);
-            return null;
-        }
-    }
-
-    /**
      *  Returns a Collection of WikiPages containing the version history of a page.
      *
      *  @param page Name of the page to look for
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index 3d5248e..123ce71 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -50,12 +50,15 @@ import java.security.Permission;
 import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.Date;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
 import java.util.NoSuchElementException;
 import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 import java.util.concurrent.ConcurrentHashMap;
 
 
@@ -397,6 +400,24 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
 
     /**
      * {@inheritDoc}
+     * @see org.apache.wiki.pages.PageManager#getRecentChanges()
+     */
+    @Override
+    public Set< WikiPage > getRecentChanges() {
+        try {
+            final TreeSet< WikiPage > sortedPages = new TreeSet<>( new PageTimeComparator() );
+            sortedPages.addAll( getAllPages() );
+            sortedPages.addAll( m_engine.getAttachmentManager().getAllAttachments() );
+
+            return sortedPages;
+        } catch( final ProviderException e ) {
+            LOG.error( "Unable to fetch all pages: ", e );
+            return Collections.emptySet();
+        }
+    }
+
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#pageExists(java.lang.String)
      */
     @Override
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index 6ff9dcd..1780a5d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -27,6 +27,7 @@ import org.apache.wiki.providers.WikiPageProvider;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Set;
 
 
 public interface PageManager extends WikiEventListener {
@@ -214,6 +215,14 @@ public interface PageManager extends WikiEventListener {
     int getTotalPageCount();
 
     /**
+     *  Returns a Collection of WikiPages, sorted in time order of last change (i.e. first object is the most recently changed).
+     *  This method also includes attachments.
+     *
+     *  @return Set of WikiPage objects.
+     */
+    Set< WikiPage > getRecentChanges();
+
+    /**
      * Returns true, if the page exists (any version).
      *
      * @param pageName Name of the page.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java
index 2d3637f..16c1d41 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java
@@ -100,7 +100,7 @@ public class RecentChangesPlugin extends AbstractReferralPlugin implements WikiP
         log.debug("Calculating recent changes from "+sincedate.getTime());
 
         // FIXME: Should really have a since date on the getRecentChanges method.
-        Collection< WikiPage > changes = engine.getRecentChanges();
+        Collection< WikiPage > changes = engine.getPageManager().getRecentChanges();
         super.initialize( context, params );
         changes = filterWikiPageCollection( changes );
         
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 174f0b6..53e5fe2 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
@@ -328,52 +328,37 @@ public class RSSGenerator {
      *  @param feed A Feed to generate the feed to.
      *  @return feed.getString().
      */
-    protected String generateFullWikiRSS( WikiContext wikiContext, Feed feed )
-    {
+    protected String generateFullWikiRSS( final WikiContext wikiContext, final Feed feed ) {
         feed.setChannelTitle( m_engine.getApplicationName() );
         feed.setFeedURL( m_engine.getBaseURL() );
         feed.setChannelLanguage( m_channelLanguage );
         feed.setChannelDescription( m_channelDescription );
 
-        Set< WikiPage > changed = m_engine.getRecentChanges();
+        final Set< WikiPage > changed = m_engine.getPageManager().getRecentChanges();
 
-        WikiSession session = WikiSession.guestSession( m_engine );
+        final WikiSession session = WikiSession.guestSession( m_engine );
         int items = 0;
-        for( Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ )
-        {
+        for( final Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
             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) ) )
-            {
+            if( !m_engine.getAuthorizationManager().checkPermission(session, new PagePermission(page,PagePermission.VIEW_ACTION) ) ) {
                 // No permission, skip to the next one.
                 continue;
             }
 
-            Entry e = new Entry();
-
-            e.setPage( page );
-
-            String url;
-
-            if( page instanceof Attachment )
-            {
-                url = m_engine.getURL( WikiContext.ATTACH,
-                                       page.getName(),
-                                       null,
-                                       true );
-            }
-            else
-            {
-                url = m_engine.getURL( WikiContext.VIEW,
-                                       page.getName(),
-                                       null,
-                                       true );
+            final String url;
+            if( page instanceof Attachment ) {
+                url = m_engine.getURL( WikiContext.ATTACH, page.getName(),null, true );
+            } else {
+                url = m_engine.getURL( WikiContext.VIEW, page.getName(), null, true );
             }
 
+            final Entry e = new Entry();
+            e.setPage( page );
             e.setURL( url );
             e.setTitle( page.getName() );
             e.setContent( getEntryDescription(page) );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java
index 5b21b80..3b1406b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/AbstractRPCHandler.java
@@ -18,17 +18,20 @@
  */
 package org.apache.wiki.xmlrpc;
 
-import java.security.Permission;
-import java.util.*;
-
-import org.apache.xmlrpc.AuthenticationFailed;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.auth.permissions.WikiPermission;
+import org.apache.xmlrpc.AuthenticationFailed;
+
+import java.security.Permission;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.Set;
+import java.util.Vector;
 
 /**
  *  Provides definitions for RPC handler routines.
@@ -36,61 +39,47 @@ import org.apache.wiki.auth.permissions.WikiPermission;
  *  @since 1.6.13
  */
 
-public abstract class AbstractRPCHandler
-    implements WikiRPCHandler
-{
+public abstract class AbstractRPCHandler implements WikiRPCHandler {
+
     /** Error code: no such page. */
     public static final int ERR_NOPAGE       = 1;
     public static final int ERR_NOPERMISSION = 2;
 
-    /**
-     *  Link to a local wiki page.
-     */
+    /** Link to a local wiki page. */
     public static final String LINK_LOCAL    = "local";
 
-    /**
-     *  Link to an external resource.
-     */
+    /** Link to an external resource. */
     public static final String LINK_EXTERNAL = "external";
 
-    /**
-     *  This is an inlined image.
-     */
+    /** This is an inlined image. */
     public static final String LINK_INLINE   = "inline";
 
     protected WikiEngine m_engine;
     protected WikiContext m_context;
 
-
-    /**
-     *  This is the currently implemented JSPWiki XML-RPC code revision.
-     */
+    /** This is the currently implemented JSPWiki XML-RPC code revision. */
     public static final int RPC_VERSION = 1;
 
-    public void initialize( WikiContext context )
-    {
+    public void initialize( final WikiContext context ) {
         m_context = context;
         m_engine  = context.getEngine();
     }
 
     protected abstract Hashtable encodeWikiPage( WikiPage p );
 
-    public Vector getRecentChanges( Date since )
-    {
+    public Vector getRecentChanges( final Date since ) {
         checkPermission( PagePermission.VIEW );
-        Collection< WikiPage > pages = m_engine.getRecentChanges();
-        Vector< Hashtable< ?, ? > > result = new Vector<Hashtable< ?, ? > >();
+        final Set< WikiPage > pages = m_engine.getPageManager().getRecentChanges();
+        final Vector< Hashtable< ?, ? > > result = new Vector<>();
 
         // Transform UTC into local time.
-        Calendar cal = Calendar.getInstance();
+        final Calendar cal = Calendar.getInstance();
         cal.setTime( since );
         cal.add( Calendar.MILLISECOND, cal.get( Calendar.ZONE_OFFSET ) +
                   (cal.getTimeZone().inDaylightTime( since ) ? cal.get( Calendar.DST_OFFSET ) : 0 ) );
 
-        for( WikiPage page : pages )
-        {
-            if( page.getLastModified().after( cal.getTime() ) )
-            {
+        for( WikiPage page : pages ) {
+            if( page.getLastModified().after( cal.getTime() ) ) {
                 result.add( encodeWikiPage( page ) );
             }
         }
@@ -104,12 +93,12 @@ public abstract class AbstractRPCHandler
      *
      *  @param perm the Permission to check
      */
-    protected void checkPermission( Permission perm )
-    {
-        AuthorizationManager mgr = m_engine.getAuthorizationManager();
+    protected void checkPermission( final Permission perm ) {
+        final AuthorizationManager mgr = m_engine.getAuthorizationManager();
 
-        if( mgr.checkPermission( m_context.getWikiSession(), perm ) )
+        if( mgr.checkPermission( m_context.getWikiSession(), perm ) ) {
             return;
+        }
 
         throw new AuthenticationFailed( "You have no access to this resource, o master" );
     }
@@ -117,10 +106,9 @@ public abstract class AbstractRPCHandler
     /**
      *  Returns the current supported JSPWiki XML-RPC API.
      */
-    public int getRPCVersionSupported()
-    {
+    public int getRPCVersionSupported() {
         checkPermission( WikiPermission.LOGIN );
-
         return RPC_VERSION;
     }
+
 }
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 3cb0a83..3ab3355 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
@@ -35,6 +35,7 @@ import java.util.Collection;
 import java.util.Date;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.Set;
 import java.util.Vector;
 
 /**
@@ -91,7 +92,7 @@ public class RPCHandler
     public Vector getAllPages()
     {
         checkPermission( PagePermission.VIEW );
-        Collection< WikiPage > pages = m_engine.getRecentChanges();
+        Collection< WikiPage > pages = m_engine.getPageManager().getRecentChanges();
         Vector<String> result = new Vector<>();
 
         for( WikiPage p : pages )
@@ -142,13 +143,12 @@ public class RPCHandler
     }
 
     @Override
-    public Vector getRecentChanges( Date since )
-    {
+    public Vector getRecentChanges( Date since ) {
         checkPermission( PagePermission.VIEW );
-        Collection< WikiPage > pages = m_engine.getRecentChanges();
-        Vector<Hashtable<String, Object>> result = new Vector<>();
+        final Set< WikiPage > pages = m_engine.getPageManager().getRecentChanges();
+        final Vector< Hashtable< String, Object > > result = new Vector<>();
 
-        Calendar cal = Calendar.getInstance();
+        final Calendar cal = Calendar.getInstance();
         cal.setTime( since );
 
         //
@@ -159,10 +159,8 @@ public class RPCHandler
                   (cal.getTimeZone().inDaylightTime(since) ? cal.get( Calendar.DST_OFFSET ) : 0 ) ) );
         since = cal.getTime();
 
-        for( WikiPage page : pages )
-        {
-            if( page.getLastModified().after( since ) && !(page instanceof Attachment) )
-            {
+        for( final WikiPage page : pages ) {
+            if( page.getLastModified().after( since ) && !(page instanceof Attachment) ) {
                 result.add( encodeWikiPage( page ) );
             }
         }
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 9444453..0390aff 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
@@ -28,10 +28,9 @@ import org.apache.wiki.auth.permissions.PermissionFactory;
 import org.apache.xmlrpc.XmlRpcException;
 
 import java.util.Calendar;
-import java.util.Collection;
 import java.util.Date;
 import java.util.Hashtable;
-import java.util.Iterator;
+import java.util.Set;
 import java.util.Vector;
 
 /**
@@ -41,27 +40,21 @@ import java.util.Vector;
  *  @since 1.6.13
  */
 
-public class RPCHandlerUTF8
-    extends AbstractRPCHandler
-{
-    public String getApplicationName()
-    {
-        checkPermission( PagePermission.VIEW );
+public class RPCHandlerUTF8 extends AbstractRPCHandler {
 
+    public String getApplicationName() {
+        checkPermission( PagePermission.VIEW );
         return m_engine.getApplicationName();
     }
 
-    public Vector getAllPages()
-    {
+    public Vector< String > getAllPages() {
         checkPermission( PagePermission.VIEW );
 
-        Collection< WikiPage > pages = m_engine.getRecentChanges();
-        Vector<String> result = new Vector<String>();
+        final Set< WikiPage > pages = m_engine.getPageManager().getRecentChanges();
+        final Vector< String > result = new Vector<>();
 
-        for( WikiPage p : pages )
-        {
-            if( !(p instanceof Attachment) )
-            {
+        for( final WikiPage p : pages ) {
+            if( !( p instanceof Attachment ) ) {
                 result.add( p.getName() );
             }
         }
@@ -72,22 +65,17 @@ public class RPCHandlerUTF8
     /**
      *  Encodes a single wiki page info into a Hashtable.
      */
-    protected Hashtable<String, Object> encodeWikiPage( WikiPage page )
-    {
-        Hashtable<String, Object> ht = new Hashtable<String, Object>();
-
+    protected Hashtable<String, Object> encodeWikiPage( final WikiPage page ) {
+        final Hashtable<String, Object> ht = new Hashtable<>();
         ht.put( "name", page.getName() );
 
-        Date d = page.getLastModified();
+        final Date d = page.getLastModified();
 
         //
-        //  Here we reset the DST and TIMEZONE offsets of the
-        //  calendar.  Unfortunately, I haven't thought of a better
-        //  way to ensure that we're getting the proper date
-        //  from the XML-RPC thingy, except to manually adjust the date.
+        //  Here we reset the DST and TIMEZONE offsets of the calendar.  Unfortunately, I haven't thought of a better
+        //  way to ensure that we're getting the proper date from the XML-RPC thingy, except to manually adjust the date.
         //
-
-        Calendar cal = Calendar.getInstance();
+        final Calendar cal = Calendar.getInstance();
         cal.setTime( d );
         cal.add( Calendar.MILLISECOND,
                  - (cal.get( Calendar.ZONE_OFFSET ) +
@@ -96,22 +84,20 @@ public class RPCHandlerUTF8
         ht.put( "lastModified", cal.getTime() );
         ht.put( "version", page.getVersion() );
 
-        if( page.getAuthor() != null )
-        {
+        if( page.getAuthor() != null ) {
             ht.put( "author", page.getAuthor() );
         }
 
         return ht;
     }
 
-    public Vector getRecentChanges( Date since )
-    {
+    public Vector< Hashtable< String, Object > > getRecentChanges( Date since ) {
         checkPermission( PagePermission.VIEW );
 
-        Collection< WikiPage > pages = m_engine.getRecentChanges();
-        Vector<Hashtable<String, Object>> result = new Vector<>();
+        final Set< WikiPage > pages = m_engine.getPageManager().getRecentChanges();
+        final Vector< Hashtable< String, Object > > result = new Vector<>();
 
-        Calendar cal = Calendar.getInstance();
+        final Calendar cal = Calendar.getInstance();
         cal.setTime( since );
 
         //
@@ -122,10 +108,8 @@ public class RPCHandlerUTF8
                   (cal.getTimeZone().inDaylightTime(since) ? cal.get( Calendar.DST_OFFSET ) : 0 ) ) );
         since = cal.getTime();
 
-        for( WikiPage page : pages )
-        {
-            if( page.getLastModified().after( since ) && !(page instanceof Attachment) )
-            {
+        for( final WikiPage page : pages ) {
+            if( page.getLastModified().after( since ) && !( page instanceof Attachment ) ) {
                 result.add( encodeWikiPage( page ) );
             }
         }
@@ -141,31 +125,22 @@ public class RPCHandlerUTF8
      *  @return Real page name, as Java string.
      *  @throws XmlRpcException, if there is something wrong with the page.
      */
-    private String parsePageCheckCondition( String pagename )
-        throws XmlRpcException
-    {
-        if( !m_engine.pageExists(pagename) )
-        {
+    private String parsePageCheckCondition( final String pagename ) throws XmlRpcException {
+        if( !m_engine.pageExists(pagename) ) {
             throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );
         }
 
-        WikiPage p = m_engine.getPageManager().getPage( pagename );
+        final WikiPage p = m_engine.getPageManager().getPage( pagename );
 
         checkPermission( PermissionFactory.getPagePermission( p, PagePermission.VIEW_ACTION ) );
         return pagename;
     }
 
-    public Hashtable getPageInfo( String pagename )
-        throws XmlRpcException
-    {
-        pagename = parsePageCheckCondition( pagename );
-
-        return encodeWikiPage( m_engine.getPageManager().getPage(pagename) );
+    public Hashtable<String, Object> getPageInfo( final String pagename ) throws XmlRpcException {
+        return encodeWikiPage( m_engine.getPageManager().getPage( parsePageCheckCondition( pagename ) ) );
     }
 
-    public Hashtable getPageInfoVersion( String pagename, int version )
-        throws XmlRpcException
-    {
+    public Hashtable<String, Object> getPageInfoVersion( String pagename, final int version ) throws XmlRpcException {
         pagename = parsePageCheckCondition( pagename );
 
         return encodeWikiPage( m_engine.getPageManager().getPage( pagename, version ) );
@@ -183,56 +158,41 @@ public class RPCHandlerUTF8
         return m_engine.getHTML( parsePageCheckCondition( pagename ) );
     }
 
-    public String getPageHTMLVersion( String pagename, int version )
-        throws XmlRpcException
-    {
-        pagename = parsePageCheckCondition( pagename );
-
-        return m_engine.getHTML( pagename, version );
+    public String getPageHTMLVersion( final String pagename, final int version ) throws XmlRpcException {
+        return m_engine.getHTML( parsePageCheckCondition( pagename ), version );
     }
 
-    public Vector listLinks( String pagename )
-        throws XmlRpcException
-    {
+    public Vector< Hashtable< String, String > > listLinks( String pagename ) throws XmlRpcException {
         pagename = parsePageCheckCondition( pagename );
 
-        WikiPage page = m_engine.getPageManager().getPage( pagename );
-        String pagedata = m_engine.getPageManager().getPureText( page );
+        final WikiPage page = m_engine.getPageManager().getPage( pagename );
+        final String pagedata = m_engine.getPageManager().getPureText( page );
 
-        LinkCollector localCollector = new LinkCollector();
-        LinkCollector extCollector   = new LinkCollector();
-        LinkCollector attCollector   = new LinkCollector();
+        final LinkCollector localCollector = new LinkCollector();
+        final LinkCollector extCollector   = new LinkCollector();
+        final LinkCollector attCollector   = new LinkCollector();
 
-        WikiContext context = new WikiContext( m_engine, page );
+        final WikiContext context = new WikiContext( m_engine, page );
         context.setVariable( WikiEngine.PROP_REFSTYLE, "absolute" );
 
-        m_engine.textToHTML( context,
-                             pagedata,
-                             localCollector,
-                             extCollector,
-                             attCollector );
+        m_engine.textToHTML( context, pagedata, localCollector, extCollector, attCollector );
 
-        Vector<Hashtable<String, String>> result = new Vector<>();
+        final Vector< Hashtable< String, String > > result = new Vector<>();
 
         // FIXME: Contains far too much common with RPCHandler.  Refactor!
 
         //
         //  Add local links.
         //
-        for( Iterator< String > i = localCollector.getLinks().iterator(); i.hasNext(); )
-        {
-            String link = i.next();
-            Hashtable< String, String > ht = new Hashtable< String, String >();
+        for( final String link : localCollector.getLinks() ) {
+            final Hashtable<String, String> ht = new Hashtable<>();
             ht.put( "page", link );
             ht.put( "type", LINK_LOCAL );
 
-            if( m_engine.pageExists(link) )
-            {
-                ht.put( "href", context.getViewURL(link) );
-            }
-            else
-            {
-                ht.put( "href", context.getURL(WikiContext.EDIT,link) );
+            if( m_engine.pageExists( link ) ) {
+                ht.put( "href", context.getViewURL( link ) );
+            } else {
+                ht.put( "href", context.getURL( WikiContext.EDIT, link ) );
             }
 
             result.add( ht );
@@ -241,33 +201,26 @@ public class RPCHandlerUTF8
         //
         // Add links to inline attachments
         //
-        for( String link : attCollector.getLinks() )
-        {
-            Hashtable<String, String> ht = new Hashtable<String, String>();
-
+        for( final String link : attCollector.getLinks() ) {
+            final Hashtable<String, String> ht = new Hashtable<>();
             ht.put( "page", link );
             ht.put( "type", LINK_LOCAL );
             ht.put( "href", context.getURL(WikiContext.ATTACH,link) );
-
             result.add( ht );
         }
 
         //
-        // External links don't need to be changed into XML-RPC strings,
-        // simply because URLs are by definition ASCII.
+        // External links don't need to be changed into XML-RPC strings, simply because URLs are by definition ASCII.
         //
-
-        for( String link : extCollector.getLinks() )
-        {
-            Hashtable<String, String> ht = new Hashtable<String, String>();
-
+        for( final String link : extCollector.getLinks() )  {
+            final Hashtable<String, String> ht = new Hashtable<>();
             ht.put( "page", link );
             ht.put( "type", LINK_EXTERNAL );
             ht.put( "href", link );
-
             result.add( ht );
         }
 
         return result;
     }
+
 }


[jspwiki] 25/32: explicit casting on WikiPage#getAttribute() can be removed in most cases now

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 2bac2a4f28ca426cd78e90746aa14955e4cd5771
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 8 00:29:40 2020 +0100

    explicit casting on WikiPage#getAttribute() can be removed in most cases now
---
 .../src/main/java/org/apache/wiki/WikiContext.java       |  6 +++---
 jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java | 14 +++++++-------
 .../main/java/org/apache/wiki/filters/SpamFilter.java    |  8 +++-----
 .../java/org/apache/wiki/parser/JSPWikiMarkupParser.java |  2 +-
 .../java/org/apache/wiki/plugin/RecentChangesPlugin.java |  4 ++--
 .../apache/wiki/providers/BasicAttachmentProvider.java   |  2 +-
 .../org/apache/wiki/providers/FileSystemProvider.java    | 12 ++++++------
 .../apache/wiki/providers/VersioningFileProvider.java    |  2 +-
 .../java/org/apache/wiki/rpc/atom/AtomAPIServlet.java    |  3 ++-
 .../apache/wiki/providers/FileSystemProviderTest.java    | 16 ++++++++--------
 10 files changed, 34 insertions(+), 35 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 4b33cf3..bea0ea4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -337,7 +337,7 @@ public class WikiContext implements Cloneable, Command {
 
         if( redirURL == null )
         {
-            String alias = (String)m_page.getAttribute( WikiPage.ALIAS );
+            String alias = m_page.getAttribute( WikiPage.ALIAS );
 
             if( alias != null )
             {
@@ -345,7 +345,7 @@ public class WikiContext implements Cloneable, Command {
             }
             else
             {
-                redirURL = (String)m_page.getAttribute( WikiPage.REDIRECT );
+                redirURL = m_page.getAttribute( WikiPage.REDIRECT );
             }
         }
 
@@ -802,7 +802,7 @@ public class WikiContext implements Cloneable, Command {
             WikiPage page = getPage();
             if ( page != null )
             {
-                template = (String)page.getAttribute( WikiEngine.PROP_TEMPLATEDIR );
+                template = page.getAttribute( WikiEngine.PROP_TEMPLATEDIR );
             }
 
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
index 6d00214..8cb19f9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
@@ -18,16 +18,16 @@
  */
 package org.apache.wiki;
 
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
-
 import org.apache.wiki.auth.acl.Acl;
 import org.apache.wiki.auth.acl.AclEntry;
 import org.apache.wiki.auth.acl.AclImpl;
 import org.apache.wiki.providers.WikiPageProvider;
 
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  *  Simple wrapper class for the Wiki page attributes.  The Wiki page
  *  content is moved around in Strings, though.
@@ -103,9 +103,9 @@ public class WikiPage implements Cloneable, Comparable< WikiPage > {
      *  @param key The key using which the attribute is fetched
      *  @return The attribute.  If the attribute has not been set, returns null.
      */
-    public Object getAttribute( String key )
+    public < T > T getAttribute( String key )
     {
-        return m_attributes.get( key );
+        return (T)m_attributes.get( key );
     }
 
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
index bc1acc7..c018bfc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
@@ -753,13 +753,11 @@ public class SpamFilter extends BasicPageFilter {
             //
             if( rebuild ) {
                 m_lastRebuild = new Date();
-                m_spamPatterns = parseWordList( sourceSpam,
-                                                ( sourceSpam != null ) ? ( String )sourceSpam.getAttribute( LISTVAR ) : null );
+                m_spamPatterns = parseWordList( sourceSpam, ( sourceSpam != null ) ? sourceSpam.getAttribute( LISTVAR ) : null );
 
                 log.info( "Spam filter reloaded - recognizing " + m_spamPatterns.size() + " patterns from page " + m_forbiddenWordsPage );
 
-                m_IPPatterns = parseWordList( sourceIPs,
-                        ( sourceIPs != null ) ? ( String )sourceIPs.getAttribute( LISTIPVAR ) : null );
+                m_IPPatterns = parseWordList( sourceIPs,  ( sourceIPs != null ) ? sourceIPs.getAttribute( LISTIPVAR ) : null );
                 log.info( "IP filter reloaded - recognizing " + m_IPPatterns.size() + " patterns from page " + m_forbiddenIPsPage );
 
                 if( att != null ) {
@@ -902,7 +900,7 @@ public class SpamFilter extends BasicPageFilter {
         //
         //  Don't forget to include the change note, too
         //
-        final String changeNote = ( String )page.getAttribute( WikiPage.CHANGENOTE );
+        final String changeNote = page.getAttribute( WikiPage.CHANGENOTE );
 
         if( changeNote != null ) {
             change.append( "\r\n" );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
index b23608a..8b2806b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
@@ -192,7 +192,7 @@ public class JSPWikiMarkupParser extends MarkupParser {
         //
         Properties props      = m_engine.getWikiProperties();
 
-        String cclinks = (String)m_context.getPage().getAttribute( PROP_CAMELCASELINKS );
+        String cclinks = m_context.getPage().getAttribute( PROP_CAMELCASELINKS );
 
         if( cclinks != null )
         {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java
index 642041c..f768f2a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java
@@ -197,8 +197,8 @@ public class RecentChangesPlugin extends AbstractReferralPlugin implements WikiP
 
                 // Change note
                 if( showChangenote ) {
-                    String changenote = ( String )pageref.getAttribute( WikiPage.CHANGENOTE );
-                    Element td_changenote = XhtmlUtil.element( XHTML.td, changenote );
+                    final String changenote = pageref.getAttribute( WikiPage.CHANGENOTE );
+                    final Element td_changenote = XhtmlUtil.element( XHTML.td, changenote );
                     td_changenote.setAttribute( XHTML.ATTR_class, "changenote" );
                     row.addContent( td_changenote );
                 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/providers/BasicAttachmentProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/providers/BasicAttachmentProvider.java
index ccaa8ed..5f6d67c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/providers/BasicAttachmentProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/providers/BasicAttachmentProvider.java
@@ -345,7 +345,7 @@ public class BasicAttachmentProvider
 
             props.setProperty( versionNumber+".author", author );
             
-            String changeNote = (String)att.getAttribute(WikiPage.CHANGENOTE);
+            String changeNote = att.getAttribute(WikiPage.CHANGENOTE);
             if( changeNote != null )
             {
                 props.setProperty( versionNumber+".changenote", changeNote );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/providers/FileSystemProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/providers/FileSystemProvider.java
index 65d3dc5..c8c7e3b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/providers/FileSystemProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/providers/FileSystemProvider.java
@@ -18,6 +18,10 @@
  */
 package org.apache.wiki.providers;
 
+import org.apache.log4j.Logger;
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.exceptions.ProviderException;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
@@ -26,10 +30,6 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.util.Properties;
 
-import org.apache.log4j.Logger;
-import org.apache.wiki.WikiPage;
-import org.apache.wiki.api.exceptions.ProviderException;
-
 /**
  *  Provides a simple directory based repository for Wiki pages.
  *  <P>
@@ -76,8 +76,8 @@ public class FileSystemProvider
         try
         {
             String author = page.getAuthor();
-            String changenote = (String)page.getAttribute( WikiPage.CHANGENOTE );
-            String viewcount = (String)page.getAttribute( WikiPage.VIEWCOUNT );
+            String changenote = page.getAttribute( WikiPage.CHANGENOTE );
+            String viewcount = page.getAttribute( WikiPage.VIEWCOUNT );
             
             if( author != null )
             {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/providers/VersioningFileProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/providers/VersioningFileProvider.java
index 2a36b0d..27dd7cb 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/providers/VersioningFileProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/providers/VersioningFileProvider.java
@@ -437,7 +437,7 @@ public class VersioningFileProvider extends AbstractFileProvider {
             page.setAuthor(newAuthor);
             props.setProperty( versionNumber + ".author", newAuthor );
 
-            String changeNote = (String) page.getAttribute(WikiPage.CHANGENOTE);
+            String changeNote = page.getAttribute(WikiPage.CHANGENOTE);
             if( changeNote != null ) {
                 props.setProperty( versionNumber + ".changenote", changeNote );
             }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
index f172e25..f568541 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
@@ -280,8 +280,9 @@ public class AtomAPIServlet extends HttpServlet
 
             log.debug( p.getName()+" = "+p.getAttribute(WeblogPlugin.ATTR_ISWEBLOG)) ;
 
-            if( !("true".equals(p.getAttribute(WeblogPlugin.ATTR_ISWEBLOG)) ) )
+            if( !("true".equals(p.getAttribute(WeblogPlugin.ATTR_ISWEBLOG)) ) ) {
                 continue;
+            }
 
             String encodedName = TextUtil.urlEncodeUTF8( p.getName() );
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/providers/FileSystemProviderTest.java b/jspwiki-main/src/test/java/org/apache/wiki/providers/FileSystemProviderTest.java
index bd36f8d..30ea671 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/providers/FileSystemProviderTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/providers/FileSystemProviderTest.java
@@ -18,11 +18,6 @@
  */
 
 package org.apache.wiki.providers;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.util.Properties;
-
 import org.apache.log4j.PropertyConfigurator;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiEngine;
@@ -34,6 +29,11 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.Properties;
+
 
 
 public class FileSystemProviderTest {
@@ -291,9 +291,9 @@ public class FileSystemProviderTest {
         m_provider.putPageText( testPage, "This page has custom properties" );
         Assertions.assertTrue( file.exists(), "No such file" );
         WikiPage pageRetrieved = m_provider.getPageInfo( pageName, -1 );
-        String value = (String)pageRetrieved.getAttribute("@test");
-        String value2 = (String)pageRetrieved.getAttribute("@test2");
-        String value3 = (String)pageRetrieved.getAttribute("test3");
+        String value = pageRetrieved.getAttribute("@test");
+        String value2 = pageRetrieved.getAttribute("@test2");
+        String value3 = pageRetrieved.getAttribute("test3");
         Assertions.assertNotNull(value);
         Assertions.assertNotNull(value2);
         Assertions.assertNull(value3);


[jspwiki] 18/32: make casting unnecessary when calling WikiEngine#getAttribute()

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 a64c5a54c783211e2839f024eedbb29aafffcaf6
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Jan 5 17:06:53 2020 +0100

    make casting unnecessary when calling WikiEngine#getAttribute()
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  5 ++---
 .../apache/wiki/parser/JSPWikiMarkupParser.java    | 15 +++++----------
 .../java/org/apache/wiki/parser/MarkupParser.java  | 22 +++++++++++-----------
 3 files changed, 18 insertions(+), 24 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 4a82ada..6333552 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -1832,9 +1832,8 @@ public class WikiEngine  {
      *  @param key the attribute name
      *  @return the value
      */
-    public Object getAttribute( final String key )
-    {
-        return m_attributes.get( key );
+    public <T> T getAttribute( final String key ) {
+        return (T)m_attributes.get( key );
     }
 
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
index 9e548b5..b23608a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
@@ -177,16 +177,11 @@ public class JSPWikiMarkupParser extends MarkupParser {
     {
         initInlineImagePatterns();
 
-        m_camelCasePattern = (Pattern) m_engine.getAttribute( CAMELCASE_PATTERN );
-        if( m_camelCasePattern == null )
-        {
-            try
-            {
-                m_camelCasePattern = m_compiler.compile( WIKIWORD_REGEX,
-                                                         Perl5Compiler.DEFAULT_MASK|Perl5Compiler.READ_ONLY_MASK );
-            }
-            catch( MalformedPatternException e )
-            {
+        m_camelCasePattern = m_engine.getAttribute( CAMELCASE_PATTERN );
+        if( m_camelCasePattern == null ) {
+            try {
+                m_camelCasePattern = m_compiler.compile( WIKIWORD_REGEX,Perl5Compiler.DEFAULT_MASK|Perl5Compiler.READ_ONLY_MASK );
+            } catch( final MalformedPatternException e ) {
                 log.fatal("Internal error: Someone put in a faulty pattern.",e);
                 throw new InternalWikiException("Faulty camelcasepattern in TranslatorReader", e);
             }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/MarkupParser.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/MarkupParser.java
index 56825a6..96a0b56 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/MarkupParser.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/MarkupParser.java
@@ -18,16 +18,6 @@
 */
 package org.apache.wiki.parser;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.PushbackReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
 import org.apache.log4j.Logger;
 import org.apache.oro.text.GlobCompiler;
 import org.apache.oro.text.regex.MalformedPatternException;
@@ -38,6 +28,16 @@ import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.jdom2.Element;
 
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.PushbackReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
 /**
  *   Provides an abstract class for the parser instances.
  *
@@ -281,7 +281,7 @@ public abstract class MarkupParser
         //
         //  We cache compiled patterns in the engine, since their creation is really expensive
         //
-        List< Pattern > compiledpatterns = ( List< Pattern > )m_engine.getAttribute( INLINE_IMAGE_PATTERNS );
+        List< Pattern > compiledpatterns = m_engine.getAttribute( INLINE_IMAGE_PATTERNS );
 
         if( compiledpatterns == null ) {
             compiledpatterns = new ArrayList< >( 20 );


[jspwiki] 26/32: revert change on previous commits: PageManager and WorkflowManager must extend WikiEventListener

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 d65ebff56544e0aa5eb887b3e11238052724aba3
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 8 00:40:23 2020 +0100

    revert change on previous commits: PageManager and WorkflowManager must extend WikiEventListener
---
 .../src/main/java/org/apache/wiki/pages/DefaultPageManager.java        | 3 +--
 jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java      | 3 ++-
 .../src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java | 3 +--
 .../src/main/java/org/apache/wiki/workflow/WorkflowManager.java        | 3 ++-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index 2090371..1a7e4f7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -35,7 +35,6 @@ import org.apache.wiki.auth.acl.AclEntry;
 import org.apache.wiki.auth.acl.AclEntryImpl;
 import org.apache.wiki.auth.user.UserProfile;
 import org.apache.wiki.event.WikiEvent;
-import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.event.WikiSecurityEvent;
@@ -76,7 +75,7 @@ import java.util.concurrent.ConcurrentHashMap;
 // FIXME: This class currently only functions just as an extra layer over providers,
 //        complicating things.  We need to move more provider-specific functionality
 //        from WikiEngine (which is too big now) into this class.
-public class DefaultPageManager extends ModuleManager implements PageManager, WikiEventListener {
+public class DefaultPageManager extends ModuleManager implements PageManager {
 
     private static final Logger LOG = Logger.getLogger( DefaultPageManager.class );
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index 0c48a48..9173df8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -20,6 +20,7 @@ package org.apache.wiki.pages;
 
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.ProviderException;
+import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.providers.WikiPageProvider;
 
 import java.util.Collection;
@@ -27,7 +28,7 @@ import java.util.List;
 import java.util.Set;
 
 
-public interface PageManager {
+public interface PageManager extends WikiEventListener {
 
     /** The property value for setting the current page provider.  Value is {@value}. */
     String PROP_PAGEPROVIDER = "jspwiki.pageProvider";
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
index bec5649..fac5361 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
@@ -23,7 +23,6 @@ import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.acl.UnresolvedPrincipal;
 import org.apache.wiki.event.WikiEvent;
-import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WorkflowEvent;
 
 import java.security.Principal;
@@ -42,7 +41,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
  * users or groups expected to approve particular Workflows.
  * </p>
  */
-public class DefaultWorkflowManager implements WorkflowManager, WikiEventListener {
+public class DefaultWorkflowManager implements WorkflowManager {
 
     private final DecisionQueue m_queue = new DecisionQueue();
     private final Set<Workflow> m_workflows;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
index 8fe46cb..e82e02c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
@@ -21,6 +21,7 @@ package org.apache.wiki.workflow;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.exceptions.WikiException;
+import org.apache.wiki.event.WikiEventListener;
 
 import java.security.Principal;
 import java.util.List;
@@ -34,7 +35,7 @@ import java.util.Set;
  * particular Workflows.
  * </p>
  */
-public interface WorkflowManager {
+public interface WorkflowManager extends WikiEventListener {
 
     /** The workflow attribute which stores the wikiContext. */
     String WF_WP_SAVE_ATTR_PRESAVE_WIKI_CONTEXT = "wikiContext";


[jspwiki] 01/32: JSPWIKI-120: move deletePage(..) and deleteVersion(..) methods from WikiEngine to PageManager

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 1ec1151a07212fba3d6193c9c57e2bfe530eb2c3
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 20:41:27 2020 +0100

    JSPWIKI-120: move deletePage(..) and deleteVersion(..) methods from WikiEngine to PageManager
    
    also removed deletePage from TestEngine - was there to try to debug some nasty NPEs on tests but didn't end up being useful (NPEs probably due to objects being garbage collected on some ci nodes)
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 46 ---------------------
 .../org/apache/wiki/pages/DefaultPageManager.java  | 47 +++++++++++++++++++---
 .../java/org/apache/wiki/pages/PageManager.java    | 28 +++++++------
 .../src/test/java/org/apache/wiki/TestEngine.java  |  9 -----
 .../test/java/org/apache/wiki/WikiEngineTest.java  | 14 +++----
 .../wiki/attachment/AttachmentManagerTest.java     | 21 +++++-----
 .../apache/wiki/auth/AuthorizationManagerTest.java | 10 ++---
 .../java/org/apache/wiki/auth/UserManagerTest.java |  4 +-
 .../wiki/auth/acl/DefaultAclManagerTest.java       |  4 +-
 .../wiki/plugin/DefaultPluginManagerTest.java      | 21 ++++------
 .../java/org/apache/wiki/plugin/GroupsTest.java    | 21 ++--------
 .../java/org/apache/wiki/plugin/IfPluginTest.java  | 23 +++--------
 .../apache/wiki/plugin/TableOfContentsTest.java    | 17 ++------
 .../org/apache/wiki/plugin/WeblogPluginTest.java   | 13 +-----
 .../wiki/references/ReferenceManagerTest.java      |  2 +-
 .../apache/wiki/render/RenderingManagerTest.java   | 19 ++-------
 .../org/apache/wiki/ui/CommandResolverTest.java    |  4 +-
 .../apache/wiki/workflow/ApprovalWorkflowTest.java | 17 ++++----
 18 files changed, 119 insertions(+), 201 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 e8a322c..19a2eaa 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -1835,52 +1835,6 @@ public class WikiEngine  {
     }
 
     /**
-     *  Deletes a page or an attachment completely, including all versions.  If the page
-     *  does not exist, does nothing.
-     *
-     * @param pageName The name of the page.
-     * @throws ProviderException If something goes wrong.
-     */
-    public void deletePage( final String pageName ) throws ProviderException {
-        final WikiPage p = getPage( pageName );
-        if( p != null ) {
-            if( p instanceof Attachment ) {
-                m_attachmentManager.deleteAttachment( ( Attachment )p );
-            } else {
-                final Collection< String > refTo = m_referenceManager.findRefersTo( pageName );
-                // May return null, if the page does not exist or has not been indexed yet.
-
-                if( m_attachmentManager.hasAttachments( p ) ) {
-                    final List< Attachment > attachments = m_attachmentManager.listAttachments( p );
-                    for( final Attachment attachment : attachments ) {
-                        if( refTo != null ) {
-                            refTo.remove( attachment.getName() );
-                        }
-
-                        m_attachmentManager.deleteAttachment( attachment );
-                    }
-                }
-                m_pageManager.deletePage( p );
-                firePageEvent( WikiPageEvent.PAGE_DELETED, pageName );
-            }
-        }
-    }
-
-    /**
-     *  Deletes a specific version of a page or an attachment.
-     *
-     *  @param page The page object.
-     *  @throws ProviderException If something goes wrong.
-     */
-    public void deleteVersion( final WikiPage page ) throws ProviderException {
-        if( page instanceof Attachment ) {
-            m_attachmentManager.deleteVersion( (Attachment) page );
-        } else {
-            m_pageManager.deleteVersion( page );
-        }
-    }
-
-    /**
      *  Returns the URL of the global RSS file.  May be null, if the
      *  RSS file generation is not operational.
      *  @since 1.7.10
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index c1d9c16..e4f97b9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -27,6 +27,7 @@ import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
+import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.auth.WikiPrincipal;
 import org.apache.wiki.auth.WikiSecurityException;
 import org.apache.wiki.auth.acl.Acl;
@@ -363,18 +364,52 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         return m_provider.pageExists(pageName, version);
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#deleteVersion(org.apache.wiki.WikiPage)
      */
     @Override
-    public void deleteVersion(WikiPage page) throws ProviderException {
-        m_provider.deleteVersion(page.getName(), page.getVersion());
+    public void deleteVersion( final WikiPage page ) throws ProviderException {
+        if( page instanceof Attachment ) {
+            m_engine.getAttachmentManager().deleteVersion( (Attachment) page );
+        } else {
+            m_provider.deleteVersion(page.getName(), page.getVersion());
+            // FIXME: If this was the latest, reindex Lucene
+            // FIXME: Update RefMgr
+        }
+    }
 
-        // FIXME: If this was the latest, reindex Lucene
-        // FIXME: Update RefMgr
+    /**
+     * {@inheritDoc}
+     * @see org.apache.wiki.pages.PageManager#deletePage(java.lang.String)
+     */
+    public void deletePage( final String pageName ) throws ProviderException {
+        final WikiPage p = m_engine.getPage( pageName );
+        if( p != null ) {
+            if( p instanceof Attachment ) {
+                m_engine.getAttachmentManager().deleteAttachment( ( Attachment )p );
+            } else {
+                final Collection< String > refTo = m_engine.getReferenceManager().findRefersTo( pageName );
+                // May return null, if the page does not exist or has not been indexed yet.
+
+                if( m_engine.getAttachmentManager().hasAttachments( p ) ) {
+                    final List< Attachment > attachments = m_engine.getAttachmentManager().listAttachments( p );
+                    for( final Attachment attachment : attachments ) {
+                        if( refTo != null ) {
+                            refTo.remove( attachment.getName() );
+                        }
+
+                        m_engine.getAttachmentManager().deleteAttachment( attachment );
+                    }
+                }
+                deletePage( p );
+                fireEvent( WikiPageEvent.PAGE_DELETED, pageName );
+            }
+        }
     }
 
-    /* (non-Javadoc)
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#deletePage(org.apache.wiki.WikiPage)
      */
     @Override
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index 95cc3a9..7337c8d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -18,9 +18,6 @@
  */
 package org.apache.wiki.pages;
 
-import java.util.Collection;
-import java.util.List;
-
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.ProviderException;
@@ -28,6 +25,9 @@ import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.providers.WikiPageProvider;
 
+import java.util.Collection;
+import java.util.List;
+
 
 public interface PageManager extends WikiEventListener {
 
@@ -47,7 +47,7 @@ public interface PageManager extends WikiEventListener {
 
     /**
      * Returns all pages in some random order.  If you need just the page names,
-     * please see {@link org.apache.wiki.ReferenceManager#findCreated() ReferenceManager#findCreated()}, which is probably a lot
+     * please see {@link org.apache.wiki.references.ReferenceManager#findCreated() ReferenceManager#findCreated()}, which is probably a lot
      * faster.  This method may cause repository access.
      *
      * @return A Collection of WikiPage objects.
@@ -85,8 +85,7 @@ public interface PageManager extends WikiEventListener {
     void putPageText(WikiPage page, String content) throws ProviderException;
 
     /**
-     * Locks page for editing.  Note, however, that the PageManager
-     * will in no way prevent you from actually editing this page;
+     * Locks page for editing.  Note, however, that the PageManager will in no way prevent you from actually editing this page;
      * the lock is just for information.
      *
      * @param page WikiPage to lock
@@ -103,8 +102,7 @@ public interface PageManager extends WikiEventListener {
     void unlockPage(PageLock lock);
 
     /**
-     * Returns the current lock owner of a page.  If the page is not
-     * locked, will return null.
+     * Returns the current lock owner of a page.  If the page is not locked, will return null.
      *
      * @param page The page to check the lock for
      * @return Current lock, or null, if there is no lock
@@ -115,8 +113,7 @@ public interface PageManager extends WikiEventListener {
      * Returns a list of currently applicable locks.  Note that by the time you get the list,
      * the locks may have already expired, so use this only for informational purposes.
      *
-     * @return List of PageLock objects, detailing the locks.  If no locks exist, returns
-     *         an empty list.
+     * @return List of PageLock objects, detailing the locks.  If no locks exist, returns an empty list.
      * @since 2.0.22.
      */
     List<PageLock> getActiveLocks();
@@ -127,8 +124,7 @@ public interface PageManager extends WikiEventListener {
      * @param pageName The name of the page
      * @param version  A version number
      * @return A WikiPage object, or null, if the page does not exist
-     * @throws ProviderException If there is something wrong with the page
-     *                           name or the repository
+     * @throws ProviderException If there is something wrong with the page name or the repository
      */
     WikiPage getPageInfo(String pageName, int version) throws ProviderException;
 
@@ -187,6 +183,14 @@ public interface PageManager extends WikiEventListener {
     void deleteVersion(WikiPage page) throws ProviderException;
 
     /**
+     *  Deletes a page or an attachment completely, including all versions.  If the page does not exist, does nothing.
+     *
+     * @param pageName The name of the page.
+     * @throws ProviderException If something goes wrong.
+     */
+    void deletePage( final String pageName ) throws ProviderException;
+
+    /**
      * Deletes an entire page, all versions, all traces.
      *
      * @param page The WikiPage to delete
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 9eef99e..6115fea 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -282,15 +282,6 @@ public class TestEngine extends WikiEngine
         return pagename;
     }
 
-    public void deletePage( final String pageName ) throws ProviderException {
-        try {
-            super.deletePage( pageName );
-        } catch( final ProviderException | RuntimeException e ) {
-            log.error( e.getMessage(), e );
-            throw e;
-        }
-    }
-
     /**
      *  Removes a page, but not any auxiliary information.  Works only
      *  with FileSystemProvider.
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 6bbddce..4cf1930 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -568,7 +568,7 @@ public class WikiEngineTest
 
         WikiPage page = m_engine.getPage( NAME1, WikiProvider.LATEST_VERSION );
 
-        m_engine.deletePage( page.getName() );
+        m_engine.getPageManager().deletePage( page.getName() );
 
         Assertions.assertFalse( saved.exists(), "Page has not been removed!" );
     }
@@ -596,7 +596,7 @@ public class WikiEngineTest
 
         WikiPage page = m_engine.getPage( NAME1, WikiProvider.LATEST_VERSION );
 
-        m_engine.deletePage( page.getName() );
+        m_engine.getPageManager().deletePage( page.getName() );
 
         Assertions.assertFalse( saved.exists(), "Page has not been removed!" );
         Assertions.assertFalse( attfile.exists(), "Attachment has not been removed" );
@@ -628,9 +628,9 @@ public class WikiEngineTest
 
         att = m_engine.getAttachmentManager().getAttachmentInfo(NAME1+"/TestAtt.txt");
 
-        m_engine.deletePage(att.getName());
+        m_engine.getPageManager().deletePage(att.getName());
 
-        m_engine.deletePage( NAME1 );
+        m_engine.getPageManager().deletePage( NAME1 );
 
         Assertions.assertNull( m_engine.getPage(NAME1), "Page not removed" );
         Assertions.assertNull( m_engine.getPage(NAME1+"/TestAtt.txt"), "Att not removed" );
@@ -653,7 +653,7 @@ public class WikiEngineTest
 
         WikiPage page = engine.getPage( NAME1, 3 );
 
-        engine.deleteVersion( page );
+        engine.getPageManager().deleteVersion( page );
 
         Assertions.assertNull( engine.getPage( NAME1, 3 ), "got page" );
 
@@ -675,7 +675,7 @@ public class WikiEngineTest
 
         WikiPage page = engine.getPage( NAME1, 1 );
 
-        engine.deleteVersion( page );
+        engine.getPageManager().deleteVersion( page );
 
         Assertions.assertNull( engine.getPage( NAME1, 1 ), "got page" );
 
@@ -714,7 +714,7 @@ public class WikiEngineTest
         // FIXME: The following must run as well
         Assertions.assertEquals( "notbar", v2.getAttribute("foo"), "V2" );
 
-        engine.deletePage( NAME1 );
+        engine.getPageManager().deletePage( NAME1 );
     }
 
     @Test
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
index 192cb35..8128b47 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
@@ -12,15 +12,7 @@
  * limitations under the License.
  */
 package org.apache.wiki.attachment;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.List;
-import java.util.Properties;
-
+import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
@@ -31,7 +23,14 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import net.sf.ehcache.CacheManager;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Properties;
 
 public class AttachmentManagerTest
 {
@@ -361,7 +360,7 @@ public class AttachmentManagerTest
         }
         finally
         {
-            m_engine.deletePage("TestPage");
+            m_engine.getPageManager().deletePage("TestPage");
         }
     }
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
index 87a721e..674c821 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
@@ -114,7 +114,7 @@ public class AuthorizationManagerTest
         // Delete the test page
         try
         {
-            m_engine.deletePage( "TestDefaultPage" );
+            m_engine.getPageManager().deletePage( "TestDefaultPage" );
         }
         catch( ProviderException e )
         {
@@ -294,7 +294,7 @@ public class AuthorizationManagerTest
 
         // Delete test page & attachment
         m_engine.getAttachmentManager().deleteAttachment( att );
-        m_engine.deletePage( "Test" );
+        m_engine.getPageManager().deletePage( "Test" );
     }
 
     @Test
@@ -326,7 +326,7 @@ public class AuthorizationManagerTest
 
         // Delete test page & attachment
         m_engine.getAttachmentManager().deleteAttachment( att );
-        m_engine.deletePage( "Test" );
+        m_engine.getPageManager().deletePage( "Test" );
     }
 
     @Test
@@ -468,7 +468,7 @@ public class AuthorizationManagerTest
         // Cleanup
         try
         {
-            m_engine.deletePage( "Test" );
+            m_engine.getPageManager().deletePage( "Test" );
         }
         catch( ProviderException e )
         {
@@ -590,7 +590,7 @@ public class AuthorizationManagerTest
         // Cleanup
         try
         {
-            m_engine.deletePage( "Test" );
+            m_engine.getPageManager().deletePage( "Test" );
         }
         catch( ProviderException e )
         {
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
index 8212bfe..e9d770d 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
@@ -194,7 +194,7 @@ public class UserManagerTest {
         Assertions.assertEquals( expectedText, actualText );
 
         // Remove our test page
-        m_engine.deletePage( pageName );
+        m_engine.getPageManager().deletePage( pageName );
 
         // Setup Step 6: re-create the group with our old test user names in it
         group = groupManager.parseGroup( m_groupName, "Alice \n Bob \n Charlie \n " + oldLogin + "\n" + oldName, true );
@@ -259,7 +259,7 @@ public class UserManagerTest {
         groupManager.removeGroup( group.getName() );
         Assertions.assertEquals( oldGroupCount, groupManager.getRoles().length );
 
-        m_engine.deletePage( pageName );
+        m_engine.getPageManager().deletePage( pageName );
         Assertions.assertEquals( oldPageCount, pageManager.getTotalPageCount() );
     }
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java
index e56a91e..3326cfc 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java
@@ -55,8 +55,8 @@ public class DefaultAclManagerTest
     {
         try
         {
-            m_engine.deletePage( "TestDefaultPage" );
-            m_engine.deletePage( "TestAclPage" );
+            m_engine.getPageManager().deletePage( "TestDefaultPage" );
+            m_engine.getPageManager().deletePage( "TestAclPage" );
         }
         catch ( ProviderException e )
         {
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
index b84a812..9a0a14e 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
@@ -18,7 +18,6 @@
  */
 
 package org.apache.wiki.plugin;
-import java.util.Properties;
 
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
@@ -30,31 +29,25 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-public class DefaultPluginManagerTest
-{
-    public static final String NAME1 = "Test1";
+import java.util.Properties;
+
+public class DefaultPluginManagerTest {
 
     Properties props = TestEngine.getTestProperties();
-
-    WikiEngine engine;
+    WikiEngine engine = TestEngine.build();
+    DefaultPluginManager manager = new DefaultPluginManager( engine, props );
 
     WikiContext context;
 
-    DefaultPluginManager manager;
-
     @BeforeEach
-    public void setUp()
-        throws Exception
-    {
-        engine = new TestEngine(props);
+    public void setUp() throws Exception {
         context = new WikiContext( engine, new WikiPage(engine, "Testpage") );
-        manager = new DefaultPluginManager( engine, props );
     }
 
     @AfterEach
     public void tearDown() throws ProviderException
     {
-        engine.deletePage("Testpage");
+        engine.getPageManager().deletePage("Testpage");
     }
 
     @Test
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/GroupsTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/GroupsTest.java
index c682c26..529af2c 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/GroupsTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/GroupsTest.java
@@ -19,31 +19,18 @@
 
 package org.apache.wiki.plugin;
 
-import java.util.Properties;
-
 import org.apache.wiki.TestEngine;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 
-public class GroupsTest
-{
-    Properties props = TestEngine.getTestProperties();
-    TestEngine testEngine;
-
-    @BeforeEach
-    public void setUp()
-        throws Exception
-    {
-        testEngine = new TestEngine(props);
-    }
+public class GroupsTest {
+    TestEngine testEngine = TestEngine.build();
 
     @AfterEach
-    public void tearDown() throws Exception
-    {
-        testEngine.deletePage( "Test" );
+    public void tearDown() throws Exception {
+        testEngine.getPageManager().deletePage( "Test" );
     }
 
     @Test
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
index b8b30cb..4ac3c19 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
@@ -17,8 +17,7 @@
     under the License.
  */
 package org.apache.wiki.plugin;
-import java.util.Properties;
-
+import net.sourceforge.stripes.mock.MockHttpServletRequest;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
@@ -28,27 +27,15 @@ import org.apache.wiki.auth.Users;
 import org.apache.wiki.providers.WikiPageProvider;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import net.sourceforge.stripes.mock.MockHttpServletRequest;
-
-public class IfPluginTest
-{
+public class IfPluginTest {
 
-    TestEngine testEngine;
-
-    @BeforeEach
-    public void setUp() throws Exception
-    {
-        Properties props = TestEngine.getTestProperties();
-        testEngine = new TestEngine( props );
-    }
+    TestEngine testEngine = TestEngine.build();
 
     @AfterEach
-    public void tearDown() throws Exception
-    {
-        testEngine.deletePage( "Test" );
+    public void tearDown() throws Exception {
+        testEngine.getPageManager().deletePage( "Test" );
     }
 
     /**
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/TableOfContentsTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/TableOfContentsTest.java
index c0b1ada..47a0784 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/TableOfContentsTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/TableOfContentsTest.java
@@ -26,30 +26,19 @@ import org.apache.wiki.TestEngine;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import java.util.Properties;
-
 /**
  *
  *  @since
  */
 public class TableOfContentsTest
 {
-    TestEngine testEngine;
-
-    @BeforeEach
-    public void setUp() throws Exception
-    {
-        Properties props = TestEngine.getTestProperties();
-        testEngine = new TestEngine( props );
-    }
+    TestEngine testEngine = TestEngine.build();
 
     @AfterEach
-    public void tearDown() throws Exception
-    {
-        testEngine.deletePage( "Test" );
+    public void tearDown() throws Exception {
+        testEngine.getPageManager().deletePage( "Test" );
     }
 
     @Test
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/WeblogPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/WeblogPluginTest.java
index 0bf7d9f..3ae3b30 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/WeblogPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/WeblogPluginTest.java
@@ -4,25 +4,16 @@ import org.apache.wiki.TestEngine;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import java.util.Properties;
-
 
 public class WeblogPluginTest {
 
-    TestEngine testEngine;
-
-    @BeforeEach
-    public void setUp() throws Exception {
-        final Properties props = TestEngine.getTestProperties();
-        testEngine = new TestEngine( props );
-    }
+    TestEngine testEngine = TestEngine.build();
 
     @AfterEach
     public void tearDown() throws Exception {
-        testEngine.deletePage( "Test" );
+        testEngine.getPageManager().deletePage( "Test" );
     }
 
     @Test
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/references/ReferenceManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/references/ReferenceManagerTest.java
index ff58d40..76122de 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/references/ReferenceManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/references/ReferenceManagerTest.java
@@ -82,7 +82,7 @@ public class ReferenceManagerTest  {
         Assertions.assertNotNull( c, "referrers expected" );
         Assertions.assertTrue( c.size() == 1 && c.contains("Foobar") );
 
-        engine.deletePage( "Foobar" );
+        engine.getPageManager().deletePage( "Foobar" );
         c = mgr.findReferrers("Foobar2");
         Assertions.assertNull( c );
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
index 6d41332..cf5aada 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
@@ -27,28 +27,17 @@ import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.parser.WikiDocument;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import java.util.Properties;
-
 public class RenderingManagerTest {
 
-    RenderingManager m_manager;
-    TestEngine       m_engine;
-
-    @BeforeEach
-    public void setUp() throws Exception {
-        CacheManager.getInstance().removeAllCaches();
-        Properties props = TestEngine.getTestProperties();
-        m_engine = new TestEngine( props );
-
-        m_manager = m_engine.getRenderingManager();
-    }
+    TestEngine       m_engine = TestEngine.build();
+    RenderingManager m_manager = m_engine.getRenderingManager();
 
     @AfterEach
     public void tearDown() throws Exception {
-        m_engine.deletePage( "TestPage" );
+        m_engine.getPageManager().deletePage( "TestPage" );
+        CacheManager.getInstance().removeAllCaches();
     }
 
     /**
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java
index 7212058..a557d5c 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java
@@ -52,8 +52,8 @@ public class CommandResolverTest {
 
     @AfterEach
     public void tearDown() throws Exception {
-        m_engine.deletePage( "SinglePage" );
-        m_engine.deletePage( "PluralPage" );
+        m_engine.getPageManager().deletePage( "SinglePage" );
+        m_engine.getPageManager().deletePage( "PluralPage" );
     }
 
     @Test
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
index 135ff01..5e03505 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
@@ -18,11 +18,6 @@
  */
 package org.apache.wiki.workflow;
 
-import java.security.Principal;
-import java.util.Collection;
-import java.util.List;
-import java.util.Properties;
-
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.engine.FilterManager;
@@ -35,14 +30,18 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-public class ApprovalWorkflowTest
-{
+import java.security.Principal;
+import java.util.Collection;
+import java.util.List;
+import java.util.Properties;
+
+public class ApprovalWorkflowTest {
+
     WorkflowBuilder m_builder;
     TestEngine m_engine;
     WorkflowManager m_wm;
     DecisionQueue m_dq;
 
-
     @BeforeEach
     public void setUp() throws Exception
     {
@@ -209,7 +208,7 @@ public class ApprovalWorkflowTest
         Assertions.assertEquals(0, decisions.size());
 
         // Delete the page we created
-        m_engine.deletePage( pageName );
+        m_engine.getPageManager().deletePage( pageName );
     }
 
     @Test


[jspwiki] 17/32: JSPWIKI-120: move getVersionHistory from WikiEngine into same method in PageManager

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 806fc47dcd20c4a6b30c4e75d52fc8515648a098
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Jan 5 17:04:32 2020 +0100

    JSPWIKI-120: move getVersionHistory from WikiEngine into same method in PageManager
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 163 +++++++--------------
 .../org/apache/wiki/pages/DefaultPageManager.java  |  18 ++-
 .../java/org/apache/wiki/pages/PageManager.java    |   8 +-
 .../org/apache/wiki/tags/HistoryIteratorTag.java   |  81 ++++------
 .../wiki/providers/VersioningFileProviderTest.java |   9 +-
 jspwiki-war/src/main/webapp/rss.jsp                |   7 +-
 .../src/main/webapp/templates/210/DiffTab.jsp      |   2 +-
 .../src/main/webapp/templates/default/DiffTab.jsp  |   2 +-
 8 files changed, 111 insertions(+), 179 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 8e60b4c..4a82ada 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -87,7 +87,6 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
 import java.util.Enumeration;
-import java.util.List;
 import java.util.Locale;
 import java.util.Map;
 import java.util.Properties;
@@ -1107,29 +1106,23 @@ public class WikiEngine  {
     }
 
     /**
-     *  Turns a WikiName into something that can be
-     *  called through using an URL.
+     *  Turns a WikiName into something that can be called through using an URL.
      *
      *  @since 1.4.1
      *  @param pagename A name.  Can be actually any string.
      *  @return A properly encoded name.
      *  @see #decodeName(String)
      */
-    public String encodeName( String pagename )
-    {
-        try
-        {
+    public String encodeName( final String pagename ) {
+        try {
             return URLEncoder.encode( pagename, m_useUTF8 ? "UTF-8" : "ISO-8859-1" );
-        }
-        catch( UnsupportedEncodingException e )
-        {
+        } catch( final UnsupportedEncodingException e ) {
             throw new InternalWikiException( "ISO-8859-1 not a supported encoding!?!  Your platform is borked." , e);
         }
     }
 
     /**
-     *  Decodes a URL-encoded request back to regular life.  This properly heeds
-     *  the encoding as defined in the settings file.
+     *  Decodes a URL-encoded request back to regular life.  This properly heeds the encoding as defined in the settings file.
      *
      *  @param pagerequest The URL-encoded string to decode
      *  @return A decoded string.
@@ -1138,14 +1131,13 @@ public class WikiEngine  {
     public String decodeName( final String pagerequest ) {
         try {
             return URLDecoder.decode( pagerequest, m_useUTF8 ? "UTF-8" : "ISO-8859-1" );
-        } catch( UnsupportedEncodingException e ) {
+        } catch( final UnsupportedEncodingException e ) {
             throw new InternalWikiException("ISO-8859-1 not a supported encoding!?!  Your platform is borked.", e);
         }
     }
 
     /**
-     *  Returns the IANA name of the character set encoding we're
-     *  supposed to be using right now.
+     *  Returns the IANA name of the character set encoding we're supposed to be using right now.
      *
      *  @since 1.5.3
      *  @return The content encoding (either UTF-8 or ISO-8859-1).
@@ -1158,9 +1150,8 @@ 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>.
+     * 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()
@@ -1169,27 +1160,22 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the un-HTMLized text of the latest version of a page.
-     *  This method also replaces the &lt; and &amp; -characters with
-     *  their respective HTML entities, thus making it suitable
-     *  for inclusion on an HTML page.  If you want to have the
-     *  page text without any conversions, use getPureText().
+     *  Returns the un-HTMLized text of the latest version of a page. This method also replaces the &lt; and &amp; -characters with
+     *  their respective HTML entities, thus making it suitable for inclusion on an HTML page.  If you want to have the page text
+     *  without any conversions, use getPureText().
      *
      *  @param page WikiName of the page to fetch.
      *  @return WikiText.
      */
-    public String getText( String page )
+    public String getText( final String page )
     {
         return getText( page, WikiPageProvider.LATEST_VERSION );
     }
 
     /**
-     *  Returns the un-HTMLized text of the given version of a page.
-     *  This method also replaces the &lt; and &amp; -characters with
-     *  their respective HTML entities, thus making it suitable
-     *  for inclusion on an HTML page.  If you want to have the
-     *  page text without any conversions, use getPureText().
-     *
+     *  Returns the un-HTMLized text of the given version of a page. This method also replaces the &lt; and &amp; -characters with
+     *  their respective HTML entities, thus making it suitable for inclusion on an HTML page.  If you want to have the page text
+     *  without any conversions, use getPureText().
      *
      * @param page WikiName of the page to fetch
      * @param version  Version of the page to fetch
@@ -1210,14 +1196,10 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the un-HTMLized text of the given version of a page in
-     *  the given context.  USE THIS METHOD if you don't know what
-     *  doing.
+     *  Returns the un-HTMLized text of the given version of a page in the given context.  USE THIS METHOD if you don't know what doing.
      *  <p>
-     *  This method also replaces the &lt; and &amp; -characters with
-     *  their respective HTML entities, thus making it suitable
-     *  for inclusion on an HTML page.  If you want to have the
-     *  page text without any conversions, use getPureText().
+     *  This method also replaces the &lt; and &amp; -characters with their respective HTML entities, thus making it suitable
+     *  for inclusion on an HTML page.  If you want to have the page text without any conversions, use getPureText().
      *
      *  @since 1.9.15.
      *  @param context The WikiContext
@@ -1231,8 +1213,7 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the converted HTML of the page using a different
-     *  context than the default context.
+     *  Returns the converted HTML of the page using a different context than the default context.
      *
      *  @param  context A WikiContext in which you wish to render this page in.
      *  @param  page WikiPage reference.
@@ -1255,8 +1236,7 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the converted HTML of the page's specific version.
-     *  The version must be a positive integer, otherwise the current
+     *  Returns the converted HTML of the page's specific version. The version must be a positive integer, otherwise the current
      *  version is returned.
      *
      *  @param pagename WikiName of the page to convert.
@@ -1439,17 +1419,17 @@ public class WikiEngine  {
      *  Individual PageFilters, such as the {@link org.apache.wiki.filters.SpamFilter} may also throw a
      *  {@link org.apache.wiki.api.exceptions.RedirectException}.
      */
-    public void saveText( WikiContext context, String text ) throws WikiException {
+    public void saveText( final WikiContext context, final String text ) throws WikiException {
         // Check if page data actually changed; bail if not
-        WikiPage page = context.getPage();
-        String oldText = getPageManager().getPureText( page );
-        String proposedText = TextUtil.normalizePostData( text );
+        final WikiPage page = context.getPage();
+        final String oldText = getPageManager().getPureText( page );
+        final String proposedText = TextUtil.normalizePostData( text );
         if ( oldText != null && oldText.equals( proposedText ) ) {
             return;
         }
 
         // Check if creation of empty pages is allowed; bail if not
-        boolean allowEmpty = TextUtil.getBooleanProperty( m_properties, PROP_ALLOW_CREATION_OF_EMPTY_PAGES, false );
+        final boolean allowEmpty = TextUtil.getBooleanProperty( m_properties, PROP_ALLOW_CREATION_OF_EMPTY_PAGES, false );
         if ( !allowEmpty && !pageExists( page ) && text.trim().equals( "" ) ) {
             return;
         }
@@ -1457,26 +1437,26 @@ public class WikiEngine  {
         // Create approval workflow for page save; add the diffed, proposed and old text versions as
         // Facts for the approver (if approval is required). If submitter is authenticated, any reject
         // messages will appear in his/her workflow inbox.
-        WorkflowBuilder builder = WorkflowBuilder.getBuilder( this );
-        Principal submitter = context.getCurrentUser();
-        Step prepTask = m_tasksManager.buildPreSaveWikiPageTask( context, proposedText );
-        Step completionTask = m_tasksManager.buildSaveWikiPageTask();
-        String diffText = m_differenceManager.makeDiff( context, oldText, proposedText );
-        boolean isAuthenticated = context.getWikiSession().isAuthenticated();
-        Fact[] facts = new Fact[ 5 ];
+        final WorkflowBuilder builder = WorkflowBuilder.getBuilder( this );
+        final Principal submitter = context.getCurrentUser();
+        final Step prepTask = m_tasksManager.buildPreSaveWikiPageTask( context, proposedText );
+        final Step completionTask = m_tasksManager.buildSaveWikiPageTask();
+        final String diffText = m_differenceManager.makeDiff( context, oldText, proposedText );
+        final boolean isAuthenticated = context.getWikiSession().isAuthenticated();
+        final Fact[] facts = new Fact[ 5 ];
         facts[ 0 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_PAGE_NAME, page.getName() );
         facts[ 1 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_DIFF_TEXT, diffText );
         facts[ 2 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_PROPOSED_TEXT, proposedText );
         facts[ 3 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_CURRENT_TEXT, oldText);
-        facts[ 4 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_IS_AUTHENTICATED, Boolean.valueOf( isAuthenticated ) );
-        String rejectKey = isAuthenticated ? WorkflowManager.WF_WP_SAVE_REJECT_MESSAGE_KEY : null;
-        Workflow workflow = builder.buildApprovalWorkflow( submitter,
-                                                           WorkflowManager.WF_WP_SAVE_APPROVER,
-                                                           prepTask,
-                                                           WorkflowManager.WF_WP_SAVE_DECISION_MESSAGE_KEY,
-                                                           facts,
-                                                           completionTask,
-                                                           rejectKey );
+        facts[ 4 ] = new Fact( WorkflowManager.WF_WP_SAVE_FACT_IS_AUTHENTICATED, isAuthenticated );
+        final String rejectKey = isAuthenticated ? WorkflowManager.WF_WP_SAVE_REJECT_MESSAGE_KEY : null;
+        final Workflow workflow = builder.buildApprovalWorkflow( submitter,
+                                                                 WorkflowManager.WF_WP_SAVE_APPROVER,
+                                                                 prepTask,
+                                                                 WorkflowManager.WF_WP_SAVE_DECISION_MESSAGE_KEY,
+                                                                 facts,
+                                                                 completionTask,
+                                                                 rejectKey );
         m_workflowMgr.start( workflow );
 
         // Let callers know if the page-save requires approval
@@ -1486,28 +1466,6 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns a Collection of WikiPages containing the version history of a page.
-     *
-     *  @param page Name of the page to look for
-     *  @return an ordered List of WikiPages, each corresponding to a different revision of the page.
-     */
-    public List< ? extends WikiPage > getVersionHistory( String page ) {
-        List< ? extends WikiPage > c = null;
-
-        try {
-            c = m_pageManager.getVersionHistory( page );
-
-            if( c == null ) {
-                c = m_attachmentManager.getVersionHistory( page );
-            }
-        } catch( ProviderException e ) {
-            log.error( "FIXME", e );
-        }
-
-        return c;
-    }
-
-    /**
      *  Returns this object's ReferenceManager.
      *  @return The current ReferenceManager instance.
      *
@@ -1547,7 +1505,6 @@ public class WikiEngine  {
      *  Returns the current variable manager.
      *  @return The current VariableManager.
      */
-
     public VariableManager getVariableManager()
     {
         return m_variableManager;
@@ -1637,23 +1594,19 @@ 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()}.
+     *  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.
+     *  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.
@@ -1674,8 +1627,7 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the URL of the global RSS file.  May be null, if the
-     *  RSS file generation is not operational.
+     *  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
      */
@@ -1690,8 +1642,7 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the root path.  The root path is where the WikiEngine is
-     *  located in the file system.
+     *  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.
@@ -1711,9 +1662,8 @@ public class WikiEngine  {
     }
 
     /**
-     * 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>
+     * 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
      */
@@ -1772,11 +1722,9 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the AclManager employed by this WikiEngine.
-     *  The AclManager is lazily initialized.
+     *  Returns the AclManager employed by this WikiEngine. The AclManager is lazily initialized.
      *  <p>
-     *  The AclManager implementing class may be set by the
-     *  System property {@link #PROP_ACL_MANAGER_IMPL}.
+     *  The AclManager implementing class may be set by the System property {@link #PROP_ACL_MANAGER_IMPL}.
      *  </p>
      *
      * @since 2.3
@@ -1834,8 +1782,7 @@ public class WikiEngine  {
      * Registers a WikiEventListener with this instance.
      * @param listener the event listener
      */
-    public final synchronized void addWikiEventListener( final WikiEventListener listener )
-    {
+    public final synchronized void addWikiEventListener( final WikiEventListener listener ) {
         WikiEventManager.addWikiEventListener( this, listener );
     }
 
@@ -1843,8 +1790,7 @@ public class WikiEngine  {
      * Un-registers a WikiEventListener with this instance.
      * @param listener the event listener
      */
-    public final synchronized void removeWikiEventListener( final WikiEventListener listener )
-    {
+    public final synchronized void removeWikiEventListener( final WikiEventListener listener ) {
         WikiEventManager.removeWikiEventListener( this, listener );
     }
 
@@ -1869,8 +1815,7 @@ public class WikiEngine  {
     }
 
     /**
-     * Adds an attribute to the engine for the duration of this engine.  The
-     * value is not persisted.
+     * Adds an attribute to the engine for the duration of this engine.  The value is not persisted.
      *
      * @since 2.4.91
      * @param key the attribute name
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index 123ce71..07a58d3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -359,12 +359,22 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * @see org.apache.wiki.pages.PageManager#getVersionHistory(java.lang.String)
      */
     @Override
-    public List< WikiPage > getVersionHistory( final String pageName ) throws ProviderException {
-        if( pageExists( pageName ) ) {
-            return m_provider.getVersionHistory( pageName );
+    public < T extends WikiPage > List< T > getVersionHistory( final String pageName ) {
+        List< T > c = null;
+
+        try {
+            if( pageExists( pageName ) ) {
+                c = (List< T >)m_provider.getVersionHistory( pageName );
+            }
+
+            if( c == null ) {
+                c = (List< T >)m_engine.getAttachmentManager().getVersionHistory( pageName );
+            }
+        } catch( final ProviderException e ) {
+            LOG.error( "ProviderException requesting version history for " + pageName, e );
         }
 
-        return null;
+        return c;
     }
 
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index 1780a5d..9cee4c6 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -184,11 +184,11 @@ public interface PageManager extends WikiEventListener {
     /**
      * Gets a version history of page.  Each element in the returned List is a WikiPage.
      *
-     * @param pageName The name of the page to fetch history for
-     * @return If the page does not exist, returns null, otherwise a List of WikiPages.
-     * @throws ProviderException If the repository fails.
+     * @param pageName The name of the page or attachment to fetch history for
+     * @return If the page does not exist or there's some problem retrieving the version history, returns null,
+     *         otherwise a List of WikiPages / Attachments, each corresponding to a different revision of the page / attachment.
      */
-    List<WikiPage> getVersionHistory( String pageName ) throws ProviderException;
+    < T extends WikiPage > List< T > getVersionHistory( String pageName );
 
     /**
      *  Returns the provider name.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/HistoryIteratorTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/HistoryIteratorTag.java
index c33cd59..694b4a5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/HistoryIteratorTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/HistoryIteratorTag.java
@@ -18,18 +18,17 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-import java.util.List;
-
-import javax.servlet.jsp.JspWriter;
-import javax.servlet.jsp.PageContext;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.ProviderException;
 
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import java.io.IOException;
+import java.util.List;
+
 /**
  *  Iterates through tags.
  *
@@ -40,57 +39,42 @@ import org.apache.wiki.api.exceptions.ProviderException;
  *
  *  @since 2.0
  */
-
 // FIXME: Too much in common with IteratorTag - REFACTOR
-public class HistoryIteratorTag
-    extends IteratorTag
-{
+public class HistoryIteratorTag extends IteratorTag  {
+
     private static final long serialVersionUID = 0L;
-    
-    static    Logger    log = Logger.getLogger( HistoryIteratorTag.class );
+    private static final Logger LOG = Logger.getLogger( HistoryIteratorTag.class );
 
     @Override
     public final int doStartTag() {
         m_wikiContext = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT, PageContext.REQUEST_SCOPE );
+        final WikiEngine engine = m_wikiContext.getEngine();
+        final WikiPage page = m_wikiContext.getPage();
 
-        WikiEngine engine = m_wikiContext.getEngine();
-        WikiPage   page;
-
-        page = m_wikiContext.getPage();
-
-        try
-        {
-            if( page != null && engine.pageExists(page) )
-            {
-                @SuppressWarnings("unchecked")
-                List< WikiPage > versions = ( List< WikiPage > )engine.getVersionHistory( page.getName() );
+        try {
+            if( page != null && engine.pageExists( page ) ) {
+                final List< WikiPage > versions = engine.getPageManager().getVersionHistory( page.getName() );
 
-                if( versions == null )
-                {
+                if( versions == null ) {
                     // There is no history
                     return SKIP_BODY;
                 }
 
                 m_iterator = versions.iterator();
 
-                if( m_iterator.hasNext() )
-                {
-                    WikiContext context = (WikiContext)m_wikiContext.clone();
-                    context.setPage( (WikiPage)m_iterator.next() );
+                if( m_iterator.hasNext() ) {
+                    final WikiContext context = ( WikiContext )m_wikiContext.clone();
+                    context.setPage( ( WikiPage )m_iterator.next() );
                     pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT, context, PageContext.REQUEST_SCOPE );
                     pageContext.setAttribute( getId(), context.getPage() );
-                }
-                else
-                {
+                } else {
                     return SKIP_BODY;
                 }
             }
 
             return EVAL_BODY_BUFFERED;
-        }
-        catch( ProviderException e )
-        {
-            log.fatal("Provider failed while trying to iterator through history",e);
+        } catch( final ProviderException e ) {
+            LOG.fatal("Provider failed while trying to iterator through history",e);
             // FIXME: THrow something.
         }
 
@@ -98,27 +82,21 @@ public class HistoryIteratorTag
     }
 
     @Override
-    public final int doAfterBody()
-    {
-        if( bodyContent != null )
-        {
-            try
-            {
-                JspWriter out = getPreviousOut();
+    public final int doAfterBody() {
+        if( bodyContent != null ) {
+            try {
+                final JspWriter out = getPreviousOut();
                 out.print(bodyContent.getString());
                 bodyContent.clearBody();
-            }
-            catch( IOException e )
-            {
-                log.error("Unable to get inner tag text", e);
+            } catch( final IOException e ) {
+                LOG.error("Unable to get inner tag text", e);
                 // FIXME: throw something?
             }
         }
 
-        if( m_iterator != null && m_iterator.hasNext() )
-        {
-            WikiContext context = (WikiContext)m_wikiContext.clone();
-            context.setPage( (WikiPage)m_iterator.next() );
+        if( m_iterator != null && m_iterator.hasNext() ) {
+            final WikiContext context = ( WikiContext )m_wikiContext.clone();
+            context.setPage( ( WikiPage )m_iterator.next() );
             pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT, context, PageContext.REQUEST_SCOPE );
             pageContext.setAttribute( getId(), context.getPage() );
             return EVAL_BODY_BUFFERED;
@@ -126,4 +104,5 @@ public class HistoryIteratorTag
 
         return SKIP_BODY;
     }
+
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java b/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
index 5f9f703..5edd440 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
@@ -18,6 +18,7 @@
  */
 
 package org.apache.wiki.providers;
+
 import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
@@ -173,7 +174,7 @@ public class VersioningFileProviderTest
         engine.saveText( NAME1, text );
 
         // confirm the right number of versions have been recorded
-        Collection versionHistory = engine.getVersionHistory(NAME1);
+        List< WikiPage > versionHistory = engine.getPageManager().getVersionHistory(NAME1);
         Assertions.assertEquals( 2, versionHistory.size(), "number of versions" );
 
         // fetch the updated page
@@ -221,7 +222,7 @@ public class VersioningFileProviderTest
         engine.saveText( NAME1, text3 );
 
         // confirm the right number of versions have been recorded
-        Collection versionHistory = engine.getVersionHistory(NAME1);
+        Collection versionHistory = engine.getPageManager().getVersionHistory(NAME1);
         Assertions.assertEquals( 3, versionHistory.size(), "number of versions" );
 
         // fetch the latest version of the page
@@ -288,7 +289,7 @@ public class VersioningFileProviderTest
         engine.saveText( NAME1, text3 );
 
         // confirm the right number of versions have been recorded
-        Collection versionHistory = engine.getVersionHistory(NAME1);
+        Collection versionHistory = engine.getPageManager().getVersionHistory(NAME1);
         Assertions.assertEquals( 3, versionHistory.size(), "number of versions" );
 
         // fetch the latest version of the page
@@ -464,7 +465,7 @@ public class VersioningFileProviderTest
         engine.saveText( NAME1, text2 );
         engine.saveText( NAME1, text3 );
 
-        Collection history = engine.getVersionHistory(NAME1);
+        Collection history = engine.getPageManager().getVersionHistory(NAME1);
 
         Assertions.assertEquals( 3, history.size(), "size" );
     }
diff --git a/jspwiki-war/src/main/webapp/rss.jsp b/jspwiki-war/src/main/webapp/rss.jsp
index 088f329..95f1570 100644
--- a/jspwiki-war/src/main/webapp/rss.jsp
+++ b/jspwiki-war/src/main/webapp/rss.jsp
@@ -100,12 +100,9 @@
     
     if( "blog".equals( mode ) ) {
         org.apache.wiki.plugin.WeblogPlugin plug = new org.apache.wiki.plugin.WeblogPlugin();
-        changed = plug.findBlogEntries(wiki,
-                                       wikipage.getName(),
-                                       new Date(0L),
-                                       new Date());
+        changed = plug.findBlogEntries( wiki, wikipage.getName(), new Date(0L), new Date() );
     } else {
-        changed = ( List< WikiPage > )wiki.getVersionHistory( wikipage.getName() );
+        changed = wiki.getPageManager().getVersionHistory( wikipage.getName() );
     }
     
     //
diff --git a/jspwiki-war/src/main/webapp/templates/210/DiffTab.jsp b/jspwiki-war/src/main/webapp/templates/210/DiffTab.jsp
index f55b68f..35c0005 100644
--- a/jspwiki-war/src/main/webapp/templates/210/DiffTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/DiffTab.jsp
@@ -29,7 +29,7 @@
 
 <%
   WikiContext c = WikiContext.findContext( pageContext );
-  List history = c.getEngine().getVersionHistory(c.getPage().getName());
+  List history = c.getEngine().getPageManager().getVersionHistory(c.getPage().getName());
   pageContext.setAttribute( "history", history );
   pageContext.setAttribute( "diffprovider", c.getEngine().getVariableManager().getVariable(c,"jspwiki.diffProvider"));
  %>
diff --git a/jspwiki-war/src/main/webapp/templates/default/DiffTab.jsp b/jspwiki-war/src/main/webapp/templates/default/DiffTab.jsp
index 1f7972b..d88f3ef 100644
--- a/jspwiki-war/src/main/webapp/templates/default/DiffTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/DiffTab.jsp
@@ -29,7 +29,7 @@
 <%
   WikiContext c = WikiContext.findContext( pageContext );
 %>
-<c:set var="history" value="<%= c.getEngine().getVersionHistory(c.getPage().getName()) %>" />
+<c:set var="history" value="<%= c.getEngine().getPageManager().getVersionHistory(c.getPage().getName()) %>" />
 <c:set var="diffprovider" value='<%= c.getEngine().getVariableManager().getVariable(c,"jspwiki.diffProvider") %>' />
 <wiki:PageExists>
 <form action="<wiki:Link jsp='Diff.jsp' format='url' />"


[jspwiki] 03/32: JSPWIKI-120: removed getPageCount from WikiEngine - use PageManager.getTotalPageCount instead

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 46b7e9756048b1a747fd8a662d545b945dfdeeca
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 21:09:20 2020 +0100

    JSPWIKI-120: removed getPageCount from WikiEngine - use PageManager.getTotalPageCount instead
---
 .../src/main/java/org/apache/wiki/WikiEngine.java   |  9 ---------
 .../org/apache/wiki/ui/admin/beans/CoreBean.java    | 21 ++++++++-------------
 .../wiki/variables/DefaultVariableManager.java      |  2 +-
 .../apache/wiki/stress/MassiveRepositoryTest.java   | 21 +++++++++------------
 4 files changed, 18 insertions(+), 35 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 836e10d..3080f5d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -1544,15 +1544,6 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the number of pages in this Wiki
-     *  @return The total number of pages.
-     */
-    public int getPageCount()
-    {
-        return m_pageManager.getTotalPageCount();
-    }
-
-    /**
      *  Returns a Collection of WikiPages, sorted in time
      *  order of last change (i.e. first object is the most
      *  recently changed).  This method also includes attachments.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/CoreBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/CoreBean.java
index a031506..0a8e7d2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/CoreBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/CoreBean.java
@@ -18,25 +18,22 @@
  */
 package org.apache.wiki.ui.admin.beans;
 
-import javax.management.NotCompliantMBeanException;
-
 import org.apache.wiki.Release;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.ui.admin.SimpleAdminBean;
 
+import javax.management.NotCompliantMBeanException;
+
+
 /**
  *  An AdminBean which manages the JSPWiki core operations.
- *
  */
-public class CoreBean
-    extends SimpleAdminBean
-{
+public class CoreBean extends SimpleAdminBean {
+
     private static final String[] ATTRIBUTES = { "pages", "version" };
     private static final String[] METHODS = { };
-    //private WikiEngine m_engine; //inherited proteced filed from SimpleAdminBean
 
-    public CoreBean( WikiEngine engine ) throws NotCompliantMBeanException
-    {
+    public CoreBean( final WikiEngine engine ) throws NotCompliantMBeanException {
         m_engine = engine;
     }
 
@@ -45,9 +42,8 @@ public class CoreBean
      *
      *  @return the page content
      */
-    public int getPages()
-    {
-        return m_engine.getPageCount();
+    public int getPages() {
+        return m_engine.getPageManager().getTotalPageCount();
     }
 
     public String getPagesDescription()
@@ -75,7 +71,6 @@ public class CoreBean
         return CORE;
     }
 
-
     public String getId()
     {
         return "corebean";
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
index 2f82aa8..7ba3d1a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
@@ -343,7 +343,7 @@ public class DefaultVariableManager implements VariableManager {
         }
 
         public String getTotalpages() {
-            return Integer.toString( m_context.getEngine().getPageCount() );
+            return Integer.toString( m_context.getEngine().getPageManager().getTotalPageCount() );
         }
 
         public String getPageprovider() {
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java b/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java
index a581170..08c65f0 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java
@@ -17,23 +17,20 @@
     under the License.  
  */
 package org.apache.wiki.stress;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.AfterEach;
-
-import org.junit.jupiter.api.Test;
-
-import java.io.File;
-import java.util.Properties;
-import java.util.Random;
-
-import org.junit.jupiter.api.Assertions;
 import net.sf.ehcache.CacheManager;
-
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.providers.FileSystemProvider;
 import org.apache.wiki.util.TextUtil;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import java.io.File;
+import java.util.Properties;
+import java.util.Random;
 
 public class MassiveRepositoryTest {
 	
@@ -148,7 +145,7 @@ public class MassiveRepositoryTest {
         
         System.out.println("\nTook "+sw.toString()+", which is "+sw.toString(numRevisions)+" adds/second");
         
-        Assertions.assertEquals( numPages, engine.getPageCount(), "Right number of pages" );
+        Assertions.assertEquals( numPages, engine.getPageManager().getTotalPageCount(), "Right number of pages" );
         
         //
         //  Rendering random pages


[jspwiki] 20/32: JSPWIKI-120: move getText(..) methods from WikiEngine to PageManager

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 4cb064d76569011498a649e54888a5b2225813d2
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Jan 6 22:41:09 2020 +0100

    JSPWIKI-120: move getText(..) methods from WikiEngine to PageManager
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 53 --------------------
 .../org/apache/wiki/pages/DefaultPageManager.java  |  9 ++++
 .../java/org/apache/wiki/pages/PageManager.java    | 38 +++++++++++++++
 .../org/apache/wiki/rpc/atom/AtomAPIServlet.java   |  2 +-
 .../java/org/apache/wiki/tags/InsertPageTag.java   |  8 +---
 .../org/apache/wiki/xmlrpc/MetaWeblogHandler.java  |  2 +-
 .../test/java/org/apache/wiki/WikiEngineTest.java  | 49 +------------------
 .../java/org/apache/wiki/auth/UserManagerTest.java |  4 +-
 .../org/apache/wiki/content/PageRenamerTest.java   | 16 +++----
 .../apache/wiki/pages/DefaultPageManagerTest.java  | 56 ++++++++++++++++++++--
 .../apache/wiki/providers/CachingProviderTest.java |  2 +-
 .../wiki/providers/VersioningFileProviderTest.java | 50 +++++++++----------
 .../wiki/stress/StressTestVersioningProvider.java  |  2 +-
 jspwiki-war/src/main/webapp/Edit.jsp               |  2 +-
 jspwiki-war/src/main/webapp/PageModified.jsp       |  2 +-
 .../src/main/webapp/templates/default/Nav.jsp      |  2 +-
 16 files changed, 144 insertions(+), 153 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 4308c3b..a6183f4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -1160,59 +1160,6 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns the un-HTMLized text of the latest version of a page. This method also replaces the &lt; and &amp; -characters with
-     *  their respective HTML entities, thus making it suitable for inclusion on an HTML page.  If you want to have the page text
-     *  without any conversions, use getPureText().
-     *
-     *  @param page WikiName of the page to fetch.
-     *  @return WikiText.
-     */
-    public String getText( final String page )
-    {
-        return getText( page, WikiPageProvider.LATEST_VERSION );
-    }
-
-    /**
-     *  Returns the un-HTMLized text of the given version of a page. This method also replaces the &lt; and &amp; -characters with
-     *  their respective HTML entities, thus making it suitable for inclusion on an HTML page.  If you want to have the page text
-     *  without any conversions, use getPureText().
-     *
-     * @param page WikiName of the page to fetch
-     * @param version  Version of the page to fetch
-     * @return WikiText.
-     */
-    public String getText( final String page, final int version ) {
-        final String result = getPageManager().getPureText( page, version );
-
-        //
-        //  Replace ampersand first, or else all quotes and stuff
-        //  get replaced as well with &quot; etc.
-        //
-        /*
-        result = TextUtil.replaceString( result, "&", "&amp;" );
-        */
-
-        return TextUtil.replaceEntities( result );
-    }
-
-    /**
-     *  Returns the un-HTMLized text of the given version of a page in the given context.  USE THIS METHOD if you don't know what doing.
-     *  <p>
-     *  This method also replaces the &lt; and &amp; -characters with their respective HTML entities, thus making it suitable
-     *  for inclusion on an HTML page.  If you want to have the page text without any conversions, use getPureText().
-     *
-     *  @since 1.9.15.
-     *  @param context The WikiContext
-     *  @param page    A page reference (not an attachment)
-     *  @return The page content as HTMLized String.
-     *  @see PageManager#getPureText(WikiPage)
-     */
-    public String getText( final WikiContext context, final WikiPage page )
-    {
-        return getText( page.getName(), page.getVersion() );
-    }
-
-    /**
      *  Returns the converted HTML of the page using a different context than the default context.
      *
      *  @param  context A WikiContext in which you wish to render this page in.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index 07a58d3..d47f910 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -210,6 +210,15 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
 
     /**
      * {@inheritDoc}
+     * @see org.apache.wiki.pages.PageManager#getText(String, int)
+     */
+    public String getText( final String page, final int version ) {
+        final String result = getPureText( page, version );
+        return TextUtil.replaceEntities( result );
+    }
+
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getEngine()
      */
     @Override
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index 9cee4c6..e3435fb 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -98,6 +98,44 @@ public interface PageManager extends WikiEventListener {
     }
 
     /**
+     *  Returns the un-HTMLized text of the given version of a page. This method also replaces the &lt; and &amp; -characters with
+     *  their respective HTML entities, thus making it suitable for inclusion on an HTML page.  If you want to have the page text
+     *  without any conversions, use {@link #getPureText(String, int)}.
+     *
+     * @param page WikiName of the page to fetch
+     * @param version  Version of the page to fetch
+     * @return WikiText.
+     */
+    String getText( String page, int version );
+
+    /**
+     *  Returns the un-HTMLized text of the latest version of a page. This method also replaces the &lt; and &amp; -characters with
+     *  their respective HTML entities, thus making it suitable for inclusion on an HTML page.  If you want to have the page text
+     *  without any conversions, use {@link #getPureText(String, int)}.
+     *
+     *  @param page WikiName of the page to fetch.
+     *  @return WikiText.
+     */
+    default String getText( final String page ) {
+        return getText( page, WikiPageProvider.LATEST_VERSION );
+    }
+
+    /**
+     *  Returns the un-HTMLized text of the given version of a page in the given context.  USE THIS METHOD if you don't know what doing.
+     *  <p>
+     *  This method also replaces the &lt; and &amp; -characters with their respective HTML entities, thus making it suitable
+     *  for inclusion on an HTML page.  If you want to have the page text without any conversions, use {@link #getPureText(WikiPage)}.
+     *
+     *  @since 1.9.15.
+     *  @param page A page reference (not an attachment)
+     *  @return The page content as HTMLized String.
+     *  @see PageManager#getPureText(WikiPage)
+     */
+    default String getText( final WikiPage page ) {
+        return getText( page.getName(), page.getVersion() );
+    }
+
+    /**
      * Returns the WikiEngine to which this PageManager belongs to.
      *
      * @return The WikiEngine object.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
index 6abdf6c..f172e25 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
@@ -228,7 +228,7 @@ public class AtomAPIServlet extends HttpServlet
 
         Entry entry = SyndicationFactory.newSyndicationEntry();
 
-        String pageText = m_engine.getText(page.getName());
+        String pageText = m_engine.getPageManager().getText(page.getName());
         String title = "";
         int firstLine = pageText.indexOf('\n');
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java
index 643d0c4..e7f62d5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java
@@ -109,12 +109,8 @@ public class InsertPageTag extends WikiTagBase {
             final WikiPage oldPage = m_wikiContext.setRealPage( insertedPage );
             
             switch( m_mode ) {
-              case HTML:
-                out.print( engine.getHTML( m_wikiContext, insertedPage ) );
-                break;
-              case PLAIN:
-                out.print( engine.getText( m_wikiContext, insertedPage ) );
-                break;
+              case HTML: out.print( engine.getHTML( m_wikiContext, insertedPage ) ); break;
+              case PLAIN: out.print( engine.getPageManager().getText( insertedPage ) ); break;
             }
             
             m_wikiContext.setRealPage( oldPage );
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 db56148..37f43a6 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
@@ -157,7 +157,7 @@ public class MetaWeblogHandler
         ht.put("postid", page.getName());
         ht.put("userid", page.getAuthor());
 
-        String pageText = m_context.getEngine().getText(page.getName());
+        String pageText = m_context.getEngine().getPageManager().getText(page.getName());
         String title = "";
         int firstLine = pageText.indexOf('\n');
 
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 f41e275..6ecffce 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -119,39 +119,6 @@ public class WikiEngineTest {
     }
 
     @Test
-    public void testPutPage() throws Exception {
-        final String text = "Foobar.\r\n";
-        final String name = NAME1;
-        m_engine.saveText( name, text );
-
-        Assertions.assertTrue( m_engine.pageExists( name ), "page does not exist" );
-        Assertions.assertEquals( text, m_engine.getText( name ), "wrong content" );
-    }
-
-    @Test
-    public void testPutPageEntities() throws Exception {
-        final String text = "Foobar. &quot;\r\n";
-        final String name = NAME1;
-        m_engine.saveText( name, text );
-
-        Assertions.assertTrue( m_engine.pageExists( name ), "page does not exist" );
-        Assertions.assertEquals( "Foobar. &amp;quot;\r\n", m_engine.getText( name ), "wrong content" );
-    }
-
-    /**
-     *  Check that basic " is changed.
-     */
-    @Test
-    public void testPutPageEntities2() throws Exception {
-        final String text = "Foobar. \"\r\n";
-        final String name = NAME1;
-        m_engine.saveText( name, text );
-
-        Assertions.assertTrue( m_engine.pageExists( name ), "page does not exist" );
-        Assertions.assertEquals( "Foobar. &quot;\r\n", m_engine.getText( name ), "wrong content" );
-    }
-
-    @Test
     public void testGetHTML() throws Exception {
         final String text = "''Foobar.''";
         final String name = NAME1;
@@ -377,7 +344,7 @@ public class WikiEngineTest {
     @Test
     public void testSpacedNames1() throws Exception {
         m_engine.saveText("This is a test", "puppaa");
-        Assertions.assertEquals( "puppaa", m_engine.getText("This is a test").trim(), "normal" );
+        Assertions.assertEquals( "puppaa", m_engine.getPageManager().getText("This is a test").trim(), "normal" );
     }
 
 
@@ -449,18 +416,4 @@ public class WikiEngineTest {
         Assertions.assertFalse( m_engine.pageExists( name ), "page should not exist right now neither" );
     }
 
-    @Test
-    public void testSaveExistingPageWithEmptyContent() throws Exception {
-        final String text = "Foobar.\r\n";
-        final String name = NAME1;
-        m_engine.saveText( name, text );
-
-        Assertions.assertTrue( m_engine.pageExists( name ), "page does not exist" );
-        // saveText uses normalizePostData to assure it conforms to certain rules
-        Assertions.assertEquals( TextUtil.normalizePostData( text ), m_engine.getText( name ), "wrong content" );
-
-        m_engine.saveText( name, "" );
-        Assertions.assertEquals( TextUtil.normalizePostData( "" ), m_engine.getText( name ), "wrong content" );
-    }
-
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
index 05ad867..668d4f2 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
@@ -190,7 +190,7 @@ public class UserManagerTest {
         // Test 4: our page text should have been re-written
         // (The new full name should be in the ACL, but the login name should have been removed)
         String expectedText = "[{ALLOW view Alice," + newName + "}]\nTest text.  More text.\r\n";
-        String actualText = m_engine.getText( pageName );
+        String actualText = m_engine.getPageManager().getText( pageName );
         Assertions.assertEquals( expectedText, actualText );
 
         // Remove our test page
@@ -249,7 +249,7 @@ public class UserManagerTest {
         // Test 8: our page text should have been re-written
         // (The new full name should be in the ACL, but the login name should have been removed)
         expectedText = "[{ALLOW view Alice," + oldName + "}]\nMore test text.  More text.\r\n";
-        actualText = m_engine.getText( pageName );
+        actualText = m_engine.getPageManager().getText( pageName );
         Assertions.assertEquals( expectedText, actualText );
 
         // CLEANUP: delete the profile; user and page; should be back to old counts
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
index 6bd2659..fe57d7f 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
@@ -267,7 +267,7 @@ public class PageRenamerTest
 
         Assertions.assertNotNull( p, "no page" );
 
-        Assertions.assertEquals("[FooTest]", m_engine.getText("FooTest").trim() );
+        Assertions.assertEquals("[FooTest]", m_engine.getPageManager().getText("FooTest").trim() );
     }
 
     @Test
@@ -283,7 +283,7 @@ public class PageRenamerTest
         Assertions.assertNotNull( p, "no page" );
 
         // Should be no change
-        Assertions.assertEquals("[TestPage|]", m_engine.getText("TestPage2").trim() );
+        Assertions.assertEquals("[TestPage|]", m_engine.getPageManager().getText("TestPage2").trim() );
     }
 
     @Test
@@ -299,7 +299,7 @@ public class PageRenamerTest
 
         Assertions.assertNotNull( p, "no page" );
 
-        Assertions.assertEquals("[|FooTest]", m_engine.getText("TestPage2").trim() );
+        Assertions.assertEquals("[|FooTest]", m_engine.getPageManager().getText("TestPage2").trim() );
     }
 
     private void rename( String src, String dst ) throws WikiException
@@ -329,7 +329,7 @@ public class PageRenamerTest
 
         rename( "Cdauth", "CdauthNew" );
 
-        Assertions.assertEquals( dst, m_engine.getText("TestPage").trim() );
+        Assertions.assertEquals( dst, m_engine.getPageManager().getText("TestPage").trim() );
     }
 
     @Test
@@ -342,7 +342,7 @@ public class PageRenamerTest
 
         rename ("TestPage2", "Test");
 
-        Assertions.assertEquals( "[Link to Test|Test]", m_engine.getText( "TestPage" ).trim() );
+        Assertions.assertEquals( "[Link to Test|Test]", m_engine.getPageManager().getText( "TestPage" ).trim() );
     }
 
     @Test
@@ -355,7 +355,7 @@ public class PageRenamerTest
 
         rename ("TestPage2", "Test");
 
-        Assertions.assertEquals( "[Link to Test|Test|target='_new']", m_engine.getText( "TestPage" ).trim() );
+        Assertions.assertEquals( "[Link to Test|Test|target='_new']", m_engine.getPageManager().getText( "TestPage" ).trim() );
     }
 
     @Test
@@ -452,7 +452,7 @@ public class PageRenamerTest
 
         rename ("TestPage2", "Test");
 
-        Assertions.assertEquals( "[[Link to TestPage2|TestPage2|target='_new']", m_engine.getText( "TestPage" ).trim() );
+        Assertions.assertEquals( "[[Link to TestPage2|TestPage2|target='_new']", m_engine.getPageManager().getText( "TestPage" ).trim() );
     }
 
     @Test
@@ -465,7 +465,7 @@ public class PageRenamerTest
 
         rename ("TestPage2", "Test");
 
-        Assertions.assertEquals( "~[Link to TestPage2|TestPage2|target='_new']", m_engine.getText( "TestPage" ).trim() );
+        Assertions.assertEquals( "~[Link to TestPage2|TestPage2|target='_new']", m_engine.getPageManager().getText( "TestPage" ).trim() );
     }
 
     /**
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
index b52b706..6d934e4 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
@@ -29,6 +29,7 @@ import org.apache.wiki.providers.BasicAttachmentProvider;
 import org.apache.wiki.providers.CachingProvider;
 import org.apache.wiki.providers.FileSystemProvider;
 import org.apache.wiki.providers.VerySimpleProvider;
+import org.apache.wiki.util.TextUtil;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
@@ -150,7 +151,7 @@ public class DefaultPageManagerTest {
         engine.getPageManager().deleteVersion( page );
         Assertions.assertNull( engine.getPageManager().getPage( NAME1, 3 ), "got page" );
 
-        final String content = engine.getText( NAME1, WikiProvider.LATEST_VERSION );
+        final String content = engine.getPageManager().getText( NAME1, WikiProvider.LATEST_VERSION );
         Assertions.assertEquals( "Test2", content.trim(), "content" );
     }
 
@@ -167,9 +168,9 @@ public class DefaultPageManagerTest {
         engine.getPageManager().deleteVersion( page );
         Assertions.assertNull( engine.getPageManager().getPage( NAME1, 1 ), "got page" );
 
-        final String content = engine.getText( NAME1, WikiProvider.LATEST_VERSION );
+        final String content = engine.getPageManager().getText( NAME1, WikiProvider.LATEST_VERSION );
         Assertions.assertEquals( "Test3", content.trim(), "content" );
-        Assertions.assertEquals( "", engine.getText(NAME1, 1).trim(), "content1" );
+        Assertions.assertEquals( "", engine.getPageManager().getText(NAME1, 1).trim(), "content1" );
     }
 
     @Test
@@ -192,7 +193,7 @@ public class DefaultPageManagerTest {
         props.setProperty( "jspwiki.pageProvider", "org.apache.wiki.providers.VerySimpleProvider" );
         props.setProperty( "jspwiki.usePageCache", "false" );
         final WikiEngine engine = new TestEngine( props );
-        final String p = engine.getText( "test", -1 );
+        final String p = engine.getPageManager().getText( "test", -1 );
         final VerySimpleProvider vsp = (VerySimpleProvider) engine.getPageManager().getProvider();
 
         Assertions.assertEquals( "test", vsp.m_latestReq, "wrong page" );
@@ -229,4 +230,51 @@ public class DefaultPageManagerTest {
         Assertions.assertNotNull( p, "null" );
     }
 
+    @Test
+    public void testPutPage() throws Exception {
+        final String text = "Foobar.\r\n";
+        final String name = NAME1;
+        engine.saveText( name, text );
+
+        Assertions.assertTrue( engine.pageExists( name ), "page does not exist" );
+        Assertions.assertEquals( text, engine.getPageManager().getText( name ), "wrong content" );
+    }
+
+    @Test
+    public void testPutPageEntities() throws Exception {
+        final String text = "Foobar. &quot;\r\n";
+        final String name = NAME1;
+        engine.saveText( name, text );
+
+        Assertions.assertTrue( engine.pageExists( name ), "page does not exist" );
+        Assertions.assertEquals( "Foobar. &amp;quot;\r\n", engine.getPageManager().getText( name ), "wrong content" );
+    }
+
+    /**
+     *  Check that basic " is changed.
+     */
+    @Test
+    public void testPutPageEntities2() throws Exception {
+        final String text = "Foobar. \"\r\n";
+        final String name = NAME1;
+        engine.saveText( name, text );
+
+        Assertions.assertTrue( engine.pageExists( name ), "page does not exist" );
+        Assertions.assertEquals( "Foobar. &quot;\r\n", engine.getPageManager().getText( name ), "wrong content" );
+    }
+
+    @Test
+    public void testSaveExistingPageWithEmptyContent() throws Exception {
+        final String text = "Foobar.\r\n";
+        final String name = NAME1;
+        engine.saveText( name, text );
+
+        Assertions.assertTrue( engine.pageExists( name ), "page does not exist" );
+        // saveText uses normalizePostData to assure it conforms to certain rules
+        Assertions.assertEquals( TextUtil.normalizePostData( text ), engine.getPageManager().getText( name ), "wrong content" );
+
+        engine.saveText( name, "" );
+        Assertions.assertEquals( TextUtil.normalizePostData( "" ), engine.getPageManager().getText( name ), "wrong content" );
+    }
+
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/providers/CachingProviderTest.java b/jspwiki-main/src/test/java/org/apache/wiki/providers/CachingProviderTest.java
index 6aa93d8..1d29bfa 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/providers/CachingProviderTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/providers/CachingProviderTest.java
@@ -95,7 +95,7 @@ public class CachingProviderTest
         WikiPage p = engine.getPageManager().getPage( "Testi" );
         Assertions.assertNotNull( p, "page did not exist?" );
 
-        String text = engine.getText( "Testi");
+        String text = engine.getPageManager().getText( "Testi");
         Assertions.assertEquals( "[fuufaa]", text, "text" );
 
         // TODO: ReferenceManager check as well
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java b/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
index 5edd440..cb17e9c 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
@@ -87,7 +87,7 @@ public class VersioningFileProviderTest
        // also create an associated properties file with some history
         injectFile(NAME1+FileSystemProvider.PROP_EXT, FAKE_HISTORY);
 
-        String res = engine.getText( NAME1 );
+        String res = engine.getPageManager().getText( NAME1 );
         Assertions.assertEquals( fakeWikiPage, res, "fetch latest should work" );
 
         WikiPage page = engine.getPageManager().getPage( NAME1, 1 );
@@ -108,10 +108,10 @@ public class VersioningFileProviderTest
         // initial FileSystemProvider wiki page must be faked.
         injectFile(NAME1+AbstractFileProvider.FILE_EXT, "foobar");
 
-        String res = engine.getText( NAME1 );
+        String res = engine.getPageManager().getText( NAME1 );
         Assertions.assertEquals( "foobar", res, "fetch latest did not work" );
 
-        res = engine.getText( NAME1, 1 ); // Should be the first version.
+        res = engine.getPageManager().getText( NAME1, 1 ); // Should be the first version.
         Assertions.assertEquals( "foobar", res, "fetch by direct version did not work" );
 
         WikiPage page = engine.getPageManager().getPage( NAME1 );
@@ -136,10 +136,10 @@ public class VersioningFileProviderTest
        // now create the associated properties file with some history
         injectFile(NAME1+FileSystemProvider.PROP_EXT, FAKE_HISTORY);
 
-        String res = engine.getText( NAME1 );
+        String res = engine.getPageManager().getText( NAME1 );
         Assertions.assertEquals( fakeWikiPage, res, "fetch latest did not work" );
 
-        res = engine.getText( NAME1, 1 ); // Should be the first version.
+        res = engine.getPageManager().getText( NAME1, 1 ); // Should be the first version.
         Assertions.assertEquals( fakeWikiPage, res, "fetch by direct version did not work" );
 
         WikiPage page = engine.getPageManager().getPage( NAME1, 1 );
@@ -166,7 +166,7 @@ public class VersioningFileProviderTest
        // also create an associated properties file with some history
         injectFile(NAME1+FileSystemProvider.PROP_EXT, FAKE_HISTORY);
 
-        String result1 = engine.getText( NAME1 );
+        String result1 = engine.getPageManager().getText( NAME1 );
         Assertions.assertEquals( fakeWikiPage, result1, "latest should be initial" );
 
         // now update the wiki page to create a new version
@@ -178,13 +178,13 @@ public class VersioningFileProviderTest
         Assertions.assertEquals( 2, versionHistory.size(), "number of versions" );
 
         // fetch the updated page
-        String result2 = engine.getText( NAME1 );
+        String result2 = engine.getPageManager().getText( NAME1 );
         Assertions.assertEquals( text, result2, "latest should be new version" );
-        String result3 = engine.getText( NAME1, 2 ); // Should be the 2nd version.
+        String result3 = engine.getPageManager().getText( NAME1, 2 ); // Should be the 2nd version.
         Assertions.assertEquals( text, result3, "fetch new by version did not work" );
 
         // now confirm the original page has been archived
-        String result4 = engine.getText( NAME1, 1 );
+        String result4 = engine.getPageManager().getText( NAME1, 1 );
         Assertions.assertEquals( fakeWikiPage, result4, "fetch original by version Assertions.failed" );
 
         WikiPage pageNew = engine.getPageManager().getPage( NAME1, 2 );
@@ -226,17 +226,17 @@ public class VersioningFileProviderTest
         Assertions.assertEquals( 3, versionHistory.size(), "number of versions" );
 
         // fetch the latest version of the page
-        String result = engine.getText( NAME1 );
+        String result = engine.getPageManager().getText( NAME1 );
         Assertions.assertEquals( text3, result, "latest should be newest version" );
-        String result2 = engine.getText( NAME1, 3 );
+        String result2 = engine.getPageManager().getText( NAME1, 3 );
         Assertions.assertEquals( text3, result2, "fetch new by version did not work" );
 
         // confirm the original page was archived
-        String result3 = engine.getText( NAME1, 1 );
+        String result3 = engine.getPageManager().getText( NAME1, 1 );
         Assertions.assertEquals( fakeWikiPage, result3, "fetch original by version Assertions.failed" );
 
         // confirm the first update was archived
-        String result4 = engine.getText( NAME1, 2 );
+        String result4 = engine.getPageManager().getText( NAME1, 2 );
         Assertions.assertEquals( text2, result4, "fetch original by version Assertions.failed" );
 
         WikiPage pageNew = engine.getPageManager().getPage( NAME1 );
@@ -293,17 +293,17 @@ public class VersioningFileProviderTest
         Assertions.assertEquals( 3, versionHistory.size(), "number of versions" );
 
         // fetch the latest version of the page
-        String result = engine.getText( NAME1 );
+        String result = engine.getPageManager().getText( NAME1 );
         Assertions.assertEquals( text3, result, "latest should be newest version" );
-        String result2 = engine.getText( NAME1, 3 );
+        String result2 = engine.getPageManager().getText( NAME1, 3 );
         Assertions.assertEquals( text3, result2, "fetch new by version did not work" );
 
         // confirm the original page was archived
-        String result3 = engine.getText( NAME1, 1 );
+        String result3 = engine.getPageManager().getText( NAME1, 1 );
         Assertions.assertEquals( fakeWikiPage, result3, "fetch original by version Assertions.failed" );
 
         // confirm the first update was archived
-        String result4 = engine.getText( NAME1, 2 );
+        String result4 = engine.getPageManager().getText( NAME1, 2 );
         Assertions.assertEquals( text2, result4, "fetch original by version Assertions.failed" );
 
         WikiPage pageNew = engine.getPageManager().getPage( NAME1 );
@@ -338,7 +338,7 @@ public class VersioningFileProviderTest
         Assertions.assertEquals( maxver, pageinfo.getVersion(), "wrong version" );
 
         // +2 comes from \r\n.
-        Assertions.assertEquals( maxver+2, engine.getText(NAME1).length(), "wrong text" );
+        Assertions.assertEquals( maxver+2, engine.getPageManager().getText(NAME1).length(), "wrong text" );
     }
 
     @Test
@@ -349,7 +349,7 @@ public class VersioningFileProviderTest
 
         engine.saveText( NAME1, text );
 
-        String res = engine.getText(NAME1);
+        String res = engine.getPageManager().getText(NAME1);
 
         Assertions.assertEquals( text, res );
     }
@@ -397,9 +397,9 @@ public class VersioningFileProviderTest
 
         Assertions.assertEquals( 3, res.getVersion(), "wrong version" );
 
-        Assertions.assertEquals( text, engine.getText( NAME1, 1 ), "ver1" );
-        Assertions.assertEquals( text2, engine.getText( NAME1, 2 ), "ver2" );
-        Assertions.assertEquals( text3, engine.getText( NAME1, 3 ), "ver3" );
+        Assertions.assertEquals( text, engine.getPageManager().getText( NAME1, 1 ), "ver1" );
+        Assertions.assertEquals( text2, engine.getPageManager().getText( NAME1, 2 ), "ver2" );
+        Assertions.assertEquals( text3, engine.getPageManager().getText( NAME1, 3 ), "ver3" );
     }
 
     @Test
@@ -442,9 +442,9 @@ public class VersioningFileProviderTest
 
         Assertions.assertEquals( 3, res.getVersion(), "wrong version" );
 
-        Assertions.assertEquals( text, engine.getText( NAME1, 1 ), "ver1" );
-        Assertions.assertEquals( text2, engine.getText( NAME1, 2 ), "ver2" );
-        Assertions.assertEquals( text3, engine.getText( NAME1, 3 ), "ver3" );
+        Assertions.assertEquals( text, engine.getPageManager().getText( NAME1, 1 ), "ver1" );
+        Assertions.assertEquals( text2, engine.getPageManager().getText( NAME1, 2 ), "ver2" );
+        Assertions.assertEquals( text3, engine.getPageManager().getText( NAME1, 3 ), "ver3" );
     }
 
     @Test
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java b/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java
index dd81de0..300fab6 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java
@@ -72,7 +72,7 @@ public class StressTestVersioningProvider {
         Assertions.assertEquals( maxver, pageinfo.getVersion(), "wrong version" );
 
         // +2 comes from \r\n.
-        Assertions.assertEquals( maxver+2, engine.getText(NAME1).length(), "wrong text" );
+        Assertions.assertEquals( maxver+2, engine.getPageManager().getText(NAME1).length(), "wrong text" );
     }
 
     private void runMassiveFileTest(int maxpages)
diff --git a/jspwiki-war/src/main/webapp/Edit.jsp b/jspwiki-war/src/main/webapp/Edit.jsp
index 1178cc7..bcaf43e 100644
--- a/jspwiki-war/src/main/webapp/Edit.jsp
+++ b/jspwiki-war/src/main/webapp/Edit.jsp
@@ -199,7 +199,7 @@
 
             if( append != null )
             {
-                StringBuffer pageText = new StringBuffer(wiki.getText( pagereq ));
+                StringBuffer pageText = new StringBuffer(wiki.getPageManager().getText( pagereq ));
 
                 pageText.append( text );
 
diff --git a/jspwiki-war/src/main/webapp/PageModified.jsp b/jspwiki-war/src/main/webapp/PageModified.jsp
index f679e67..9130123 100644
--- a/jspwiki-war/src/main/webapp/PageModified.jsp
+++ b/jspwiki-war/src/main/webapp/PageModified.jsp
@@ -46,7 +46,7 @@
     // Make the user and conflicting text presentable for display.
     usertext = StringEscapeUtils.escapeXml11( usertext );
 
-    String conflicttext = wiki.getText(pagereq);
+    String conflicttext = wiki.getPageManager().getText(pagereq);
     conflicttext = StringEscapeUtils.escapeXml11( conflicttext );
 
     pageContext.setAttribute( "conflicttext",
diff --git a/jspwiki-war/src/main/webapp/templates/default/Nav.jsp b/jspwiki-war/src/main/webapp/templates/default/Nav.jsp
index 57bdc49..0bf0f36 100644
--- a/jspwiki-war/src/main/webapp/templates/default/Nav.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/Nav.jsp
@@ -31,7 +31,7 @@
 <%
   WikiContext c = WikiContext.findContext( pageContext );
 
-  String text = c.getEngine().getText(c, c.getPage());
+  String text = c.getEngine().getPageManager().getText(c, c.getPage());
   StringTokenizer tokens = new StringTokenizer( text );
   //avg reading speeds: https://iovs.arvojournals.org/article.aspx?articleid=2166061
 


[jspwiki] 14/32: take into account executions on Windows boxes can have both / and \

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 d7dd21dbc5a85bedda99c22d3b4382a11de419ff
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Jan 5 01:20:44 2020 +0100

    take into account executions on Windows boxes can have both / and \
---
 jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 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 e2c3849..f012adb 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -423,13 +423,15 @@ public class TestEngine extends WikiEngine
     private static String cleanNewDirFrom( final String pageDir, final long millis ) {
         final String testEngineCreationOrigin = getTestEngineCreationOrigin();
         if( StringUtils.isBlank( pageDir ) ) {
-            return "target/" + millis + "-" + testEngineCreationOrigin;
+            return "target" + File.separator + millis + "-" + testEngineCreationOrigin;
         }
-        if( pageDir.lastIndexOf( '/' ) == -1 ) {
-            return "target/" + millis + "-" + testEngineCreationOrigin + "-" + pageDir;
+        // take into account executions on Windows boxes can have both / and \
+        final int lastDirPosition = Math.max( pageDir.lastIndexOf( '/' ), pageDir.lastIndexOf( File.separator ) );
+        if( lastDirPosition == -1 ) {
+            return "target" + File.separator + millis + "-" + testEngineCreationOrigin + "-" + pageDir;
         }
-        final String stripNumbers = pageDir.substring( pageDir.lastIndexOf( '/' ) );
-        return pageDir.substring( 0, pageDir.lastIndexOf( '/' ) + 1 )
+        final String stripNumbers = pageDir.substring( lastDirPosition );
+        return pageDir.substring( 0, lastDirPosition + 1 )
              + millis
              + "-" + testEngineCreationOrigin
              + stripNumbers.replaceAll( "\\d", StringUtils.EMPTY ); // place all related tests' folders one next to the others


[jspwiki] 06/32: add missing package.html

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 f9171896199eadc25b6ada123c6c78c1496f9eb2
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 21:17:40 2020 +0100

    add missing package.html
---
 .../main/java/org/apache/wiki/pages/package.html   | 34 ++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/package.html b/jspwiki-main/src/main/java/org/apache/wiki/pages/package.html
new file mode 100644
index 0000000..16b4cf2
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/package.html
@@ -0,0 +1,34 @@
+<!--
+    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.
+-->
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html lang="en">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>org.apache.wiki.pages</title>
+</head>
+<body>
+Provides the JSPWiki wiki page related functionality.
+
+<h3>Package Specification</h3>
+
+<h3>Related Documentation</h3>
+
+</body>
+</html>
\ No newline at end of file


[jspwiki] 27/32: apply format and fixes suggested by IntelliJ to 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 7a7056638f88c8fc4514e5eabc891816bf092c1d
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 8 23:46:38 2020 +0100

    apply format and fixes suggested by IntelliJ to WikiEngine
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 281 ++++++++-------------
 1 file changed, 100 insertions(+), 181 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 d6c94e9..2e0a0bf 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -300,9 +300,7 @@ public class WikiEngine  {
      */
     // FIXME: It seems that this does not work too well, jspInit()
     // does not react to RuntimeExceptions, or something...
-    public static synchronized WikiEngine getInstance( ServletConfig config )
-        throws InternalWikiException
-    {
+    public static synchronized WikiEngine getInstance( final ServletConfig config ) throws InternalWikiException {
         return getInstance( config.getServletContext(), null );
     }
 
@@ -318,9 +316,7 @@ public class WikiEngine  {
      *
      *  @return One well-behaving WikiEngine instance.
      */
-    public static synchronized WikiEngine getInstance( ServletConfig config,
-                                                       Properties props )
-    {
+    public static synchronized WikiEngine getInstance( final ServletConfig config, final Properties props ) {
         return getInstance( config.getServletContext(), props );
     }
 
@@ -339,29 +335,20 @@ public class WikiEngine  {
     //        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( ServletContext context,
-                                                       Properties props )
-        throws InternalWikiException
-    {
-        WikiEngine engine = (WikiEngine) context.getAttribute( ATTR_WIKIENGINE );
-
-        if( engine == null )
-        {
-            String appid = Integer.toString(context.hashCode()); //FIXME: Kludge, use real type.
+    public static synchronized WikiEngine getInstance( final ServletContext context, Properties props ) throws InternalWikiException {
+        WikiEngine engine = ( WikiEngine )context.getAttribute( ATTR_WIKIENGINE );
 
+        if( engine == null ) {
+            final String appid = Integer.toString(context.hashCode()); //FIXME: Kludge, use real type.
             context.log(" Assigning new engine to "+appid);
-            try
-            {
-                if( props == null )
-                {
+            try {
+                if( props == null ) {
                     props = PropertyReader.loadWebAppProps( context );
                 }
 
                 engine = new WikiEngine( context, appid, props );
                 context.setAttribute( ATTR_WIKIENGINE, engine );
-            }
-            catch( Exception e )
-            {
+            } catch( final Exception e ) {
                 context.log( "ERROR: Failed to create a Wiki engine: "+e.getMessage() );
                 log.error( "ERROR: Failed to create a Wiki engine, stacktrace follows " , e);
                 throw new InternalWikiException( "No wiki engine, check logs." , e);
@@ -380,9 +367,7 @@ public class WikiEngine  {
      *  @param properties A set of properties to use to initialize this WikiEngine.
      *  @throws WikiException If the initialization fails.
      */
-    public WikiEngine( Properties properties )
-        throws WikiException
-    {
+    public WikiEngine( final Properties properties ) throws WikiException {
         initialize( properties );
     }
 
@@ -398,33 +383,23 @@ public class WikiEngine  {
      *  @param props   The WikiEngine configuration.
      *  @throws WikiException If the WikiEngine construction fails.
      */
-    protected WikiEngine( ServletContext context, String appid, Properties props )
-        throws WikiException
-    {
-        super();
+    protected WikiEngine( final ServletContext context, final String appid, final Properties props ) throws WikiException {
         m_servletContext = context;
         m_appid          = appid;
 
         // Stash the WikiEngine in the servlet context
-        if ( context != null )
-        {
+        if ( context != null ) {
             context.setAttribute( ATTR_WIKIENGINE,  this );
             m_rootPath = context.getRealPath("/");
         }
 
-        try
-        {
-            //
+        try {
             //  Note: May be null, if JSPWiki has been deployed in a WAR file.
-            //
             initialize( props );
-            log.info("Root path for this Wiki is: '"+m_rootPath+"'");
-        }
-        catch( Exception e )
-        {
-            String msg = Release.APPNAME+": Unable to load and setup properties from jspwiki.properties. "+e.getMessage();
-            if ( context != null )
-            {
+            log.info( "Root path for this Wiki is: '" + m_rootPath + "'" );
+        } catch( final Exception e ) {
+            final String msg = Release.APPNAME+": Unable to load and setup properties from jspwiki.properties. "+e.getMessage();
+            if ( context != null ) {
                 context.log( msg );
             }
             throw new WikiException( msg, e );
@@ -434,9 +409,7 @@ public class WikiEngine  {
     /**
      *  Does all the real initialization.
      */
-    private void initialize( Properties props )
-        throws WikiException
-    {
+    private void initialize( final Properties props ) throws WikiException {
         m_startTime  = new Date();
         m_properties = props;
 
@@ -446,18 +419,16 @@ public class WikiEngine  {
         //  the property jspwiki.use.external.logconfig=true, in that case we let log4j figure out the
         //  logging configuration.
         //
-        if( !c_configured )
-        {
-            String useExternalLogConfig = TextUtil.getStringProperty(props,"jspwiki.use.external.logconfig","false");
-            if( useExternalLogConfig == null || useExternalLogConfig.equals("false"))
-            {
+        if( !c_configured ) {
+            final String useExternalLogConfig = TextUtil.getStringProperty( props,"jspwiki.use.external.logconfig","false" );
+            if( useExternalLogConfig == null || useExternalLogConfig.equals( "false" ) ) {
                 PropertyConfigurator.configure( props );
             }
             c_configured = true;
         }
 
-        log.info("*******************************************");
-        log.info(Release.APPNAME+" "+Release.getVersionString()+" starting. Whee!");
+        log.info( "*******************************************" );
+        log.info( Release.APPNAME + " " + Release.getVersionString() + " starting. Whee!" );
 
         fireEvent( WikiEngineEvent.INITIALIZING ); // begin initialization
 
@@ -493,22 +464,30 @@ public class WikiEngine  {
         }
 
         try {
-            File f = new File( m_workDir );
+            final File f = new File( m_workDir );
             f.mkdirs();
 
             //
             //  A bunch of sanity checks
             //
-            if( !f.exists() ) throw new WikiException("Work directory does not exist: "+m_workDir);
-            if( !f.canRead() ) throw new WikiException("No permission to read work directory: "+m_workDir);
-            if( !f.canWrite() ) throw new WikiException("No permission to write to work directory: "+m_workDir);
-            if( !f.isDirectory() ) throw new WikiException("jspwiki.workDir does not point to a directory: "+m_workDir);
-        } catch( SecurityException e ) {
+            if( !f.exists() ) {
+                throw new WikiException("Work directory does not exist: "+m_workDir);
+            }
+            if( !f.canRead() ) {
+                throw new WikiException("No permission to read work directory: "+m_workDir);
+            }
+            if( !f.canWrite() ) {
+                throw new WikiException("No permission to write to work directory: "+m_workDir);
+            }
+            if( !f.isDirectory() ) {
+                throw new WikiException("jspwiki.workDir does not point to a directory: "+m_workDir);
+            }
+        } catch( final SecurityException e ) {
             log.fatal( "Unable to find or create the working directory: "+m_workDir, e );
             throw new IllegalArgumentException( "Unable to find or create the working dir: " + m_workDir, e );
         }
 
-        log.info("JSPWiki working directory is '"+m_workDir+"'");
+        log.info( "JSPWiki working directory is '" + m_workDir + "'" );
 
         m_saveUserInfo   = TextUtil.getBooleanProperty( props, PROP_STOREUSERNAME, m_saveUserInfo );
         m_useUTF8        = StandardCharsets.UTF_8.name().equals( TextUtil.getStringProperty( props, PROP_ENCODING, StandardCharsets.ISO_8859_1.name() ) );
@@ -524,11 +503,10 @@ 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
-        {
-            Class< ? > urlclass = ClassUtil.findClass( "org.apache.wiki.url",
-                                                       TextUtil.getStringProperty( props, PROP_URLCONSTRUCTOR, "DefaultURLConstructor" ) );
-            m_urlConstructor = (URLConstructor) urlclass.getDeclaredConstructor().newInstance();
+        try {
+            final Class< ? > urlclass = ClassUtil.findClass( "org.apache.wiki.url",
+                                                             TextUtil.getStringProperty( props, PROP_URLCONSTRUCTOR, "DefaultURLConstructor" ) );
+            m_urlConstructor = ( URLConstructor ) urlclass.getDeclaredConstructor().newInstance();
             m_urlConstructor.initialize( this, props );
 
             m_pageManager           = ClassUtil.getMappedObject( PageManager.class.getName(), this, props );
@@ -588,31 +566,20 @@ public class WikiEngine  {
             //
             m_filterManager.addPageFilter(m_referenceManager, -1001 );
             m_filterManager.addPageFilter(m_searchManager, -1002 );
-        }
-
-        catch( RuntimeException e )
-        {
+        } catch( final RuntimeException e ) {
             // RuntimeExceptions may occur here, even if they shouldn't.
             log.fatal( "Failed to start managers.", e );
             throw new WikiException( "Failed to start managers: " + e.getMessage(), e );
-        }
-        catch (ClassNotFoundException e)
-        {
+        } catch( final ClassNotFoundException e ) {
             log.fatal( "JSPWiki could not start, URLConstructor was not found: " + e.getMessage(), e );
-            throw new WikiException(e.getMessage(), e );
-        }
-        catch (InstantiationException e)
-        {
+            throw new WikiException( e.getMessage(), e );
+        } catch( final InstantiationException e ) {
             log.fatal( "JSPWiki could not start, URLConstructor could not be instantiated: " + e.getMessage(), e );
-            throw new WikiException(e.getMessage(), e );
-        }
-        catch (IllegalAccessException e)
-        {
+            throw new WikiException( e.getMessage(), e );
+        } catch( final IllegalAccessException e ) {
             log.fatal( "JSPWiki could not start, URLConstructor cannot be accessed: " + e.getMessage(), e );
-            throw new WikiException(e.getMessage(), e );
-        }
-        catch( Exception e )
-        {
+            throw new WikiException( e.getMessage(), e );
+        } 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() +
@@ -633,24 +600,16 @@ public class WikiEngine  {
         }
 
         // Start the RSS generator & generator thread
-        if( m_rssGenerator != null )
-        {
-            m_rssFile = TextUtil.getStringProperty( props,
-                    RSSGenerator.PROP_RSSFILE, "rss.rdf" );
-            File rssFile=null;
-            if (m_rssFile.startsWith(File.separator))
-            {
-                // honor absolute pathnames:
+        if( m_rssGenerator != null ) {
+            m_rssFile = TextUtil.getStringProperty( props, RSSGenerator.PROP_RSSFILE, "rss.rdf" );
+            final File rssFile;
+            if( m_rssFile.startsWith( File.separator ) ) { // honor absolute pathnames:
                 rssFile = new File(m_rssFile );
-            }
-            else
-            {
-                // relative path names are anchored from the webapp root path:
+            } else { // relative path names are anchored from the webapp root path:
                 rssFile = new File( getRootPath(), m_rssFile );
             }
-            int rssInterval = TextUtil.getIntegerProperty( props,
-                    RSSGenerator.PROP_INTERVAL, 3600 );
-            RSSThread rssThread = new RSSThread( this, rssFile, rssInterval );
+            final int rssInterval = TextUtil.getIntegerProperty( props, RSSGenerator.PROP_INTERVAL, 3600 );
+            final RSSThread rssThread = new RSSThread( this, rssFile, rssInterval );
             rssThread.start();
         }
 
@@ -675,9 +634,9 @@ public class WikiEngine  {
             boolean exists = new File( m_servletContext.getRealPath("/") + viewTemplate ).exists();
             if( !exists ) {
                 try {
-                    URL url = m_servletContext.getResource( viewTemplate );
+                    final URL url = m_servletContext.getResource( viewTemplate );
                     exists = url != null && StringUtils.isNotEmpty( url.getFile() );
-                } catch( MalformedURLException e ) {
+                } catch( final MalformedURLException e ) {
                     exists = false;
                 }
             }
@@ -696,7 +655,7 @@ public class WikiEngine  {
      */
     public void initReferenceManager() throws WikiException {
         try {
-            ArrayList<WikiPage> pages = new ArrayList<>();
+            final ArrayList<WikiPage> pages = new ArrayList<>();
             pages.addAll( m_pageManager.getAllPages() );
             pages.addAll( m_attachmentManager.getAllAttachments() );
 
@@ -706,9 +665,9 @@ public class WikiEngine  {
                 m_referenceManager.initialize( pages );
             }
 
-        } catch( ProviderException e ) {
+        } catch( final ProviderException e ) {
             log.fatal("PageProvider is unable to list pages: ", e);
-        } catch( ReflectiveOperationException | IllegalArgumentException e ) {
+        } catch( final ReflectiveOperationException | IllegalArgumentException e ) {
             throw new WikiException( "Could not instantiate ReferenceManager: " + e.getMessage(), e );
         }
     }
@@ -781,12 +740,10 @@ public class WikiEngine  {
 
     /**
      * <p>
-     * Returns the basic absolute URL to a page, without any modifications. You
-     * may add any parameters to this.
+     * 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.
+     * 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>
      * @since 2.0.3
      * @param pageName The name of the page.  May be null, in which case defaults to the front page.
@@ -846,9 +803,8 @@ public class WikiEngine  {
      *  @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);
+    public String getInterWikiURL( final String wikiName ) {
+        return TextUtil.getStringProperty( m_properties,PROP_INTERWIKIREF + wikiName,null );
     }
 
     /**
@@ -856,16 +812,11 @@ public class WikiEngine  {
      *
      *  @return A Collection of Strings.
      */
-    public Collection< String > getAllInterWikiLinks()
-    {
-        ArrayList< String > list = new ArrayList< >();
-
-        for( Enumeration< ? > i = m_properties.propertyNames(); i.hasMoreElements(); )
-        {
-            String prop = ( String )i.nextElement();
-
-            if( prop.startsWith( PROP_INTERWIKIREF ) )
-            {
+    public Collection< String > getAllInterWikiLinks() {
+        final ArrayList< String > list = new ArrayList< >();
+        for( final Enumeration< ? > i = m_properties.propertyNames(); i.hasMoreElements(); ) {
+            final String prop = ( String )i.nextElement();
+            if( prop.startsWith( PROP_INTERWIKIREF ) ) {
                 list.add( prop.substring( prop.lastIndexOf( "." ) + 1 ) );
             }
         }
@@ -878,25 +829,16 @@ public class WikiEngine  {
      *
      *  @return A Collection of Strings with a regexp pattern.
      */
-    public Collection< String > getAllInlinedImagePatterns()
-    {
-        Properties props    = getWikiProperties();
-        ArrayList<String>  ptrnlist = new ArrayList<>();
-
-        for( Enumeration< ? > e = props.propertyNames(); e.hasMoreElements(); )
-        {
-            String name = ( String )e.nextElement();
-
-            if( name.startsWith( PROP_INLINEIMAGEPTRN ) )
-            {
-                String ptrn = TextUtil.getStringProperty( props, name, null );
-
-                ptrnlist.add( ptrn );
+    public Collection< String > getAllInlinedImagePatterns() {
+        final ArrayList< String > ptrnlist = new ArrayList<>();
+        for( 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 ) );
             }
         }
 
-        if( ptrnlist.size() == 0 )
-        {
+        if( ptrnlist.size() == 0 ) {
             ptrnlist.add( DEFAULT_INLINEPATTERN );
         }
 
@@ -904,21 +846,18 @@ public class WikiEngine  {
     }
 
     /**
-     *  <p>If the page is a special page, then returns a direct URL
-     *  to that page.  Otherwise returns <code>null</code>.
-     *  This method delegates requests to
-     *  {@link org.apache.wiki.ui.CommandResolver#getSpecialPageReference(String)}.
+     *  <p>If the page is a special page, then returns a direct URL to that page.  Otherwise returns <code>null</code>.
+     *  This method delegates requests to {@link org.apache.wiki.ui.CommandResolver#getSpecialPageReference(String)}.
      *  </p>
      *  <p>
-     *  Special pages are defined in jspwiki.properties using the jspwiki.specialPage
-     *  setting.  They're typically used to give Wiki page names to e.g. custom JSP
-     *  pages.
+     *  Special pages are defined in jspwiki.properties using the jspwiki.specialPage setting.  They're typically used to give Wiki page
+     *  names to e.g. custom JSP pages.
      *  </p>
      *
      *  @param original The page to check
      *  @return A reference to the page, or null, if there's no special page.
      */
-    public String getSpecialPageReference( String original )
+    public String getSpecialPageReference( final String original )
     {
         return m_commandResolver.getSpecialPageReference( original );
     }
@@ -928,45 +867,31 @@ public class WikiEngine  {
      *
      *  @return A string describing the name of this application.
      */
-
     // FIXME: Should use servlet context as a default instead of a constant.
-    public String getApplicationName()
-    {
-        String appName = TextUtil.getStringProperty(m_properties,PROP_APPNAME,Release.APPNAME);
-
+    public String getApplicationName() {
+        String appName = TextUtil.getStringProperty( m_properties, PROP_APPNAME, Release.APPNAME );
         return MarkupParser.cleanLink( appName );
     }
 
     /**
-     *  Beautifies the title of the page by appending spaces in suitable
-     *  places, if the user has so decreed in the properties when constructing
-     *  this WikiEngine.  However, attachment names are only beautified by
-     *  the name.
+     *  Beautifies the title of the page by appending spaces in suitable places, if the user has so decreed in the properties when
+     *  constructing this WikiEngine.  However, attachment names are only beautified by the name.
      *
      *  @param title The title to beautify
-     *  @return A beautified title (or, if beautification is off,
-     *          returns the title without modification)
+     *  @return A beautified title (or, if beautification is off, returns the title without modification)
      *  @since 1.7.11
      */
-    public String beautifyTitle( String title )
-    {
-        if( m_beautifyTitle )
-        {
-            try
-            {
-                Attachment att = m_attachmentManager.getAttachmentInfo(title);
-
-                if(att == null)
-                {
+    public String beautifyTitle( final String title ) {
+        if( m_beautifyTitle ) {
+            try {
+                final Attachment att = m_attachmentManager.getAttachmentInfo( title );
+                if( att == null ) {
                     return TextUtil.beautifyString( title );
                 }
 
-                String parent = TextUtil.beautifyString( att.getParentName() );
-
+                final String parent = TextUtil.beautifyString( att.getParentName() );
                 return parent + "/" + att.getFileName();
-            }
-            catch( ProviderException e )
-            {
+            } catch( final ProviderException e ) {
                 return title;
             }
         }
@@ -1246,7 +1171,6 @@ public class WikiEngine  {
         return result;
     }
 
-
     /**
      *  Writes the WikiText of a page into the page repository. If the <code>jspwiki.properties</code> file contains
      *  the property <code>jspwiki.approver.workflow.saveWikiPage</code> and its value resolves to a valid user,
@@ -1568,18 +1492,13 @@ public class WikiEngine  {
      * @since 2.3
      * @return The current AclManager.
      */
-    public AclManager getAclManager()
-    {
-        if( m_aclManager == null )
-        {
-            try
-            {
-                String s = m_properties.getProperty( PROP_ACL_MANAGER_IMPL, ClassUtil.getMappedClass( AclManager.class.getName() ).getName() );
+    public AclManager getAclManager()  {
+        if( m_aclManager == null ) {
+            try {
+                final String s = m_properties.getProperty( PROP_ACL_MANAGER_IMPL, ClassUtil.getMappedClass( AclManager.class.getName() ).getName() );
                 m_aclManager = ClassUtil.getMappedObject(s); // TODO: I am not sure whether this is the right call
                 m_aclManager.initialize( this, m_properties );
-            }
-            catch ( ReflectiveOperationException | IllegalArgumentException e )
-            {
+            } catch( final ReflectiveOperationException | IllegalArgumentException e ) {
                 log.fatal( "unable to instantiate class for AclManager: " + e.getMessage() );
                 throw new InternalWikiException( "Cannot instantiate AclManager, please check logs.", e );
             }


[jspwiki] 31/32: apply format 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 2297125aa8a2d6cdbfaf1f9c5be89591ca0dcd8b
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 9 21:38:29 2020 +0100

    apply format and fixes suggested by IntelliJ
---
 .../main/java/org/apache/wiki/WikiProvider.java    |   3 +-
 .../src/main/java/org/apache/wiki/WikiServlet.java |  24 +-
 .../src/main/java/org/apache/wiki/WikiSession.java | 603 ++++++++-------------
 .../main/java/org/apache/wiki/plugin/Counter.java  |  66 +--
 4 files changed, 256 insertions(+), 440 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java
index d9e6f45..8e13402 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java
@@ -30,8 +30,7 @@ import java.util.Properties;
  *
  *  @since 2.0
  */
-public interface WikiProvider
-{
+public interface WikiProvider {
     /**
      *  Passing this to any method should get the latest version
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
index b8a405b..45c5f2f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
@@ -18,7 +18,9 @@
  */
 package org.apache.wiki;
 
-import java.io.IOException;
+import net.sf.ehcache.CacheManager;
+import org.apache.log4j.Logger;
+import org.apache.wiki.url.DefaultURLConstructor;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletConfig;
@@ -26,11 +28,7 @@ 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.url.DefaultURLConstructor;
-
-import net.sf.ehcache.CacheManager;
+import java.io.IOException;
 
 
 /**
@@ -44,13 +42,13 @@ public class WikiServlet extends HttpServlet {
 
     private static final long serialVersionUID = 3258410651167633973L;
     private WikiEngine m_engine;
-    static final Logger log = Logger.getLogger( WikiServlet.class.getName() );
+    private static final Logger log = Logger.getLogger( WikiServlet.class.getName() );
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public void init( ServletConfig config ) throws ServletException {
+    public void init( final ServletConfig config ) throws ServletException {
         super.init( config );
         m_engine = WikiEngine.getInstance( config );
         log.info( "WikiServlet initialized." );
@@ -77,7 +75,7 @@ public class WikiServlet extends HttpServlet {
      * {@inheritDoc}
      */
     @Override
-    public void doPost( HttpServletRequest req, HttpServletResponse res ) throws IOException, ServletException {
+    public void doPost( final HttpServletRequest req, final HttpServletResponse res ) throws IOException, ServletException {
         doGet( req, res );
     }
 
@@ -85,7 +83,7 @@ public class WikiServlet extends HttpServlet {
      * {@inheritDoc}
      */
     @Override
-    public void doGet( HttpServletRequest req, HttpServletResponse res ) throws IOException, ServletException {
+    public void doGet( final HttpServletRequest req, final HttpServletResponse res ) throws IOException, ServletException {
         String pageName = DefaultURLConstructor.parsePageFromURL( req, m_engine.getContentEncoding() );
 
         log.info( "Request for page: " + pageName );
@@ -93,9 +91,9 @@ public class WikiServlet extends HttpServlet {
             pageName = m_engine.getFrontPage(); // FIXME: Add special pages as well
         }
 
-        String jspPage = m_engine.getURLConstructor().getForwardPage( req );
-        RequestDispatcher dispatcher = req.getRequestDispatcher( "/" + jspPage + "?page=" +
-                                                                 m_engine.encodeName( pageName ) + "&" + req.getQueryString() );
+        final String jspPage = m_engine.getURLConstructor().getForwardPage( req );
+        final RequestDispatcher dispatcher = req.getRequestDispatcher( "/" + jspPage + "?page=" +
+                                                                       m_engine.encodeName( pageName ) + "&" + req.getQueryString() );
 
         dispatcher.forward( req, res );
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
index eb58b90..756260f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiSession.java
@@ -51,10 +51,9 @@ import java.util.Map;
 import java.util.Set;
 
 /**
- * <p>Represents a long-running wiki session, with an associated user Principal,
- * user Subject, and authentication status. This class is initialized with
- * minimal, default-deny values: authentication is set to <code>false</code>,
- * and the user principal is set to <code>null</code>.</p>
+ * <p>Represents a long-running wiki session, with an associated user Principal, user Subject, and authentication status. This class
+ * is initialized with minimal, default-deny values: authentication is set to <code>false</code>, and the user principal is set to
+ * <code>null</code>.</p>
  * <p>The WikiSession class allows callers to:</p>
  * <ul>
  *   <li>Obtain the authentication status of the user via
@@ -66,34 +65,23 @@ import java.util.Set;
  *     {@link #addMessage(String)}, {@link #getMessages(String)}
  *     and {@link #clearMessages(String)}</li>
  * </ul>
- * <p>To keep track of the Principals each user posseses, each WikiSession
- * stores a JAAS Subject. Various login processes add or remove Principals
- * when users authenticate or log out.</p>
- * <p>WikiSession implements the {@link org.apache.wiki.event.WikiEventListener}
- * interface and listens for group add/change/delete events fired by
- * event sources the WikiSession is registered with. Normally,
- * {@link org.apache.wiki.auth.AuthenticationManager} registers each WikiSession
- * with the {@link org.apache.wiki.auth.authorize.GroupManager}
- * so it can catch group events. Thus, when a user is added to a
- * {@link org.apache.wiki.auth.authorize.Group}, a corresponding
- * {@link org.apache.wiki.auth.GroupPrincipal} is injected into
- * the Subject's Principal set. Likewise, when the user is removed from
- * the Group or the Group is deleted, the GroupPrincipal is removed
- * from the Subject. The effect that this strategy produces is extremely
- * beneficial: when someone adds a user to a wiki group, that user
- * <em>immediately</em> gains the privileges associated with that
- * group; he or she does not need to re-authenticate.
+ * <p>To keep track of the Principals each user posseses, each WikiSession stores a JAAS Subject. Various login processes add or
+ * remove Principals when users authenticate or log out.</p>
+ * <p>WikiSession implements the {@link org.apache.wiki.event.WikiEventListener} interface and listens for group add/change/delete
+ * events fired by event sources the WikiSession is registered with. Normally, {@link org.apache.wiki.auth.AuthenticationManager}
+ * registers each WikiSession with the {@link org.apache.wiki.auth.authorize.GroupManager} so it can catch group events. Thus, when
+ * a user is added to a {@link org.apache.wiki.auth.authorize.Group}, a corresponding {@link org.apache.wiki.auth.GroupPrincipal} is
+ * injected into the Subject's Principal set. Likewise, when the user is removed from the Group or the Group is deleted, the
+ * GroupPrincipal is removed from the Subject. The effect that this strategy produces is extremely beneficial: when someone adds a user
+ * to a wiki group, that user <em>immediately</em> gains the privileges associated with that group; he or she does not need to
+ * re-authenticate.
  * </p>
- * <p>In addition to methods for examining individual <code>WikiSession</code>
- * objects, this class also contains a number of static methods for
- * managing WikiSessions for an entire wiki. These methods allow callers
- * to find, query and remove WikiSession objects, and
+ * <p>In addition to methods for examining individual <code>WikiSession</code> objects, this class also contains a number of static
+ * methods for managing WikiSessions for an entire wiki. These methods allow callers to find, query and remove WikiSession objects, and
  * to obtain a list of the current wiki session users.</p>
- * <p>WikiSession encloses a protected static class, {@link SessionMonitor},
- * to keep track of WikiSessions registered with each wiki.</p>
+ * <p>WikiSession encloses a protected static class, {@link SessionMonitor}, to keep track of WikiSessions registered with each wiki.</p>
  */
-public final class WikiSession implements WikiEventListener
-{
+public final class WikiSession implements WikiEventListener {
 
     /** An anonymous user's session status. */
     public static final String  ANONYMOUS             = "anonymous";
@@ -132,36 +120,31 @@ public final class WikiSession implements WikiEventListener
     private Locale              m_cachedLocale        = Locale.getDefault();
 
     /**
-     * Returns <code>true</code> if one of this WikiSession's user Principals
-     * can be shown to belong to a particular wiki group. If the user is
-     * not authenticated, this method will always return <code>false</code>.
+     * Returns <code>true</code> if one of this WikiSession's user Principals can be shown to belong to a particular wiki group. If
+     * the user is not authenticated, this method will always return <code>false</code>.
+     *
      * @param group the group to test
      * @return the result
      */
-    protected boolean isInGroup( Group group )
-    {
-        for ( Principal principal : getPrincipals() )
-        {
-          if ( isAuthenticated() && group.isMember( principal ) )
-          {
-              return true;
-          }
+    protected boolean isInGroup( final Group group ) {
+        for( final Principal principal : getPrincipals() ) {
+            if( isAuthenticated() && group.isMember( principal ) ) {
+                return true;
+            }
         }
         return false;
     }
 
     /**
-     * Private constructor to prevent WikiSession from being instantiated
-     * directly.
+     * Private constructor to prevent WikiSession from being instantiated directly.
      */
-    private WikiSession()
-    {
+    private WikiSession() {
     }
 
     /**
-     * Returns <code>true</code> if the user is considered asserted via
-     * a session cookie; that is, the Subject contains the Principal
+     * Returns <code>true</code> if the user is considered asserted via a session cookie; that is, the Subject contains the Principal
      * Role.ASSERTED.
+     *
      * @return Returns <code>true</code> if the user is asserted
      */
     public boolean isAsserted()
@@ -170,26 +153,20 @@ public final class WikiSession implements WikiEventListener
     }
 
     /**
-     * Returns the authentication status of the user's session. The user is
-     * considered authenticated if the Subject contains the Principal
-     * Role.AUTHENTICATED. If this method determines that an earlier
-     * LoginModule did not inject Role.AUTHENTICATED, it will inject one
-     * if the user is not anonymous <em>and</em> not asserted.
+     * Returns the authentication status of the user's session. The user is considered authenticated if the Subject contains the
+     * Principal Role.AUTHENTICATED. If this method determines that an earlier LoginModule did not inject Role.AUTHENTICATED, it
+     * will inject one if the user is not anonymous <em>and</em> not asserted.
+     *
      * @return Returns <code>true</code> if the user is authenticated
      */
-    public boolean isAuthenticated()
-    {
+    public boolean isAuthenticated() {
         // If Role.AUTHENTICATED is in principals set, always return true.
-        if ( m_subject.getPrincipals().contains( Role.AUTHENTICATED ) )
-        {
+        if ( m_subject.getPrincipals().contains( Role.AUTHENTICATED ) ) {
             return true;
         }
 
-        // With non-JSPWiki LoginModules, the role may not be there, so
-        // we need to add it if the user really is authenticated.
-        if ( !isAnonymous() && !isAsserted() )
-        {
-            // Inject AUTHENTICATED role
+        // With non-JSPWiki LoginModules, the role may not be there, so we need to add it if the user really is authenticated.
+        if ( !isAnonymous() && !isAsserted() ) {
             m_subject.getPrincipals().add( Role.AUTHENTICATED );
             return true;
         }
@@ -198,8 +175,7 @@ public final class WikiSession implements WikiEventListener
     }
 
     /**
-     * <p>Determines whether the current session is anonymous. This will be
-     * true if any of these conditions are true:</p>
+     * <p>Determines whether the current session is anonymous. This will be true if any of these conditions are true:</p>
      * <ul>
      *   <li>The session's Principal set contains
      *       {@link org.apache.wiki.auth.authorize.Role#ANONYMOUS}</li>
@@ -208,30 +184,24 @@ public final class WikiSession implements WikiEventListener
      *   <li>The Principal returned by {@link #getUserPrincipal()} evaluates
      *       to an IP address.</li>
      * </ul>
-     * <p>The criteria above are listed in the order in which they are
-     * evaluated.</p>
-     * @return whether the current user's identity is equivalent to an IP
-     * address
+     * <p>The criteria above are listed in the order in which they are evaluated.</p>
+     * @return whether the current user's identity is equivalent to an IP address
      */
-    public boolean isAnonymous()
-    {
-        Set<Principal> principals = m_subject.getPrincipals();
+    public boolean isAnonymous() {
+        final Set< Principal > principals = m_subject.getPrincipals();
         return principals.contains( Role.ANONYMOUS ) ||
-                 principals.contains( WikiPrincipal.GUEST ) ||
-                 isIPV4Address( getUserPrincipal().getName() );
+               principals.contains( WikiPrincipal.GUEST ) ||
+               isIPV4Address( getUserPrincipal().getName() );
     }
 
     /**
-     * <p> Returns the Principal used to log in to an authenticated session. The
-     * login principal is determined by examining the Subject's Principal set
-     * for PrincipalWrappers or WikiPrincipals with type designator
-     * <code>LOGIN_NAME</code>; the first one found is the login principal.
-     * If one is not found, this method returns the first principal that isn't
-     * of type Role or GroupPrincipal. If neither of these conditions hold, this method returns
-     * {@link org.apache.wiki.auth.WikiPrincipal#GUEST}.
-     * @return the login Principal. If it is a PrincipalWrapper containing an
-     * externally-provided Principal, the object returned is the Principal, not
-     * the wrapper around it.
+     * <p> Returns the Principal used to log in to an authenticated session. The login principal is determined by examining the
+     * Subject's Principal set for PrincipalWrappers or WikiPrincipals with type designator <code>LOGIN_NAME</code>; the first one
+     * found is the login principal. If one is not found, this method returns the first principal that isn't of type Role or
+     * GroupPrincipal. If neither of these conditions hold, this method returns {@link org.apache.wiki.auth.WikiPrincipal#GUEST}.
+     *
+     * @return the login Principal. If it is a PrincipalWrapper containing an externally-provided Principal, the object returned is the
+     * Principal, not the wrapper around it.
      */
     public Principal getLoginPrincipal()
     {
@@ -239,16 +209,15 @@ public final class WikiSession implements WikiEventListener
     }
 
     /**
-     * <p>Returns the primary user Principal associated with this session. The
-     * primary user principal is determined as follows:</p> <ol> <li>If the
-     * Subject's Principal set contains WikiPrincipals, the first WikiPrincipal
-     * with type designator <code>WIKI_NAME</code> or (alternatively)
-     * <code>FULL_NAME</code> is the primary Principal.</li>
-     *   <li>For all other cases, the first Principal in the Subject's principal
-     *       collection that that isn't of type Role or GroupPrincipal is the primary.</li>
+     * <p>Returns the primary user Principal associated with this session. The primary user principal is determined as follows:</p>
+     * <ol>
+     *     <li>If the Subject's Principal set contains WikiPrincipals, the first WikiPrincipal with type designator
+     *         <code>WIKI_NAME</code> or (alternatively) <code>FULL_NAME</code> is the primary Principal.</li>
+     *     <li>For all other cases, the first Principal in the Subject's principal collection that that isn't of type Role or
+     *         GroupPrincipal is the primary.</li>
      * </ol>
-     * If no primary user Principal is found, this method returns
-     * {@link org.apache.wiki.auth.WikiPrincipal#GUEST}.
+     * If no primary user Principal is found, this method returns {@link org.apache.wiki.auth.WikiPrincipal#GUEST}.
+     *
      * @return the primary user Principal
      */
     public Principal getUserPrincipal()
@@ -257,12 +226,10 @@ public final class WikiSession implements WikiEventListener
     }
 
     /**
-     *  Returns a cached Locale object for this user.  It's better to use
-     *  WikiContext's corresponding getBundle() method, since that will actually
-     *  react if the user changes the locale in the middle, but if that's not
-     *  available (or, for some reason, you need the speed), this method can
-     *  also be used.  The Locale expires when the WikiSession expires, and
-     *  currently there is no way to reset the Locale.
+     *  Returns a cached Locale object for this user.  It's better to use WikiContext's corresponding getBundle() method, since that
+     *  will actually react if the user changes the locale in the middle, but if that's not available (or, for some reason, you need
+     *  the speed), this method can also be used.  The Locale expires when the WikiSession expires, and currently there is no way to
+     *  reset the Locale.
      *
      *  @return A cached Locale object
      *  @since 2.5.96
@@ -273,36 +240,28 @@ public final class WikiSession implements WikiEventListener
     }
 
     /**
-     * Adds a message to the generic list of messages associated with the
-     * session. These messages retain their order of insertion and remain until
-     * the {@link #clearMessages()} method is called.
+     * Adds a message to the generic list of messages associated with the session. These messages retain their order of insertion and
+     * remain until the {@link #clearMessages()} method is called.
+     *
      * @param message the message to add; if <code>null</code> it is ignored.
      */
-    public void addMessage(String message)
+    public void addMessage( final String message )
     {
         addMessage( ALL, message );
     }
 
-
     /**
-     * Adds a message to the specific set of messages associated with the
-     * session. These messages retain their order of insertion and remain until
-     * the {@link #clearMessages()} method is called.
+     * Adds a message to the specific set of messages associated with the session. These messages retain their order of insertion and
+     * remain until the {@link #clearMessages()} method is called.
+     *
      * @param topic the topic to associate the message to;
      * @param message the message to add
      */
-    public void addMessage(String topic, String message)
-    {
-        if ( topic == null )
-        {
+    public void addMessage( final String topic, final String message ) {
+        if ( topic == null ) {
             throw new IllegalArgumentException( "addMessage: topic cannot be null." );
         }
-        Set<String> messages = m_messages.get( topic );
-        if (messages == null )
-        {
-            messages = new LinkedHashSet<>();
-            m_messages.put( topic, messages );
-        }
+        final Set< String > messages = m_messages.computeIfAbsent( topic, k -> new LinkedHashSet<>() );
         messages.add( StringUtils.defaultString( message ) );
     }
 
@@ -316,13 +275,12 @@ public final class WikiSession implements WikiEventListener
 
     /**
      * Clears all messages associated with a session topic.
+     *
      * @param topic the topic whose messages should be cleared.
      */
-    public void clearMessages( String topic )
-    {
-        Set<String> messages = m_messages.get( topic );
-        if ( messages != null )
-        {
+    public void clearMessages( final String topic ) {
+        final Set< String > messages = m_messages.get( topic );
+        if ( messages != null ) {
             m_messages.clear();
         }
     }
@@ -345,32 +303,27 @@ public final class WikiSession implements WikiEventListener
      * @return the current messages.
      * @param topic The topic
      */
-    public String[] getMessages( String topic )
-    {
-        Set<String> messages = m_messages.get( topic );
-        if ( messages == null || messages.size() == 0 )
-        {
+    public String[] getMessages( final String topic ) {
+        final Set< String > messages = m_messages.get( topic );
+        if( messages == null || messages.size() == 0 ) {
             return new String[0];
         }
         return messages.toArray( new String[messages.size()] );
     }
 
     /**
-     * Returns all user Principals associated with this session. User principals
-     * are those in the Subject's principal collection that aren't of type Role or
-     * of type GroupPrincipal. This is a defensive copy.
+     * Returns all user Principals associated with this session. User principals are those in the Subject's principal collection that
+     * aren't of type Role or of type GroupPrincipal. This is a defensive copy.
+     *
      * @return Returns the user principal
      * @see org.apache.wiki.auth.AuthenticationManager#isUserPrincipal(Principal)
      */
-    public Principal[] getPrincipals()
-    {
-        ArrayList<Principal> principals = new ArrayList<>();
+    public Principal[] getPrincipals() {
+        final ArrayList< Principal > principals = new ArrayList<>();
 
         // Take the first non Role as the main Principal
-        for( Principal principal : m_subject.getPrincipals() )
-        {
-            if ( AuthenticationManager.isUserPrincipal( principal ) )
-            {
+        for( final Principal principal : m_subject.getPrincipals() ) {
+            if ( AuthenticationManager.isUserPrincipal( principal ) ) {
                 principals.add( principal );
             }
         }
@@ -379,21 +332,16 @@ public final class WikiSession implements WikiEventListener
     }
 
     /**
-     * Returns an array of Principal objects that represents the groups and
-     * roles that the user associated with a WikiSession possesses. The array is
-     * built by iterating through the Subject's Principal set and extracting all
-     * Role and GroupPrincipal objects into a list. The list is returned as an
-     * array sorted in the natural order implied by each Principal's
-     * <code>getName</code> method. Note that this method does <em>not</em>
-     * consult the external Authorizer or GroupManager; it relies on the
-     * Principals that have been injected into the user's Subject at login time,
-     * or after group creation/modification/deletion.
-     * @return an array of Principal objects corresponding to the roles the
-     *         Subject possesses
+     * Returns an array of Principal objects that represents the groups and roles that the user associated with a WikiSession possesses.
+     * The array is built by iterating through the Subject's Principal set and extracting all Role and GroupPrincipal objects into a
+     * list. The list is returned as an array sorted in the natural order implied by each Principal's <code>getName</code> method. Note
+     * that this method does <em>not</em> consult the external Authorizer or GroupManager; it relies on the Principals that have been
+     * injected into the user's Subject at login time, or after group creation/modification/deletion.
+     *
+     * @return an array of Principal objects corresponding to the roles the Subject possesses
      */
-    public Principal[] getRoles()
-    {
-        Set<Principal> roles = new HashSet<>();
+    public Principal[] getRoles() {
+        final Set< Principal > roles = new HashSet<>();
 
         // Add all of the Roles possessed by the Subject directly
         roles.addAll( m_subject.getPrincipals( Role.class ) );
@@ -402,104 +350,79 @@ public final class WikiSession implements WikiEventListener
         roles.addAll( m_subject.getPrincipals( GroupPrincipal.class ) );
 
         // Return a defensive copy
-        Principal[] roleArray = roles.toArray( new Principal[roles.size()] );
+        final Principal[] roleArray = roles.toArray( new Principal[roles.size()] );
         Arrays.sort( roleArray, WikiPrincipal.COMPARATOR );
         return roleArray;
     }
 
     /**
-     * Removes the wiki session associated with the user's HTTP request
-     * from the cache of wiki sessions, typically as part of a logout
-     * process.
+     * Removes the wiki session associated with the user's HTTP request from the cache of wiki sessions, typically as part of a
+     * logout process.
+     *
      * @param engine the wiki engine
      * @param request the users's HTTP request
      */
-    public static void removeWikiSession( WikiEngine engine, HttpServletRequest request )
-    {
-        if ( engine == null || request == null )
-        {
+    public static void removeWikiSession( final WikiEngine engine, final HttpServletRequest request ) {
+        if ( engine == null || request == null ) {
             throw new IllegalArgumentException( "Request or engine cannot be null." );
         }
-        SessionMonitor monitor = SessionMonitor.getInstance( engine );
+        final SessionMonitor monitor = SessionMonitor.getInstance( engine );
         monitor.remove( request.getSession() );
     }
 
     /**
-     * Returns <code>true</code> if the WikiSession's Subject
-     * possess a supplied Principal. This method eliminates the need
-     * to externally request and inspect the JAAS subject.
+     * Returns <code>true</code> if the WikiSession's Subject possess a supplied Principal. This method eliminates the need to externally
+     * request and inspect the JAAS subject.
+     *
      * @param principal the Principal to test
      * @return the result
      */
-    public boolean hasPrincipal( Principal principal )
-    {
+    public boolean hasPrincipal( final Principal principal ) {
         return m_subject.getPrincipals().contains( principal );
-
     }
 
     /**
-     * Listens for WikiEvents generated by source objects such as the
-     * GroupManager. This method adds Principals to the private Subject managed
-     * by the WikiSession.
+     * Listens for WikiEvents generated by source objects such as the GroupManager. This method adds Principals to the private Subject
+     * managed by the WikiSession.
+     *
      * @see org.apache.wiki.event.WikiEventListener#actionPerformed(org.apache.wiki.event.WikiEvent)
      */
     @Override
-    public void actionPerformed( WikiEvent event )
-    {
-        if ( event instanceof WikiSecurityEvent )
-        {
-            WikiSecurityEvent e = (WikiSecurityEvent)event;
-            if ( e.getTarget() != null )
-            {
-                switch (e.getType() )
-                {
+    public void actionPerformed( final WikiEvent event ) {
+        if ( event instanceof WikiSecurityEvent ) {
+            final WikiSecurityEvent e = (WikiSecurityEvent)event;
+            if ( e.getTarget() != null ) {
+                switch (e.getType() ) {
                     case WikiSecurityEvent.GROUP_ADD:
-                    {
-                        Group group = (Group)e.getTarget();
-                        if ( isInGroup( group ) )
-                        {
-                            m_subject.getPrincipals().add( group.getPrincipal() );
+                        final Group groupAdd = (Group)e.getTarget();
+                        if ( isInGroup( groupAdd ) ) {
+                            m_subject.getPrincipals().add( groupAdd.getPrincipal() );
                         }
                         break;
-                    }
                     case WikiSecurityEvent.GROUP_REMOVE:
-                    {
-                        Group group = (Group)e.getTarget();
-                        if ( m_subject.getPrincipals().contains( group.getPrincipal() ) )
-                        {
-                            m_subject.getPrincipals().remove( group.getPrincipal() );
-                        }
+                        final Group group = (Group)e.getTarget();
+                        m_subject.getPrincipals().remove( group.getPrincipal() );
                         break;
-                    }
                     case WikiSecurityEvent.GROUP_CLEAR_GROUPS:
-                    {
                         m_subject.getPrincipals().removeAll( m_subject.getPrincipals( GroupPrincipal.class ) );
                         break;
-                    }
                     case WikiSecurityEvent.LOGIN_INITIATED:
-                    {
                         // Do nothing
                         break;
-                    }
                     case WikiSecurityEvent.PRINCIPAL_ADD:
-                    {
-                        WikiSession target = (WikiSession)e.getTarget();
-                        if ( this.equals( target ) && m_status.equals(AUTHENTICATED) )
-                        {
-                            Set<Principal> principals = m_subject.getPrincipals();
-                            principals.add( (Principal)e.getPrincipal());
+                        final WikiSession targetPA = (WikiSession)e.getTarget();
+                        if ( this.equals( targetPA ) && m_status.equals(AUTHENTICATED) ) {
+                            final Set<Principal> principals = m_subject.getPrincipals();
+                            principals.add( ( Principal )e.getPrincipal() );
                         }
                         break;
-                    }
                     case WikiSecurityEvent.LOGIN_ANONYMOUS:
-                    {
-                        WikiSession target = (WikiSession)e.getTarget();
-                        if ( this.equals( target ) )
-                        {
+                        final WikiSession targetLAN = (WikiSession)e.getTarget();
+                        if( this.equals( targetLAN ) ) {
                             m_status = ANONYMOUS;
 
                             // Set the login/user principals and login status
-                            Set<Principal> principals = m_subject.getPrincipals();
+                            final Set<Principal> principals = m_subject.getPrincipals();
                             m_loginPrincipal = (Principal)e.getPrincipal();
                             m_userPrincipal = m_loginPrincipal;
 
@@ -510,16 +433,13 @@ public final class WikiSession implements WikiEventListener
                             principals.add( Role.ANONYMOUS );
                         }
                         break;
-                    }
                     case WikiSecurityEvent.LOGIN_ASSERTED:
-                    {
-                        WikiSession target = (WikiSession)e.getTarget();
-                        if ( this.equals( target ) )
-                        {
+                        final WikiSession targetLAS = (WikiSession)e.getTarget();
+                        if ( this.equals( targetLAS ) ) {
                             m_status = ASSERTED;
 
                             // Set the login/user principals and login status
-                            Set<Principal> principals = m_subject.getPrincipals();
+                            final Set<Principal> principals = m_subject.getPrincipals();
                             m_loginPrincipal = (Principal)e.getPrincipal();
                             m_userPrincipal = m_loginPrincipal;
 
@@ -530,16 +450,13 @@ public final class WikiSession implements WikiEventListener
                             principals.add( Role.ASSERTED );
                         }
                         break;
-                    }
                     case WikiSecurityEvent.LOGIN_AUTHENTICATED:
-                    {
-                        WikiSession target = (WikiSession)e.getTarget();
-                        if ( this.equals( target ) )
-                        {
+                        final WikiSession targetLAU = (WikiSession)e.getTarget();
+                        if ( this.equals( targetLAU ) ) {
                             m_status = AUTHENTICATED;
 
                             // Set the login/user principals and login status
-                            Set<Principal> principals = m_subject.getPrincipals();
+                            final Set<Principal> principals = m_subject.getPrincipals();
                             m_loginPrincipal = (Principal)e.getPrincipal();
                             m_userPrincipal = m_loginPrincipal;
 
@@ -554,32 +471,25 @@ public final class WikiSession implements WikiEventListener
                             injectGroupPrincipals();  // Inject group principals
                         }
                         break;
-                    }
                     case WikiSecurityEvent.PROFILE_SAVE:
-                    {
-                        WikiSession source = e.getSrc();
-                        if ( this.equals( source ) )
-                        {
+                        final WikiSession sourcePS = e.getSrc();
+                        if ( this.equals( sourcePS ) ) {
                             injectUserProfilePrincipals();  // Add principals for the user profile
                             injectGroupPrincipals();  // Inject group principals
                         }
                         break;
-                    }
                     case WikiSecurityEvent.PROFILE_NAME_CHANGED:
-                    {
                         // Refresh user principals based on new user profile
-                        WikiSession source = e.getSrc();
-                        if ( this.equals( source ) && m_status.equals(AUTHENTICATED) )
-                        {
+                        final WikiSession sourcePNC = e.getSrc();
+                        if ( this.equals( sourcePNC ) && m_status.equals(AUTHENTICATED) ) {
                             // To prepare for refresh, set the new full name as the primary principal
-                            UserProfile[] profiles = (UserProfile[])e.getTarget();
-                            UserProfile newProfile = profiles[1];
-                            if ( newProfile.getFullname() == null )
-                            {
+                            final UserProfile[] profiles = (UserProfile[])e.getTarget();
+                            final UserProfile newProfile = profiles[1];
+                            if ( newProfile.getFullname() == null ) {
                                 throw new IllegalStateException( "User profile FullName cannot be null." );
                             }
 
-                            Set<Principal> principals = m_subject.getPrincipals();
+                            final Set<Principal> principals = m_subject.getPrincipals();
                             m_loginPrincipal = new WikiPrincipal( newProfile.getLoginName() );
 
                             // Add the login principal to the Subject, and set the built-in roles
@@ -593,24 +503,18 @@ public final class WikiSession implements WikiEventListener
                             injectGroupPrincipals();  // Inject group principals
                         }
                         break;
-                    }
 
-                    //
                     //  No action, if the event is not recognized.
-                    //
-                    default:
-                        break;
+                    default: break;
                 }
             }
         }
     }
 
     /**
-     * Invalidates the WikiSession and resets its Subject's
-     * Principals to the equivalent of a "guest session".
+     * Invalidates the WikiSession and resets its Subject's Principals to the equivalent of a "guest session".
      */
-    public void invalidate()
-    {
+    public void invalidate() {
         m_subject.getPrincipals().clear();
         m_subject.getPrincipals().add( WikiPrincipal.GUEST );
         m_subject.getPrincipals().add( Role.ANONYMOUS );
@@ -620,81 +524,62 @@ public final class WikiSession implements WikiEventListener
     }
 
     /**
-     * Injects GroupPrincipal objects into the user's Principal set based on the
-     * groups the user belongs to. For Groups, the algorithm first calls the
-     * {@link GroupManager#getRoles()} to obtain the array of GroupPrincipals
-     * the authorizer knows about. Then, the method
-     * {@link GroupManager#isUserInRole(WikiSession, Principal)} is called for
-     * each Principal. If the user is a member of the group, an equivalent
-     * GroupPrincipal is injected into the user's principal set. Existing
-     * GroupPrincipals are flushed and replaced. This method should generally be
-     * called after a user's {@link org.apache.wiki.auth.user.UserProfile} is
-     * saved. If the wiki session is null, or there is no matching user profile,
-     * the method returns silently.
+     * Injects GroupPrincipal objects into the user's Principal set based on the groups the user belongs to. For Groups, the algorithm
+     * first calls the {@link GroupManager#getRoles()} to obtain the array of GroupPrincipals the authorizer knows about. Then, the
+     * method {@link GroupManager#isUserInRole(WikiSession, Principal)} is called for each Principal. If the user is a member of the
+     * group, an equivalent GroupPrincipal is injected into the user's principal set. Existing GroupPrincipals are flushed and replaced.
+     * This method should generally be called after a user's {@link org.apache.wiki.auth.user.UserProfile} is saved. If the wiki session
+     * is null, or there is no matching user profile, the method returns silently.
      */
-    protected void injectGroupPrincipals()
-    {
+    protected void injectGroupPrincipals() {
         // Flush the existing GroupPrincipals
         m_subject.getPrincipals().removeAll( m_subject.getPrincipals(GroupPrincipal.class) );
 
         // Get the GroupManager and test for each Group
-        GroupManager manager = m_engine.getGroupManager();
-        for ( Principal group : manager.getRoles() )
-        {
-            if ( manager.isUserInRole( this, group ) )
-            {
+        final GroupManager manager = m_engine.getGroupManager();
+        for( final Principal group : manager.getRoles() ) {
+            if ( manager.isUserInRole( this, group ) ) {
                 m_subject.getPrincipals().add( group );
             }
         }
     }
 
     /**
-     * Adds Principal objects to the Subject that correspond to the
-     * logged-in user's profile attributes for the wiki name, full name
-     * and login name. These Principals will be WikiPrincipals, and they
-     * will replace all other WikiPrincipals in the Subject. <em>Note:
+     * Adds Principal objects to the Subject that correspond to the logged-in user's profile attributes for the wiki name, full name
+     * and login name. These Principals will be WikiPrincipals, and they will replace all other WikiPrincipals in the Subject. <em>Note:
      * this method is never called during anonymous or asserted sessions.</em>
      */
-    protected void injectUserProfilePrincipals()
-    {
+    protected void injectUserProfilePrincipals() {
         // Search for the user profile
-        String searchId = m_loginPrincipal.getName();
-        if ( searchId == null )
-        {
+        final String searchId = m_loginPrincipal.getName();
+        if ( searchId == null ) {
             // Oh dear, this wasn't an authenticated user after all
             log.info("Refresh principals failed because WikiSession had no user Principal; maybe not logged in?");
             return;
         }
 
         // Look up the user and go get the new Principals
-        UserDatabase database = m_engine.getUserManager().getUserDatabase();
-        if ( database == null )
-        {
+        final UserDatabase database = m_engine.getUserManager().getUserDatabase();
+        if( database == null ) {
             throw new IllegalStateException( "User database cannot be null." );
         }
-        try
-        {
-            UserProfile profile = database.find( searchId );
-            Principal[] principals = database.getPrincipals( profile.getLoginName() );
-            for ( Principal principal : principals )
-            {
+        try {
+            final UserProfile profile = database.find( searchId );
+            final Principal[] principals = database.getPrincipals( profile.getLoginName() );
+            for( final Principal principal : principals ) {
                 // Add the Principal to the Subject
                 m_subject.getPrincipals().add( principal );
 
                 // Set the user principal if needed; we prefer FullName, but the WikiName will also work
-                boolean isFullNamePrincipal = ( principal instanceof WikiPrincipal && ((WikiPrincipal)principal).getType() == WikiPrincipal.FULL_NAME );
-                if ( isFullNamePrincipal )
-                {
+                final boolean isFullNamePrincipal = ( principal instanceof WikiPrincipal &&
+                                                      ( ( WikiPrincipal )principal ).getType().equals( WikiPrincipal.FULL_NAME ) );
+                if ( isFullNamePrincipal ) {
                    m_userPrincipal = principal;
-                }
-                else if ( !( m_userPrincipal instanceof WikiPrincipal ) )
-                {
+                } else if ( !( m_userPrincipal instanceof WikiPrincipal ) ) {
                     m_userPrincipal = principal;
                 }
             }
-        }
-        catch ( NoSuchPrincipalException e )
-        {
+        } catch ( final NoSuchPrincipalException e ) {
             // We will get here if the user has a principal but not a profile
             // For example, it's a container-managed user who hasn't set up a profile yet
             log.warn("User profile '" + searchId + "' not found. This is normal for container-auth users who haven't set up a profile yet.");
@@ -710,70 +595,59 @@ public final class WikiSession implements WikiEventListener
      * </ul>
      * @return the user's session status
      */
-    public String getStatus()
-    {
+    public String getStatus() {
         return m_status;
     }
 
     /**
-     * <p>Static factory method that returns the WikiSession object associated with
-     * the current HTTP request. This method looks up the associated HttpSession
-     * in an internal WeakHashMap and attempts to retrieve the WikiSession. If
-     * not found, one is created. This method is guaranteed to always return a
-     * WikiSession, although the authentication status is unpredictable until
-     * the user attempts to log in. If the servlet request parameter is
-     * <code>null</code>, a synthetic {@link #guestSession(WikiEngine)}is returned.</p>
-     * <p>When a session is created, this method attaches a WikiEventListener
-     * to the GroupManager so that changes to groups are detected automatically.</p>
+     * <p>Static factory method that returns the WikiSession object associated with the current HTTP request. This method looks up
+     * the associated HttpSession in an internal WeakHashMap and attempts to retrieve the WikiSession. If not found, one is created.
+     * This method is guaranteed to always return a WikiSession, although the authentication status is unpredictable until the user
+     * attempts to log in. If the servlet request parameter is <code>null</code>, a synthetic {@link #guestSession(WikiEngine)} is
+     * returned.</p>
+     * <p>When a session is created, this method attaches a WikiEventListener to the GroupManager so that changes to groups are detected
+     * automatically.</p>
+     *
      * @param engine the wiki engine
      * @param request the servlet request object
      * @return the existing (or newly created) wiki session
      */
-    public static WikiSession getWikiSession( WikiEngine engine, HttpServletRequest request )
-    {
-        // If request is null, return guest session
-        if ( request == null )
-        {
-            if ( log.isDebugEnabled() )
-            {
+    public static WikiSession getWikiSession( final WikiEngine engine, final HttpServletRequest request ) {
+        if ( request == null ) {
+            if ( log.isDebugEnabled() ) {
                 log.debug( "Looking up WikiSession for NULL HttpRequest: returning guestSession()" );
             }
             return staticGuestSession( engine );
         }
 
-        // Look for a WikiSession associated with the user's Http Session
-        // and create one if it isn't there yet.
-        HttpSession session = request.getSession();
-        SessionMonitor monitor = SessionMonitor.getInstance( engine );
-        WikiSession wikiSession = monitor.find( session );
+        // Look for a WikiSession associated with the user's Http Session and create one if it isn't there yet.
+        final HttpSession session = request.getSession();
+        final SessionMonitor monitor = SessionMonitor.getInstance( engine );
+        final WikiSession wikiSession = monitor.find( session );
 
         // Attach reference to wiki engine
         wikiSession.m_engine = engine;
-
         wikiSession.m_cachedLocale = request.getLocale();
-
         return wikiSession;
     }
 
     /**
-     * Static factory method that creates a new "guest" session containing a single
-     * user Principal {@link org.apache.wiki.auth.WikiPrincipal#GUEST},
-     * plus the role principals {@link Role#ALL} and
-     * {@link Role#ANONYMOUS}. This method also adds the session as a listener
-     * for GroupManager, AuthenticationManager and UserManager events.
+     * Static factory method that creates a new "guest" session containing a single user Principal
+     * {@link org.apache.wiki.auth.WikiPrincipal#GUEST}, plus the role principals {@link Role#ALL} and {@link Role#ANONYMOUS}. This
+     * method also adds the session as a listener for GroupManager, AuthenticationManager and UserManager events.
+     *
      * @param engine the wiki engine
      * @return the guest wiki session
      */
-    public static WikiSession guestSession( WikiEngine engine )
-    {
-        WikiSession session = new WikiSession();
+    public static WikiSession guestSession( final WikiEngine engine ) {
+        final WikiSession session = new WikiSession();
         session.m_engine = engine;
         session.invalidate();
 
         // Add the session as listener for GroupManager, AuthManager, UserManager events
-        GroupManager groupMgr = engine.getGroupManager();
-        AuthenticationManager authMgr = engine.getAuthenticationManager();
-        UserManager userMgr = engine.getUserManager();
+        final GroupManager groupMgr = engine.getGroupManager();
+        final AuthenticationManager authMgr = engine.getAuthenticationManager();
+        final UserManager userMgr = engine.getUserManager();
         groupMgr.addWikiEventListener( session );
         authMgr.addWikiEventListener( session );
         userMgr.addWikiEventListener( session );
@@ -782,25 +656,17 @@ public final class WikiSession implements WikiEventListener
     }
 
     /**
-     *  Returns a static guest session, which is available for this
-     *  thread only.  This guest session is used internally whenever
-     *  there is no HttpServletRequest involved, but the request is
-     *  done e.g. when embedding JSPWiki code.
+     *  Returns a static guest session, which is available for this thread only.  This guest session is used internally whenever
+     *  there is no HttpServletRequest involved, but the request is done e.g. when embedding JSPWiki code.
      *
      *  @param engine WikiEngine for this session
-     *  @return A static WikiSession which is shared by all in this
-     *          same Thread.
+     *  @return A static WikiSession which is shared by all in this same Thread.
      */
     // FIXME: Should really use WeakReferences to clean away unused sessions.
-
-    private static WikiSession staticGuestSession( WikiEngine engine )
-    {
+    private static WikiSession staticGuestSession( final WikiEngine engine ) {
         WikiSession session = c_guestSession.get();
-
-        if( session == null )
-        {
+        if( session == null ) {
             session = guestSession( engine );
-
             c_guestSession.set( session );
         }
 
@@ -808,47 +674,42 @@ public final class WikiSession implements WikiEventListener
     }
 
     /**
-     * Returns the total number of active wiki sessions for a
-     * particular wiki. This method delegates to the wiki's
+     * Returns the total number of active wiki sessions for a particular wiki. This method delegates to the wiki's
      * {@link SessionMonitor#sessions()} method.
+     *
      * @param engine the wiki session
      * @return the number of sessions
      */
-    public static int sessions( WikiEngine engine )
-    {
-        SessionMonitor monitor = SessionMonitor.getInstance( engine );
+    public static int sessions( final WikiEngine engine ) {
+        final SessionMonitor monitor = SessionMonitor.getInstance( engine );
         return monitor.sessions();
     }
 
     /**
-     * Returns Principals representing the current users known
-     * to a particular wiki. Each Principal will correspond to the
-     * value returned by each WikiSession's {@link #getUserPrincipal()}
-     * method. This method delegates to {@link SessionMonitor#userPrincipals()}.
+     * Returns Principals representing the current users known to a particular wiki. Each Principal will correspond to the
+     * value returned by each WikiSession's {@link #getUserPrincipal()} method. This method delegates to
+     * {@link SessionMonitor#userPrincipals()}.
+     *
      * @param engine the wiki engine
      * @return an array of Principal objects, sorted by name
      */
-    public static Principal[] userPrincipals( WikiEngine engine )
-    {
-        SessionMonitor monitor = SessionMonitor.getInstance( engine );
+    public static Principal[] userPrincipals( final WikiEngine engine ) {
+        final SessionMonitor monitor = SessionMonitor.getInstance( engine );
         return monitor.userPrincipals();
     }
 
     /**
      * Wrapper for
      * {@link javax.security.auth.Subject#doAsPrivileged(Subject, java.security.PrivilegedExceptionAction, java.security.AccessControlContext)}
-     * that executes an action with the privileges posssessed by a
-     * WikiSession's Subject. The action executes with a <code>null</code>
-     * AccessControlContext, which has the effect of running it "cleanly"
-     * without the AccessControlContexts of the caller.
+     * that executes an action with the privileges posssessed by a WikiSession's Subject. The action executes with a <code>null</code>
+     * AccessControlContext, which has the effect of running it "cleanly" without the AccessControlContexts of the caller.
+     *
      * @param session the wiki session
      * @param action the privileged action
      * @return the result of the privileged action; may be <code>null</code>
-     * @throws java.security.AccessControlException if the action is not permitted
-     * by the security policy
+     * @throws java.security.AccessControlException if the action is not permitted by the security policy
      */
-    public static Object doPrivileged( WikiSession session, PrivilegedAction<?> action ) throws AccessControlException
-    {
+    public static Object doPrivileged( final WikiSession session, final PrivilegedAction<?> action ) throws AccessControlException {
         return Subject.doAsPrivileged( session.m_subject, action, null );
     }
 
@@ -858,39 +719,29 @@ public final class WikiSession implements WikiEventListener
      * @param name the address to test
      * @return the result
      */
-    protected static boolean isIPV4Address( String name )
-    {
-        if ( name.charAt( 0 ) == DOT || name.charAt( name.length() - 1 ) == DOT )
-        {
+    protected static boolean isIPV4Address( final String name ) {
+        if ( name.charAt( 0 ) == DOT || name.charAt( name.length() - 1 ) == DOT ) {
             return false;
         }
 
-        int[] addr = new int[]
+        final int[] addr = new int[]
         { 0, 0, 0, 0 };
         int currentOctet = 0;
-        for( int i = 0; i < name.length(); i++ )
-        {
-            int ch = name.charAt( i );
-            boolean isDigit = ch >= ONE && ch <= NINE;
-            boolean isDot = ch == DOT;
-            if ( !isDigit && !isDot )
-            {
+        for( int i = 0; i < name.length(); i++ ) {
+            final int ch = name.charAt( i );
+            final boolean isDigit = ch >= ONE && ch <= NINE;
+            final boolean isDot = ch == DOT;
+            if ( !isDigit && !isDot ) {
                 return false;
             }
-            if ( isDigit )
-            {
+            if( isDigit ) {
                 addr[currentOctet] = 10 * addr[currentOctet] + ( ch - ONE );
-                if ( addr[currentOctet] > 255 )
-                {
+                if ( addr[currentOctet] > 255 ) {
                     return false;
                 }
-            }
-            else if ( name.charAt( i - 1 ) == DOT )
-            {
+            } else if( name.charAt( i - 1 ) == DOT ) {
                 return false;
-            }
-            else
-            {
+            } else {
                 currentOctet++;
             }
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Counter.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Counter.java
index 8258560..44a8ad7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/Counter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/Counter.java
@@ -18,13 +18,13 @@
  */
 package org.apache.wiki.plugin;
 
-import java.util.Map;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.util.TextUtil;
 
+import java.util.Map;
+
 /**
  *  Provides a page-specific counter, it is reset every time a page is rendered, so it is not usable as a hitcounter.
  *  <br>Stores a variable in the WikiContext called "counter", with the name of the optionally specified variable "name".  
@@ -39,9 +39,7 @@ import org.apache.wiki.util.TextUtil;
  *
  *  @since 1.9.30
  */
-public class Counter
-    implements WikiPlugin
-{
+public class Counter implements WikiPlugin {
     // private static Logger log = Logger.getLogger( Counter.class );
 
     /** Parameter name for setting the name.  Value is <tt>{@value}</tt>. */
@@ -59,56 +57,32 @@ public class Counter
     /**
      *  {@inheritDoc}
      */
-    public String execute( WikiContext context, Map<String, String> params )
-        throws PluginException
-    {
-        //
-        //  First, determine which kind of name we use to store in
-        //  the WikiContext.
-        //
+    public String execute( final WikiContext context, final Map< String, String > params ) throws PluginException {
+        //  First, determine which kind of name we use to store in the WikiContext.
         String  countername = params.get(  PARAM_NAME);
 
-        if( countername == null ) 
-        {
+        if( countername == null ) {
             countername = DEFAULT_NAME;
-        }
-        else
-        {
+        } else {
             countername = DEFAULT_NAME+"-"+countername;
         }
 
-        //
         //  Fetch the old value
-        //
         Integer val = (Integer)context.getVariable( countername );
-
-        if( val == null )
-        {
+        if( val == null ) {
             val = 0;
         }
         
-        //
         //  Check if we need to reset this
-        //
-        
-        String start = params.get( PARAM_START );
-        
-        if( start != null )
-        {
+        final String start = params.get( PARAM_START );
+        if( start != null ) {
             val = Integer.parseInt( start );
-        }
-        else
-        {
-            //
+        } else {
             //  Determine how much to increment
-            //
-            String incrementObj = params.get( PARAM_INCREMENT );
-        
+            final String incrementObj = params.get( PARAM_INCREMENT );
             int increment = DEFAULT_INCREMENT;
-        
-            if (incrementObj != null) 
-            {
-                increment = ( Integer.valueOf( incrementObj ) ).intValue();
+            if( incrementObj != null ) {
+                increment = Integer.parseInt( incrementObj );
             }
 
             val = val + increment;
@@ -116,20 +90,14 @@ public class Counter
         
         context.setVariable( countername, val );
 
-        //
         // check if we want to hide the result (just count, don't show result on the page
-        //
-        String showObj = params.get(PARAM_SHOW_RESULT);
-        
+        final String showObj = params.get(PARAM_SHOW_RESULT);
         boolean show = DEFAULT_SHOW_RESULT;
-        
-        if( showObj != null ) 
-        {
+        if( showObj != null ) {
             show = TextUtil.isPositive( showObj );
         }
         
-        if( show )
-        {
+        if( show ) {
             return val.toString();
         } 
        


[jspwiki] 13/32: JSPWIKI-120: use getPureText from PageManager

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 49325691ddd4996e5fc9499bbaef060994b04010
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Jan 5 00:57:31 2020 +0100

    JSPWIKI-120: use getPureText from PageManager
---
 jspwiki-war/src/main/webapp/Comment.jsp                            | 2 +-
 jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp     | 4 ++--
 jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp          | 4 ++--
 jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp      | 4 ++--
 jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp        | 4 ++--
 jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp      | 4 ++--
 jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp | 4 ++--
 jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp  | 4 ++--
 jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp    | 4 ++--
 jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp  | 4 ++--
 10 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/jspwiki-war/src/main/webapp/Comment.jsp b/jspwiki-war/src/main/webapp/Comment.jsp
index 5b998a9..d1b90a1 100644
--- a/jspwiki-war/src/main/webapp/Comment.jsp
+++ b/jspwiki-war/src/main/webapp/Comment.jsp
@@ -181,7 +181,7 @@
         //  Build comment part
         //
 
-        StringBuffer pageText = new StringBuffer(wiki.getPureText( wikipage ));
+        StringBuffer pageText = new StringBuffer(wiki.getPageManager().getPureText( wikipage ));
 
         log.debug("Page initial contents are "+pageText.length()+" chars");
 
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp
index a99e778..71bdce9 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp
@@ -76,7 +76,7 @@
         {
           if( mgr.checkPermission( context.getWikiSession(), pp ) )
           {
-            usertext = engine.getPureText( p );
+            usertext = engine.getPageManager().getPureText( p );
           }
         }
         catch( Exception e ) {  /*log.error( "Accessing clone page "+clone, e );*/ }
@@ -87,7 +87,7 @@
 <%
   if( usertext == null )
   {
-    usertext = engine.getPureText( context.getPage() );
+    usertext = engine.getPageManager().getPureText( context.getPage() );
   }
 %>
 </wiki:CheckRequestContext>
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp
index 16e33a0..4d5ca8d 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp
@@ -65,7 +65,7 @@
         {
           if( mgr.checkPermission( context.getWikiSession(), pp ) )
           {
-            usertext = engine.getPureText( p );
+            usertext = engine.getPageManager().getPureText( p );
           }
         }
         catch( Exception e ) {  /*log.error( "Accessing clone page "+clone, e );*/ }
@@ -76,7 +76,7 @@
 <%
     if( usertext == null )
     {
-        usertext = engine.getPureText( context.getPage() );
+        usertext = engine.getPageManager().getPureText( context.getPage() );
     }%>
 </wiki:CheckRequestContext>
 <% if( usertext == null ) usertext = "";
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp
index 0073bbb..1ce9593 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp
@@ -76,7 +76,7 @@
         {
           if( mgr.checkPermission( context.getWikiSession(), pp ) )
           {
-            usertext = engine.getPureText( p );
+            usertext = engine.getPageManager().getPureText( p );
           }
         }
         catch( Exception e ) {  /*log.error( "Accessing clone page "+clone, e );*/ }
@@ -87,7 +87,7 @@
 <%
   if( usertext == null )
   {
-    usertext = engine.getPureText( context.getPage() );
+    usertext = engine.getPageManager().getPureText( context.getPage() );
   }
 %>
 </wiki:CheckRequestContext>
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp
index 22c1c34..7b8b7cb 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp
@@ -58,7 +58,7 @@
         {
           if( mgr.checkPermission( context.getWikiSession(), pp ) )
           {
-            usertext = engine.getPureText( p );
+            usertext = engine.getPageManager().getPureText( p );
           }
         }
         catch( Exception e ) {  /*log.error( "Accessing clone page "+clone, e );*/ }
@@ -69,7 +69,7 @@
 <%
   if( usertext == null )
   {
-    usertext = engine.getPureText( context.getPage() );
+    usertext = engine.getPageManager().getPureText( context.getPage() );
   }
 %>
 </wiki:CheckRequestContext>
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp
index 3bc866c..3eeba15 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp
@@ -58,7 +58,7 @@
         {
           if( mgr.checkPermission( context.getWikiSession(), pp ) )
           {
-            usertext = engine.getPureText( p );
+            usertext = engine.getPageManager().getPureText( p );
           }
         }
         catch( Exception e ) {  /*log.error( "Accessing clone page "+clone, e );*/ }
@@ -69,7 +69,7 @@
 <%
   if( usertext == null )
   {
-    usertext = engine.getPureText( context.getPage() );
+    usertext = engine.getPageManager().getPureText( context.getPage() );
   }
 %>
 </wiki:CheckRequestContext>
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
index c3c60e2..081e5cd 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
@@ -78,7 +78,7 @@
         {
           if( mgr.checkPermission( context.getWikiSession(), pp ) )
           {
-            usertext = engine.getPureText( p );
+            usertext = engine.getPageManager().getPureText( p );
           }
         }
         catch( Exception e ) {  /*log.error( "Accessing clone page "+clone, e );*/ }
@@ -89,7 +89,7 @@
 <%
   if( usertext == null )
   {
-    usertext = engine.getPureText( context.getPage() );
+    usertext = engine.getPageManager().getPureText( context.getPage() );
   }
 %>
 </wiki:CheckRequestContext>
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
index 2acd953..2965c13 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
@@ -76,7 +76,7 @@
         {
           if( mgr.checkPermission( context.getWikiSession(), pp ) )
           {
-            usertext = engine.getPureText( p );
+            usertext = engine.getPageManager().getPureText( p );
           }
         }
         catch( Exception e ) {  /*log.error( "Accessing clone page "+clone, e );*/ }
@@ -87,7 +87,7 @@
 <%
   if( usertext == null )
   {
-    usertext = engine.getPureText( context.getPage() );
+    usertext = engine.getPageManager().getPureText( context.getPage() );
   }
 %>
 </wiki:CheckRequestContext>
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp
index bc657a6..d91cedb 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp
@@ -58,7 +58,7 @@
         {
           if( mgr.checkPermission( context.getWikiSession(), pp ) )
           {
-            usertext = engine.getPureText( p );
+            usertext = engine.getPageManager().getPureText( p );
           }
         }
         catch( Exception e ) {  /*log.error( "Accessing clone page "+clone, e );*/ }
@@ -69,7 +69,7 @@
 <%
   if( usertext == null )
   {
-    usertext = engine.getPureText( context.getPage() );
+    usertext = engine.getPageManager().getPureText( context.getPage() );
   }
 %>
 </wiki:CheckRequestContext>
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp
index 6c62d9a..ba2e504 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp
@@ -70,7 +70,7 @@
         {
           if( mgr.checkPermission( context.getWikiSession(), pp ) )
           {
-            usertext = engine.getPureText( p );
+            usertext = engine.getPageManager().getPureText( p );
           }
         }
         catch( Exception e ) {  /*log.error( "Accessing clone page "+clone, e );*/ }
@@ -81,7 +81,7 @@
 <%
   if( usertext == null )
   {
-    usertext = engine.getPureText( context.getPage() );
+    usertext = engine.getPageManager().getPureText( context.getPage() );
   }
 %>
 </wiki:CheckRequestContext>


[jspwiki] 28/32: fix test compilation error

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 bdcfef8485c2e364e488cd5e318e8ffb1a3b98bd
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 9 00:29:23 2020 +0100

    fix test compilation error
---
 .../src/test/java/org/apache/wiki/workflow/WorkflowTest.java   | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowTest.java
index 7e7c516..7b9850d 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowTest.java
@@ -18,10 +18,6 @@
  */
 package org.apache.wiki.workflow;
 
-import java.math.BigDecimal;
-import java.security.Principal;
-import java.util.Date;
-
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.auth.GroupPrincipal;
 import org.apache.wiki.auth.WikiPrincipal;
@@ -29,6 +25,10 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.math.BigDecimal;
+import java.security.Principal;
+import java.util.Date;
+
 public class WorkflowTest
 {
     Workflow w;
@@ -87,7 +87,7 @@ public class WorkflowTest
     public void testSetWorkflowManager()
     {
         Assertions.assertNull(w.getWorkflowManager());
-        WorkflowManager m = new WorkflowManager();
+        WorkflowManager m = new DefaultWorkflowManager();
         w.setWorkflowManager(m);
         Assertions.assertEquals(m, w.getWorkflowManager());
     }


[jspwiki] 07/32: JSPWIKI-120: getPage( String ) and getPage( String, int ) methods from WikiEngine moved to PageManager

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 94d45984877d3cdee9c629690fdcdf8e1fcfb757
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 4 01:50:11 2020 +0100

    JSPWIKI-120: getPage( String ) and getPage( String, int ) methods from WikiEngine moved to PageManager
---
 .../src/main/java/org/apache/wiki/WikiContext.java |  45 ++-
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  49 +---
 .../apache/wiki/attachment/AttachmentManager.java  |  38 +--
 .../org/apache/wiki/auth/AuthorizationManager.java |   2 +-
 .../apache/wiki/auth/acl/DefaultAclManager.java    |  36 +--
 .../apache/wiki/content/DefaultPageRenamer.java    |  12 +-
 .../java/org/apache/wiki/filters/SpamFilter.java   |  29 +-
 .../org/apache/wiki/pages/DefaultPageManager.java  |  31 +-
 .../java/org/apache/wiki/pages/PageManager.java    |  25 +-
 .../apache/wiki/plugin/AbstractReferralPlugin.java |   2 +-
 .../java/org/apache/wiki/plugin/InsertPage.java    |  36 +--
 .../apache/wiki/plugin/ReferringPagesPlugin.java   |   2 +-
 .../java/org/apache/wiki/plugin/WeblogPlugin.java  |   2 +-
 .../wiki/references/DefaultReferenceManager.java   |   2 +-
 .../org/apache/wiki/rpc/atom/AtomAPIServlet.java   |  27 +-
 .../apache/wiki/search/LuceneSearchProvider.java   |   2 +-
 .../java/org/apache/wiki/search/SearchManager.java |  37 +--
 .../java/org/apache/wiki/tags/CheckVersionTag.java |   6 +-
 .../java/org/apache/wiki/tags/DiffLinkTag.java     | 103 +++----
 .../java/org/apache/wiki/tags/EditLinkTag.java     |   8 +-
 .../java/org/apache/wiki/tags/InsertDiffTag.java   |   2 +-
 .../java/org/apache/wiki/tags/InsertPageTag.java   |  51 ++--
 .../main/java/org/apache/wiki/tags/LinkTag.java    |  27 +-
 .../java/org/apache/wiki/tags/NoSuchPageTag.java   |  37 +--
 .../java/org/apache/wiki/tags/PermissionTag.java   | 103 +++----
 .../apache/wiki/tasks/pages/SaveWikiPageTask.java  |   2 +-
 .../java/org/apache/wiki/ui/CommandResolver.java   |   2 +-
 .../org/apache/wiki/xmlrpc/MetaWeblogHandler.java  |  30 +-
 .../java/org/apache/wiki/xmlrpc/RPCHandler.java    |  24 +-
 .../org/apache/wiki/xmlrpc/RPCHandlerUTF8.java     |  22 +-
 .../src/test/java/org/apache/wiki/TestEngine.java  |  90 +++---
 .../test/java/org/apache/wiki/WikiEngineTest.java  | 312 ++-------------------
 .../apache/wiki/auth/AuthorizationManagerTest.java |   8 +-
 .../java/org/apache/wiki/auth/UserManagerTest.java |   8 +-
 .../wiki/auth/acl/DefaultAclManagerTest.java       |  33 +--
 .../org/apache/wiki/content/PageRenamerTest.java   |  26 +-
 .../apache/wiki/pages/DefaultPageManagerTest.java  | 214 ++++++++++++--
 .../java/org/apache/wiki/plugin/IfPluginTest.java  |   8 +-
 .../org/apache/wiki/plugin/PageViewPluginTest.java |  33 ++-
 .../apache/wiki/providers/CachingProviderTest.java |  28 +-
 .../wiki/providers/VersioningFileProviderTest.java |  83 +++---
 .../apache/wiki/render/RenderingManagerTest.java   |   4 +-
 .../java/org/apache/wiki/rss/RSSGeneratorTest.java |  29 +-
 .../wiki/stress/StressTestVersioningProvider.java  |  24 +-
 .../org/apache/wiki/ui/CommandResolverTest.java    |   2 +-
 .../java/org/apache/wiki/ui/PageCommandTest.java   |   2 +-
 .../org/apache/wiki/xmlrpc/RPCHandlerTest.java     |  19 +-
 .../apache/wiki/render/MarkdownRendererTest.java   |  19 +-
 jspwiki-war/src/main/webapp/Comment.jsp            |   2 +-
 jspwiki-war/src/main/webapp/Delete.jsp             |   8 +-
 jspwiki-war/src/main/webapp/Edit.jsp               |   2 +-
 .../src/main/webapp/templates/210/InfoContent.jsp  |   2 +-
 .../src/main/webapp/templates/210/PageTab.jsp      |   2 +-
 .../main/webapp/templates/210/editors/CKeditor.jsp |   2 +-
 .../src/main/webapp/templates/210/editors/FCK.jsp  |   2 +-
 .../main/webapp/templates/210/editors/TinyMCE.jsp  |   2 +-
 .../main/webapp/templates/210/editors/plain.jsp    |   2 +-
 .../main/webapp/templates/210/editors/wysiwyg.jsp  |   2 +-
 .../main/webapp/templates/default/InfoContent.jsp  |   2 +-
 .../src/main/webapp/templates/default/PageTab.jsp  |   2 +-
 .../webapp/templates/default/editors/CKeditor.jsp  |   2 +-
 .../webapp/templates/default/editors/TinyMCE.jsp   |   2 +-
 .../webapp/templates/default/editors/plain.jsp     |   2 +-
 .../webapp/templates/default/editors/wysiwyg.jsp   |   2 +-
 64 files changed, 734 insertions(+), 1040 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 7a3029a..4b33cf3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -181,27 +181,19 @@ public class WikiContext implements Cloneable, Command {
 
     /**
      * <p>
-     * Creates a new WikiContext for the given WikiEngine, Command and
-     * HttpServletRequest.
+     * Creates a new WikiContext for the given WikiEngine, Command and HttpServletRequest.
      * </p>
      * <p>
-     * This constructor will also look up the HttpSession associated with the
-     * request, and determine if a WikiSession object is present. If not, a new
-     * one is created.
+     * This constructor will also look up the HttpSession associated with the request, and determine if a WikiSession object is present.
+     * If not, a new one is created.
      * </p>
      * @param engine The WikiEngine that is handling the request
-     * @param request The HttpServletRequest that should be associated with this
-     *            context. This parameter may be <code>null</code>.
+     * @param request The HttpServletRequest that should be associated with this context. This parameter may be <code>null</code>.
      * @param command the command
-     * @throws IllegalArgumentException if <code>engine</code> or
-     *             <code>command</code> are <code>null</code>
+     * @throws IllegalArgumentException if <code>engine</code> or <code>command</code> are <code>null</code>
      */
-    public WikiContext( WikiEngine engine, HttpServletRequest request, Command command )
-        throws IllegalArgumentException
-    {
-        super();
-        if ( engine == null || command == null )
-        {
+    public WikiContext( final WikiEngine engine, final HttpServletRequest request, final Command command ) throws IllegalArgumentException {
+        if ( engine == null || command == null ) {
             throw new IllegalArgumentException( "Parameter engine and command must not be null." );
         }
 
@@ -211,19 +203,16 @@ public class WikiContext implements Cloneable, Command {
         m_command = command;
 
         // If PageCommand, get the WikiPage
-        if( command instanceof PageCommand )
-        {
-            m_page = (WikiPage)((PageCommand)command).getTarget();
+        if( command instanceof PageCommand ) {
+            m_page = ( WikiPage )command.getTarget();
         }
 
         // If page not supplied, default to front page to avoid NPEs
-        if( m_page == null )
-        {
-            m_page = m_engine.getPage( m_engine.getFrontPage() );
+        if( m_page == null ) {
+            m_page = m_engine.getPageManager().getPage( m_engine.getFrontPage() );
 
             // Front page does not exist?
-            if( m_page == null )
-            {
+            if( m_page == null ) {
                 m_page = new WikiPage( m_engine, m_engine.getFrontPage() );
             }
         }
@@ -231,16 +220,14 @@ public class WikiContext implements Cloneable, Command {
         m_realPage = m_page;
 
         // Special case: retarget any empty 'view' PageCommands to the front page
-        if ( PageCommand.VIEW.equals( command ) && command.getTarget() == null )
-        {
+        if ( PageCommand.VIEW.equals( command ) && command.getTarget() == null ) {
             m_command = command.targetedCommand( m_page );
         }
 
         // Debugging...
-        if( log.isDebugEnabled() )
-        {
-            HttpSession session = ( request == null ) ? null : request.getSession( false );
-            String sid = ( session == null ) ? "(null)" : session.getId();
+        if( log.isDebugEnabled() ) {
+            final HttpSession session = ( request == null ) ? null : request.getSession( false );
+            final String sid = session == null ? "(null)" : session.getId();
             log.debug( "Creating WikiContext for session ID=" + sid + "; target=" + getName() );
         }
 
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 3080f5d..387ce65 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -1322,7 +1322,7 @@ public class WikiEngine  {
      *  @return HTML-rendered page text.
      */
     public String getHTML( final String pagename, final int version ) {
-        final WikiPage page = getPage( pagename, version );
+        final WikiPage page = getPageManager().getPage( pagename, version );
         final WikiContext context = new WikiContext( this, page );
         context.setRequestContext( WikiContext.NONE );
         return getHTML( context, page );
@@ -1568,53 +1568,6 @@ public class WikiEngine  {
     }
 
     /**
-     *  Finds the corresponding WikiPage object based on the page name.  It always finds
-     *  the latest version of a page.
-     *
-     *  @param pagereq The name of the page to look for.
-     *  @return A WikiPage object, or null, if the page by the name could not be found.
-     */
-
-    public WikiPage getPage( String pagereq )
-    {
-        return getPage( pagereq, WikiProvider.LATEST_VERSION );
-    }
-
-    /**
-     *  Finds the corresponding WikiPage object base on the page name and version.
-     *
-     *  @param pagereq The name of the page to look for.
-     *  @param version The version number to look for.  May be WikiProvider.LATEST_VERSION,
-     *  in which case it will look for the latest version (and this method then becomes
-     *  the equivalent of getPage(String).
-     *
-     *  @return A WikiPage object, or null, if the page could not be found; or if there
-     *  is no such version of the page.
-     *  @since 1.6.7.
-     */
-
-    public WikiPage getPage( String pagereq, int version )
-    {
-        try
-        {
-            WikiPage p = m_pageManager.getPageInfo( pagereq, version );
-
-            if( p == null )
-            {
-                p = m_attachmentManager.getAttachmentInfo( (WikiContext)null, pagereq );
-            }
-
-            return p;
-        }
-        catch( ProviderException e )
-        {
-            log.error( "Unable to fetch page info",e);
-            return null;
-        }
-    }
-
-
-    /**
      *  Returns a Collection of WikiPages containing the version history of a page.
      *
      *  @param page Name of the page to look for
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java
index ab819ab..8ec4634 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentManager.java
@@ -299,31 +299,25 @@ public class AttachmentManager
      *  @throws ProviderException If something goes wrong.
      */
 
-    public Attachment getAttachmentInfo( WikiContext context,
+    public Attachment getAttachmentInfo( final WikiContext context,
                                          String attachmentname,
-                                         int version )
-        throws ProviderException
-    {
-        if( m_provider == null )
-        {
+                                         final int version ) throws ProviderException {
+        if( m_provider == null ) {
             return null;
         }
 
         WikiPage currentPage = null;
 
-        if( context != null )
-        {
+        if( context != null ) {
             currentPage = context.getPage();
         }
 
         //
-        //  Figure out the parent page of this attachment.  If we can't find it,
-        //  we'll assume this refers directly to the attachment.
+        //  Figure out the parent page of this attachment.  If we can't find it, we'll assume this refers directly to the attachment.
         //
-        int cutpt = attachmentname.lastIndexOf('/');
+        final int cutpt = attachmentname.lastIndexOf('/');
 
-        if( cutpt != -1 )
-        {
+        if( cutpt != -1 ) {
             String parentPage = attachmentname.substring(0,cutpt);
             parentPage = MarkupParser.cleanLink( parentPage );
             attachmentname = attachmentname.substring(cutpt+1);
@@ -332,7 +326,7 @@ public class AttachmentManager
             // this can't be an attachment
             if(parentPage.length() == 0) return null;
 
-            currentPage = m_engine.getPage( parentPage );
+            currentPage = m_engine.getPageManager().getPage( parentPage );
 
             //
             // Go check for legacy name
@@ -340,30 +334,24 @@ public class AttachmentManager
             // FIXME: This should be resolved using CommandResolver,
             //        not this adhoc way.  This also assumes that the
             //        legacy charset is a subset of the full allowed set.
-            if( currentPage == null )
-            {
-                currentPage = m_engine.getPage( MarkupParser.wikifyLink( parentPage ) );
+            if( currentPage == null ) {
+                currentPage = m_engine.getPageManager().getPage( MarkupParser.wikifyLink( parentPage ) );
             }
         }
 
         //
-        //  If the page cannot be determined, we cannot possibly find the
-        //  attachments.
+        //  If the page cannot be determined, we cannot possibly find the attachments.
         //
-        if( currentPage == null || currentPage.getName().length() == 0 )
-        {
+        if( currentPage == null || currentPage.getName().length() == 0 ) {
             return null;
         }
 
-        // System.out.println("Seeking info on "+currentPage+"::"+attachmentname);
-
         //
         //  Finally, figure out whether this is a real attachment or a generated attachment.
         //
         Attachment att = getDynamicAttachment( currentPage.getName()+"/"+attachmentname );
 
-        if( att == null )
-        {
+        if( att == null ) {
             att = m_provider.getAttachmentInfo( currentPage, attachmentname, version );
         }
 
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 6d27142..e1acca7 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
@@ -214,7 +214,7 @@ public class AuthorizationManager {
         // If the page or ACL is null, it's allowed.
         //
         String pageName = ((PagePermission)permission).getPage();
-        WikiPage page = m_engine.getPage( pageName );
+        WikiPage page = m_engine.getPageManager().getPage( pageName );
         Acl acl = ( page == null) ? null : m_engine.getAclManager().getPermissions( page );
         if ( page == null ||  acl == null || acl.isEmpty() )
         {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
index 07363a5..8cdad24 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
@@ -18,20 +18,6 @@
  */
 package org.apache.wiki.auth.acl;
 
-import java.security.Permission;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.TreeMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -47,6 +33,20 @@ import org.apache.wiki.pages.PageLock;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.render.RenderingManager;
 
+import java.security.Permission;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+import java.util.StringTokenizer;
+import java.util.TreeMap;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
 /**
  * Default implementation that parses Acls from wiki page markup.
  *
@@ -158,7 +158,7 @@ public class DefaultAclManager implements AclManager {
      * @return the Acl representing permissions for the page
      * @since 2.2.121
      */
-    public Acl getPermissions(WikiPage page) {
+    public Acl getPermissions( final WikiPage page ) {
         //
         //  Does the page already have cached ACLs?
         //
@@ -169,15 +169,15 @@ public class DefaultAclManager implements AclManager {
             //
             //  If null, try the parent.
             //
-            if (page instanceof Attachment) {
-                WikiPage parent = m_engine.getPage(((Attachment) page).getParentName());
+            if( page instanceof Attachment ) {
+                final WikiPage parent = m_engine.getPageManager().getPage( ( ( Attachment ) page ).getParentName() );
 
                 acl = getPermissions(parent);
             } else {
                 //
                 //  Or, try parsing the page
                 //
-                WikiContext ctx = new WikiContext(m_engine, page);
+                final WikiContext ctx = new WikiContext(m_engine, page);
 
                 ctx.setVariable(RenderingManager.VAR_EXECUTE_PLUGINS, Boolean.FALSE);
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
index 21f6204..e15de8c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
@@ -79,11 +79,11 @@ public class DefaultPageRenamer implements PageRenamer {
         
         //  Preconditions: "from" page must exist, and "to" page must not yet exist.
         final WikiEngine engine = context.getEngine();
-        final WikiPage fromPage = engine.getPage( renameFrom );
+        final WikiPage fromPage = engine.getPageManager().getPage( renameFrom );
         if( fromPage == null ) {
             throw new WikiException("No such page "+renameFrom);
         }
-        WikiPage toPage = engine.getPage( renameToClean );
+        WikiPage toPage = engine.getPageManager().getPage( renameToClean );
         if( toPage != null ) {
             throw new WikiException( "Page already exists " + renameToClean );
         }
@@ -94,7 +94,7 @@ public class DefaultPageRenamer implements PageRenamer {
         //  Remove references to attachments under old name
         final List< Attachment > attachmentsOldName = engine.getAttachmentManager().listAttachments( fromPage );
         for( final Attachment att: attachmentsOldName ) {
-            final WikiPage fromAttPage = engine.getPage( att.getName() );
+            final WikiPage fromAttPage = engine.getPageManager().getPage( att.getName() );
             engine.getReferenceManager().pageRemoved( fromAttPage );
         }
 
@@ -104,7 +104,7 @@ public class DefaultPageRenamer implements PageRenamer {
         }
         
         //  Add a comment to the page notifying what changed.  This adds a new revision to the repo with no actual change.
-        toPage = engine.getPage( renameToClean );
+        toPage = engine.getPageManager().getPage( renameToClean );
         if( toPage == null ) {
             throw new InternalWikiException( "Rename seems to have failed for some strange reason - please check logs!" );
         }
@@ -126,7 +126,7 @@ public class DefaultPageRenamer implements PageRenamer {
         
         final Collection< Attachment > attachmentsNewName = engine.getAttachmentManager().listAttachments( toPage );
         for( final Attachment att:attachmentsNewName ) {
-            final WikiPage toAttPage = engine.getPage( att.getName() );
+            final WikiPage toAttPage = engine.getPageManager().getPage( att.getName() );
             // add reference to attachment under new page name
             engine.getReferenceManager().updateReferences( toAttPage );
             engine.getSearchManager().reindexPage( att );
@@ -171,7 +171,7 @@ public class DefaultPageRenamer implements PageRenamer {
                 pageName = toPage.getName();
             }
             
-            final WikiPage p = engine.getPage( pageName );
+            final WikiPage p = engine.getPageManager().getPage( pageName );
 
             final String sourceText = engine.getPureText( p );
             String newText = replaceReferrerString( context, sourceText, fromPage.getName(), toPage.getName() );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
index 3ee127c..4dd287d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
@@ -701,14 +701,13 @@ public class SpamFilter extends BasicPageFilter {
             String remote = HttpUtil.getRemoteAddress(req);
             long now = System.currentTimeMillis();
 
-            for( Iterator< Host > i = m_temporaryBanList.iterator(); i.hasNext(); ) {
-                Host host = i.next();
-
+            for( Host host : m_temporaryBanList ) {
                 if( host.getAddress().equals( remote ) ) {
                     long timeleft = ( host.getReleaseTime() - now ) / 1000L;
 
                     log( context, REJECT, REASON_IP_BANNED_TEMPORARILY, change.m_change );
-                    checkStrategy( context, REASON_IP_BANNED_TEMPORARILY, "You have been temporarily banned from modifying this wiki. (" + timeleft + " seconds of ban left)" );
+                    checkStrategy( context, REASON_IP_BANNED_TEMPORARILY,
+                            "You have been temporarily banned from modifying this wiki. (" + timeleft + " seconds of ban left)" );
                 }
             }
         }
@@ -717,9 +716,9 @@ public class SpamFilter extends BasicPageFilter {
     /**
      *  If the spam filter notices changes in the black list page, it will refresh them automatically.
      *
-     *  @param context
+     *  @param context associated WikiContext
      */
-    private void refreshBlacklists( WikiContext context ) {
+    private void refreshBlacklists( final WikiContext context ) {
         try {
 
             boolean rebuild = false;
@@ -727,21 +726,21 @@ public class SpamFilter extends BasicPageFilter {
             //
             //  Rebuild, if the spam words page, the attachment or the IP ban page has changed since.
             //
-            WikiPage sourceSpam = context.getEngine().getPage( m_forbiddenWordsPage );
+            final WikiPage sourceSpam = context.getEngine().getPageManager().getPage( m_forbiddenWordsPage );
             if( sourceSpam != null ) {
                 if( m_spamPatterns == null || m_spamPatterns.isEmpty() || sourceSpam.getLastModified().after( m_lastRebuild ) ) {
                     rebuild = true;
                 }
             }
 
-            Attachment att = context.getEngine().getAttachmentManager().getAttachmentInfo( context, m_blacklist );
+            final Attachment att = context.getEngine().getAttachmentManager().getAttachmentInfo( context, m_blacklist );
             if( att != null ) {
                 if( m_spamPatterns == null || m_spamPatterns.isEmpty() || att.getLastModified().after( m_lastRebuild ) ) {
                     rebuild = true;
                 }
             }
 
-            WikiPage sourceIPs = context.getEngine().getPage( m_forbiddenIPsPage );
+            final WikiPage sourceIPs = context.getEngine().getPageManager().getPage( m_forbiddenIPsPage );
             if( sourceIPs != null ) {
                 if( m_IPPatterns == null || m_IPPatterns.isEmpty() || sourceIPs.getLastModified().after( m_lastRebuild ) ) {
                     rebuild = true;
@@ -764,17 +763,17 @@ public class SpamFilter extends BasicPageFilter {
                 log.info( "IP filter reloaded - recognizing " + m_IPPatterns.size() + " patterns from page " + m_forbiddenIPsPage );
 
                 if( att != null ) {
-                    InputStream in = context.getEngine().getAttachmentManager().getAttachmentStream(att);
-                    StringWriter out = new StringWriter();
-                    FileUtil.copyContents( new InputStreamReader( in,"UTF-8" ), out );
-                    Collection< Pattern > blackList = parseBlacklist( out.toString() );
+                    final InputStream in = context.getEngine().getAttachmentManager().getAttachmentStream(att);
+                    final StringWriter out = new StringWriter();
+                    FileUtil.copyContents( new InputStreamReader( in, StandardCharsets.UTF_8 ), out );
+                    final Collection< Pattern > blackList = parseBlacklist( out.toString() );
                     log.info( "...recognizing additional " + blackList.size() + " patterns from blacklist " + m_blacklist );
                     m_spamPatterns.addAll( blackList );
                 }
             }
-        } catch( IOException ex ) {
+        } catch( final IOException ex ) {
             log.info( "Unable to read attachment data, continuing...", ex );
-        } catch( ProviderException ex ) {
+        } catch( final ProviderException ex ) {
             log.info( "Failed to read spam filter attachment, continuing...", ex );
         }
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index 945c401..5d605ed 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -276,6 +276,32 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
 
     /**
      * {@inheritDoc}
+     * @see org.apache.wiki.pages.PageManager#getPage(java.lang.String)
+     */
+    public WikiPage getPage( final String pagereq ) {
+        return getPage( pagereq, WikiProvider.LATEST_VERSION );
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see org.apache.wiki.pages.PageManager#getPage(java.lang.String, int)
+     */
+    public WikiPage getPage( final String pagereq, final int version ) {
+        try {
+            WikiPage p = getPageInfo( pagereq, version );
+            if( p == null ) {
+                p = m_engine.getAttachmentManager().getAttachmentInfo( null, pagereq );
+            }
+
+            return p;
+        } catch( final ProviderException e ) {
+            LOG.error( "Unable to fetch page info for " + pagereq + " [version " + version + "]", e );
+            return null;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getPageInfo(java.lang.String, int)
      */
     @Override
@@ -386,8 +412,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
             m_engine.getAttachmentManager().deleteVersion( ( Attachment )page );
         } else {
             m_provider.deleteVersion(page.getName(), page.getVersion());
-            // FIXME: If this was the latest, reindex Lucene
-            // FIXME: Update RefMgr
+            // FIXME: If this was the latest, reindex Lucene, update RefMgr
         }
     }
 
@@ -396,7 +421,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * @see org.apache.wiki.pages.PageManager#deletePage(java.lang.String)
      */
     public void deletePage( final String pageName ) throws ProviderException {
-        final WikiPage p = m_engine.getPage( pageName );
+        final WikiPage p = getPage( pageName );
         if( p != null ) {
             if( p instanceof Attachment ) {
                 m_engine.getAttachmentManager().deleteAttachment( ( Attachment )p );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index dbdf1db..c7a9674 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -116,7 +116,30 @@ public interface PageManager extends WikiEventListener {
      * @return List of PageLock objects, detailing the locks.  If no locks exist, returns an empty list.
      * @since 2.0.22.
      */
-    List<PageLock> getActiveLocks();
+    List< PageLock > getActiveLocks();
+
+    /**
+     *  Finds the corresponding WikiPage object based on the page name.  It always finds
+     *  the latest version of a page.
+     *
+     *  @param pagereq The name of the page to look for.
+     *  @return A WikiPage object, or null, if the page by the name could not be found.
+     */
+    WikiPage getPage( String pagereq );
+
+    /**
+     *  Finds the corresponding WikiPage object base on the page name and version.
+     *
+     *  @param pagereq The name of the page to look for.
+     *  @param version The version number to look for.  May be WikiProvider.LATEST_VERSION,
+     *  in which case it will look for the latest version (and this method then becomes
+     *  the equivalent of getPage(String).
+     *
+     *  @return A WikiPage object, or null, if the page could not be found; or if there
+     *  is no such version of the page.
+     *  @since 1.6.7 (moved to PageManager on 2.11.0).
+     */
+    WikiPage getPage( String pagereq, int version );
 
     /**
      * Finds a WikiPage object describing a particular page and version.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/AbstractReferralPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/AbstractReferralPlugin.java
index 6838cf8..5bc2871 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/AbstractReferralPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/AbstractReferralPlugin.java
@@ -318,7 +318,7 @@ public abstract class AbstractReferralPlugin implements WikiPlugin
                 WikiPage page = null;
                 if( m_lastModified )
                 {
-                    page = m_engine.getPage( pageName );
+                    page = m_engine.getPageManager().getPage( pageName );
                     if( page != null )
                     {
                         Date lastModPage = page.getLastModified();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java
index afc12e3..3c92e9f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/InsertPage.java
@@ -18,11 +18,6 @@
  */
 package org.apache.wiki.plugin;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
@@ -31,9 +26,14 @@ import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.permissions.PermissionFactory;
-import org.apache.wiki.util.TextUtil;
-import org.apache.wiki.util.HttpUtil;
 import org.apache.wiki.preferences.Preferences;
+import org.apache.wiki.util.HttpUtil;
+import org.apache.wiki.util.TextUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
 
 
 /**
@@ -106,21 +106,15 @@ public class InsertPage
 
         if( includedPage != null )
         {
-            WikiPage page = null;
-            try
-            {
-                String pageName = engine.getFinalPageName( includedPage );
-                if( pageName != null )
-                {
-                    page = engine.getPage( pageName );
+            WikiPage page;
+            try {
+                final String pageName = engine.getFinalPageName( includedPage );
+                if( pageName != null ) {
+                    page = engine.getPageManager().getPage( pageName );
+                } else {
+                    page = engine.getPageManager().getPage( includedPage );
                 }
-                else
-                {
-                    page = engine.getPage( includedPage );
-                }
-            }
-            catch( ProviderException e )
-            {
+            } catch( final ProviderException e ) {
                 res.append( "<span class=\"error\">Page could not be found by the page provider.</span>" );
                 return res.toString();
             }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringPagesPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringPagesPlugin.java
index 6d1bd72..51596ff 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringPagesPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringPagesPlugin.java
@@ -83,7 +83,7 @@ public class ReferringPagesPlugin
             pageName = context.getPage().getName();
         }
 
-        WikiPage page = context.getEngine().getPage( pageName );
+        WikiPage page = context.getEngine().getPageManager().getPage( pageName );
 
         if( page != null )
         {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
index ae5e712..214a265 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
@@ -338,7 +338,7 @@ public class WeblogPlugin
         WikiContext entryCtx = (WikiContext) context.clone();
         entryCtx.setPage( entry );
 
-        String html = engine.getHTML( entryCtx, engine.getPage(entry.getName()) );
+        String html = engine.getHTML( entryCtx, engine.getPageManager().getPage( entry.getName() ) );
 
         // Extract the first h1/h2/h3 as title, and replace with null
         buffer.append("<div class=\"weblogentrytitle\">\n");
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 3360c9a..6c69498 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
@@ -205,7 +205,7 @@ public class DefaultReferenceManager extends BasicPageFilter implements Referenc
             for( final WikiPage page : pages ) {
                 if( !( page instanceof Attachment ) ) {
                     // Refresh with the latest copy
-                    final WikiPage wp = m_engine.getPage( page.getName() );
+                    final WikiPage wp = m_engine.getPageManager().getPage( page.getName() );
 
                     if( wp.getLastModified() == null ) {
                         log.fatal( "Provider returns null lastModified.  Please submit a bug report." );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
index 049a551..6abdf6c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
@@ -18,17 +18,6 @@
  */
 package org.apache.wiki.rpc.atom;
 
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-
-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;
@@ -47,6 +36,16 @@ import org.intabulas.sandler.elements.Link;
 import org.intabulas.sandler.elements.Person;
 import org.intabulas.sandler.exceptions.FeedMarshallException;
 
+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.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+
 
 /**
  *  Handles incoming requests for the Atom API.  This class uses the
@@ -117,7 +116,7 @@ public class AtomAPIServlet extends HttpServlet
         {
             String blogid = getPageName( request );
 
-            WikiPage page    = m_engine.getPage( blogid );
+            WikiPage page    = m_engine.getPageManager().getPage( blogid );
 
             if( page == null )
             {
@@ -224,8 +223,8 @@ public class AtomAPIServlet extends HttpServlet
     private Entry getBlogEntry( String entryid )
         throws ProviderException
     {
-        WikiPage page = m_engine.getPage( entryid );
-        WikiPage firstVersion = m_engine.getPage( entryid, 1 );
+        WikiPage page = m_engine.getPageManager().getPage( entryid );
+        WikiPage firstVersion = m_engine.getPageManager().getPage( entryid, 1 );
 
         Entry entry = SyndicationFactory.newSyndicationEntry();
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
index 5bb618d..2815e37 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
@@ -539,7 +539,7 @@ public class LuceneSearchProvider implements SearchProvider {
                 int docID = hits[curr].doc;
                 Document doc = searcher.doc( docID );
                 String pageName = doc.get(LUCENE_ID);
-                WikiPage page = m_engine.getPage(pageName, WikiPageProvider.LATEST_VERSION);
+                WikiPage page = m_engine.getPageManager().getPage(pageName, WikiPageProvider.LATEST_VERSION);
 
                 if( page != null ) {
                     if( page instanceof Attachment ) {
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 c8ac883..247d08d 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
@@ -314,10 +314,10 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
      * @throws ProviderException If the provider fails and a search cannot be completed.
      * @throws IOException If something else goes wrong.
      */
-    public Collection< SearchResult > findPages( String query, WikiContext wikiContext )
-        throws ProviderException, IOException
-    {
-        if( query == null ) query = "";
+    public Collection< SearchResult > findPages( String query, final WikiContext wikiContext ) throws ProviderException, IOException {
+        if( query == null ) {
+            query = "";
+        }
         return m_searchProvider.findPages( query, wikiContext );
     }
 
@@ -325,7 +325,7 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
      *  Removes the page from the search cache (if any).
      *  @param page  The page to remove
      */
-    public void pageRemoved(WikiPage page)
+    public void pageRemoved( final WikiPage page )
     {
         m_searchProvider.pageRemoved(page);
     }
@@ -337,13 +337,9 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
      *  @param content {@inheritDoc}
      */
     @Override
-    public void postSave( WikiContext wikiContext, String content )
-    {
-        //
-        //  Makes sure that we're indexing the latest version of this
-        //  page.
-        //
-        WikiPage p = m_engine.getPage( wikiContext.getPage().getName() );
+    public void postSave( final WikiContext wikiContext, final String content ) {
+        //  Makes sure that we're indexing the latest version of this page.
+        final WikiPage p = m_engine.getPageManager().getPage( wikiContext.getPage().getName() );
         reindexPage( p );
     }
 
@@ -352,9 +348,9 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
      *
      *   @param page The page.
      */
-    public void reindexPage(WikiPage page)
+    public void reindexPage( final WikiPage page )
     {
-        m_searchProvider.reindexPage(page);
+        m_searchProvider.reindexPage( page );
     }
 
     /**
@@ -363,15 +359,12 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
      *  @param event {@inheritDoc}
      */
     @Override
-    public void actionPerformed(WikiEvent event)
-    {
-        if( (event instanceof WikiPageEvent) && (event.getType() == WikiPageEvent.PAGE_DELETE_REQUEST) )
-        {
-            String pageName = ((WikiPageEvent) event).getPageName();
+    public void actionPerformed( final WikiEvent event ) {
+        if( event instanceof WikiPageEvent && event.getType() == WikiPageEvent.PAGE_DELETE_REQUEST ) {
+            final String pageName = ( ( WikiPageEvent ) event ).getPageName();
 
-            WikiPage p = m_engine.getPage( pageName );
-            if( p != null )
-            {
+            final WikiPage p = m_engine.getPageManager().getPage( pageName );
+            if( p != null ) {
                 pageRemoved( p );
             }
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/CheckVersionTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/CheckVersionTag.java
index 16d5b69..2e170c1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/CheckVersionTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/CheckVersionTag.java
@@ -18,13 +18,13 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.ProviderException;
 
+import java.io.IOException;
+
 /**
  *  Does a version check on the page.  Mode is as follows:
  *  <UL>
@@ -100,7 +100,7 @@ public class CheckVersionTag
             int version = page.getVersion();
             boolean include = false;
 
-            WikiPage latest = engine.getPage( page.getName() );
+            WikiPage latest = engine.getPageManager().getPage( page.getName() );
 
             //log.debug("Doing version check: this="+page.getVersion()+
             //          ", latest="+latest.getVersion());
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/DiffLinkTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/DiffLinkTag.java
index 10772b1..3e9a827 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/DiffLinkTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/DiffLinkTag.java
@@ -18,10 +18,13 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-import javax.servlet.jsp.JspWriter;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.WikiProvider;
 
-import org.apache.wiki.*;
+import javax.servlet.jsp.JspWriter;
+import java.io.IOException;
 
 /**
  *  Writes a diff link.  Body of the link becomes the link text.
@@ -40,11 +43,9 @@ import org.apache.wiki.*;
  *
  *  @since 2.0
  */
-public class DiffLinkTag
-    extends WikiLinkTag
-{
+public class DiffLinkTag extends WikiLinkTag {
+
     private static final long serialVersionUID = 0L;
-    
     public static final String VER_LATEST   = "latest";
     public static final String VER_PREVIOUS = "previous";
     public static final String VER_CURRENT  = "current";
@@ -63,7 +64,7 @@ public class DiffLinkTag
         return m_version;
     }
 
-    public void setVersion( String arg )
+    public void setVersion( final String arg )
     {
         m_version = arg;
     }
@@ -73,99 +74,66 @@ public class DiffLinkTag
         return m_newVersion;
     }
 
-    public void setNewVersion( String arg )
+    public void setNewVersion( final String arg )
     {
         m_newVersion = arg;
     }
 
-    public final int doWikiStartTag()
-        throws IOException
-    {
-        WikiEngine engine   = m_wikiContext.getEngine();
-        String     pageName = m_pageName;
+    public final int doWikiStartTag() throws IOException {
+        final WikiEngine engine = m_wikiContext.getEngine();
+        String pageName = m_pageName;
 
-        if( m_pageName == null )
-        {
-            if( m_wikiContext.getPage() != null )
-            {
+        if( m_pageName == null ) {
+            if( m_wikiContext.getPage() != null ) {
                 pageName = m_wikiContext.getPage().getName();
-            }
-            else
-            {
+            } else {
                 return SKIP_BODY;
             }
         }
 
-        JspWriter out = pageContext.getOut();
+        final JspWriter out = pageContext.getOut();
 
-        int r1 = 0;
-        int r2 = 0;
+        int r1;
+        int r2;
 
-        //
         //  In case the page does not exist, we fail silently.
-        //
-        if(!engine.pageExists(pageName))
-        {
+        if( !engine.pageExists( pageName ) ) {
             return SKIP_BODY;
         }
 
-        if( VER_LATEST.equals(getVersion()) )
-        {
-            WikiPage latest = engine.getPage( pageName, 
-                                              WikiProvider.LATEST_VERSION );
-
-            if( latest == null )
-            {
+        if( VER_LATEST.equals(getVersion()) ) {
+            final WikiPage latest = engine.getPageManager().getPage( pageName, WikiProvider.LATEST_VERSION );
+            if( latest == null ) {
                 // This may occur if matchEnglishPlurals is on, and we access the wrong page name
                 return SKIP_BODY;
             }
             r1 = latest.getVersion();
-        }
-        else if( VER_PREVIOUS.equals(getVersion()) )
-        {
+        } else if( VER_PREVIOUS.equals( getVersion() ) ) {
             r1 = m_wikiContext.getPage().getVersion() - 1;
-            r1 = (r1 < 1 ) ? 1 : r1;
-        }
-        else if( VER_CURRENT.equals(getVersion()) )
-        {
+            r1 = Math.max( r1, 1 );
+        } else if( VER_CURRENT.equals( getVersion() ) ) {
             r1 = m_wikiContext.getPage().getVersion();
-        }
-        else
-        {
+        } else {
             r1 = Integer.parseInt( getVersion() );
         }
 
-        if( VER_LATEST.equals(getNewVersion()) )
-        {
-            WikiPage latest = engine.getPage( pageName,
-                                              WikiProvider.LATEST_VERSION );
-
+        if( VER_LATEST.equals( getNewVersion() ) ) {
+            final WikiPage latest = engine.getPageManager().getPage( pageName, WikiProvider.LATEST_VERSION );
             r2 = latest.getVersion();
-        }
-        else if( VER_PREVIOUS.equals(getNewVersion()) )
-        {
+        } else if( VER_PREVIOUS.equals( getNewVersion() ) ) {
             r2 = m_wikiContext.getPage().getVersion() - 1;
-            r2 = (r2 < 1 ) ? 1 : r2;
-        }
-        else if( VER_CURRENT.equals(getNewVersion()) )
-        {
+            r2 = Math.max( r2, 1 );
+        } else if( VER_CURRENT.equals( getNewVersion() ) ) {
             r2 = m_wikiContext.getPage().getVersion();
-        }
-        else
-        {
+        } else {
             r2 = Integer.parseInt( getNewVersion() );
         }
 
-        String url = m_wikiContext.getURL( WikiContext.DIFF,
-                                           pageName,
-                                           "r1="+r1+"&amp;r2="+r2 );
-        switch( m_format )
-        {
+        final String url = m_wikiContext.getURL( WikiContext.DIFF, pageName, "r1="+r1+"&amp;r2="+r2 );
+        switch( m_format ) {
           case ANCHOR:
             out.print("<a href=\""+url+"\">");
-
             break;
-
           case URL:
             out.print( url );
             break;
@@ -173,4 +141,5 @@ public class DiffLinkTag
 
         return EVAL_BODY_INCLUDE;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/EditLinkTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/EditLinkTag.java
index 390b01f..8bbbd32 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/EditLinkTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/EditLinkTag.java
@@ -18,13 +18,13 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-import javax.servlet.jsp.JspWriter;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 
+import javax.servlet.jsp.JspWriter;
+import java.io.IOException;
+
 /**
  *  Writes an edit link.  Body of the link becomes the link text.
  *  <P><B>Attributes</B></P>
@@ -107,7 +107,7 @@ public class EditLinkTag
                 if( page == null )
                 {
                     // No page, so go fetch according to page name.
-                    page = engine.getPage( m_pageName );
+                    page = engine.getPageManager().getPage( m_pageName );
                 }
                 
                 if( page != null )
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertDiffTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertDiffTag.java
index 761eff0..68152f6 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertDiffTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertDiffTag.java
@@ -83,7 +83,7 @@ public class InsertDiffTag extends WikiTagBase {
             ctx = m_wikiContext;
         } else {
             ctx = ( WikiContext )m_wikiContext.clone();
-            ctx.setPage( engine.getPage(m_pageName) );
+            ctx.setPage( engine.getPageManager().getPage(m_pageName) );
         }
 
         final Integer vernew = ( Integer )pageContext.getAttribute( ATTR_NEWVERSION, PageContext.REQUEST_SCOPE );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java
index 7a76288..643d0c4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java
@@ -18,15 +18,14 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-
-import javax.servlet.jsp.JspWriter;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.ProviderException;
 
+import javax.servlet.jsp.JspWriter;
+import java.io.IOException;
+
 /**
  *  Renders WikiPage content.  For InsertPage tag and the InsertPage plugin
  *  the difference is that the tag will always render in the context of the page
@@ -59,14 +58,13 @@ public class InsertPageTag extends WikiTagBase {
     protected String m_pageName = null;
     private   int    m_mode = HTML;
 
-    public void initTag()
-    {
+    public void initTag() {
         super.initTag();
         m_pageName = null;
         m_mode = HTML;
     }
 
-    public void setPage( String page )
+    public void setPage( final String page )
     {
         m_pageName = page;
     }
@@ -76,24 +74,17 @@ public class InsertPageTag extends WikiTagBase {
         return m_pageName;
     }
 
-    public void setMode( String arg )
-    {
-        if( "plain".equals(arg) )
-        {
+    public void setMode( final String arg ) {
+        if( "plain".equals( arg ) ) {
             m_mode = PLAIN;
-        }
-        else
-        {
+        } else {
             m_mode = HTML;
         }
     }
 
-    public final int doWikiStartTag()
-        throws IOException,
-               ProviderException
-    {
-        WikiEngine engine = m_wikiContext.getEngine();
-        WikiPage   insertedPage;
+    public final int doWikiStartTag() throws IOException, ProviderException {
+        final WikiEngine engine = m_wikiContext.getEngine();
+        final WikiPage insertedPage;
 
         //
         //  NB: The page might not really exist if the user is currently
@@ -101,29 +92,23 @@ public class InsertPageTag extends WikiTagBase {
         //      AND we got the page from the wikiContext.
         //
 
-        if( m_pageName == null )
-        {
+        if( m_pageName == null ) {
             insertedPage = m_wikiContext.getPage();
             if( !engine.pageExists(insertedPage) ) return SKIP_BODY;
-        }
-        else
-        {
-            insertedPage = engine.getPage( m_pageName );
+        } else {
+            insertedPage = engine.getPageManager().getPage( m_pageName );
         }
 
-        if( insertedPage != null )
-        {
+        if( insertedPage != null ) {
             // FIXME: Do version setting later.
             // page.setVersion( WikiProvider.LATEST_VERSION );
 
             log.debug("Inserting page "+insertedPage);
 
-            JspWriter out = pageContext.getOut();
-
-            WikiPage oldPage = m_wikiContext.setRealPage( insertedPage );
+            final JspWriter out = pageContext.getOut();
+            final WikiPage oldPage = m_wikiContext.setRealPage( insertedPage );
             
-            switch( m_mode )
-            {
+            switch( m_mode ) {
               case HTML:
                 out.print( engine.getHTML( m_wikiContext, insertedPage ) );
                 break;
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 17af986..ec2bc91 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
@@ -18,15 +18,6 @@
  */
 package org.apache.wiki.tags;
 
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.servlet.jsp.JspException;
-import javax.servlet.jsp.JspWriter;
-import javax.servlet.jsp.tagext.BodyContent;
-import javax.servlet.jsp.tagext.BodyTag;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -38,6 +29,14 @@ 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;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
 /**
  *  Provides a generic link tag for all kinds of linking
  *  purposes.
@@ -248,7 +247,7 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
                 //
                 //  Internal wiki link, but is it an attachment link?
                 //
-                WikiPage p = engine.getPage( m_pageName );
+                WikiPage p = engine.getPageManager().getPage( m_pageName );
 
                 if( p instanceof Attachment )
                 {
@@ -287,7 +286,7 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
         }
         else if( m_pageName != null && m_pageName.length() > 0 )
         {
-            WikiPage p = engine.getPage( m_pageName );
+            WikiPage p = engine.getPageManager().getPage( m_pageName );
 
             String parms = (m_version != null) ? "version="+getVersion() : null;
 
@@ -363,7 +362,7 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
 
             if( DiffLinkTag.VER_LATEST.equals(getVersion()) )
             {
-                WikiPage latest = engine.getPage( page, WikiProvider.LATEST_VERSION );
+                WikiPage latest = engine.getPageManager().getPage( page, WikiProvider.LATEST_VERSION );
 
                 r1 = latest.getVersion();
             }
@@ -383,7 +382,7 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
 
             if( DiffLinkTag.VER_LATEST.equals(m_compareToVersion) )
             {
-                WikiPage latest = engine.getPage( page, WikiProvider.LATEST_VERSION );
+                WikiPage latest = engine.getPageManager().getPage( page, WikiProvider.LATEST_VERSION );
 
                 r2 = latest.getVersion();
             }
@@ -440,7 +439,7 @@ 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.getPage( m_pageName ) instanceof Attachment )
+            if( engine.getPageManager().getPage( m_pageName ) instanceof Attachment )
             {
                 sb.append( engine.getAttachmentManager().forceDownload( m_pageName ) ? "download " : "" );
             }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/NoSuchPageTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/NoSuchPageTag.java
index 038a4ad..8fca495 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/NoSuchPageTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/NoSuchPageTag.java
@@ -18,31 +18,29 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.ProviderException;
 
+import java.io.IOException;
+
 /**
  *  Includes the body in case there is no such page available.
  *
  *  @since 2.0
  */
-public class NoSuchPageTag
-    extends WikiTagBase
-{
+public class NoSuchPageTag extends WikiTagBase {
+
     private static final long serialVersionUID = 0L;
     
     private String m_pageName;
 
-    public void initTag()
-    {
+    public void initTag() {
         super.initTag();
         m_pageName = null;
     }
 
-    public void setPage( String name )
+    public void setPage( final String name )
     {
         m_pageName = name;
     }
@@ -52,26 +50,17 @@ public class NoSuchPageTag
         return m_pageName;
     }
 
-    public int doWikiStartTag()
-        throws IOException,
-               ProviderException
-    {
-        WikiEngine engine = m_wikiContext.getEngine();
-        WikiPage   page;
+    public int doWikiStartTag() throws IOException, ProviderException {
+        final WikiEngine engine = m_wikiContext.getEngine();
+        final WikiPage page;
 
-        if( m_pageName == null )
-        {
+        if( m_pageName == null ) {
             page = m_wikiContext.getPage();
+        } else {
+            page = engine.getPageManager().getPage( m_pageName );
         }
-        else
-        {
-            page = engine.getPage( m_pageName );
-        }
-
-        // System.out.println("Checking "+page);
 
-        if( page != null && engine.pageExists( page.getName(), page.getVersion() ) )
-        {
+        if( page != null && engine.pageExists( page.getName(), page.getVersion() ) ) {
             return SKIP_BODY;
         }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java
index 0c41a28..a6a246b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/PermissionTag.java
@@ -31,7 +31,6 @@ import org.apache.wiki.auth.permissions.WikiPermission;
 import org.apache.wiki.ui.Command;
 import org.apache.wiki.ui.GroupCommand;
 
-import java.io.IOException;
 import java.security.Permission;
 
 /**
@@ -60,9 +59,8 @@ import java.security.Permission;
  *  
  *  @since 2.0
  */
-public class PermissionTag
-    extends WikiTagBase
-{
+public class PermissionTag extends WikiTagBase {
+
     private static final String ALL_PERMISSION   = "allPermission";
     private static final String CREATE_GROUPS    = "createGroups";
     private static final String CREATE_PAGES     = "createPages";
@@ -82,8 +80,7 @@ public class PermissionTag
      * Initializes the tag.
      */
     @Override
-    public void initTag()
-    {
+    public void initTag() {
         super.initTag();
         m_permissionList = null;
     }
@@ -93,7 +90,7 @@ public class PermissionTag
      * 
      * @param permission A list of permissions
      */
-    public void setPermission( String permission )
+    public void setPermission( final String permission )
     {
         m_permissionList = StringUtils.split(permission,'|');
     }
@@ -101,67 +98,46 @@ public class PermissionTag
     /**
      *  Checks a single permission.
      *  
-     *  @param permission
+     *  @param permission permission to check for
      *  @return true if granted, false if not
      */
-    private boolean checkPermission( String permission )
-    {
-        WikiSession session        = m_wikiContext.getWikiSession();
-        WikiPage    page           = m_wikiContext.getPage();
-        AuthorizationManager mgr   = m_wikiContext.getEngine().getAuthorizationManager();
-        boolean gotPermission     = false;
+    private boolean checkPermission( final String permission ) {
+        final WikiSession session        = m_wikiContext.getWikiSession();
+        final WikiPage    page           = m_wikiContext.getPage();
+        final AuthorizationManager mgr   = m_wikiContext.getEngine().getAuthorizationManager();
+        boolean gotPermission      = false;
         
-        if ( CREATE_GROUPS.equals( permission ) || CREATE_PAGES.equals( permission )
-            || EDIT_PREFERENCES.equals( permission ) || EDIT_PROFILE.equals( permission )
-            || LOGIN.equals( permission ) )
-        {
+        if ( CREATE_GROUPS.equals( permission ) || CREATE_PAGES.equals( permission ) || EDIT_PREFERENCES.equals( permission ) || EDIT_PROFILE.equals( permission ) || LOGIN.equals( permission ) ) {
             gotPermission = mgr.checkPermission( session, new WikiPermission( page.getWiki(), permission ) );
-        }
-        else if ( VIEW_GROUP.equals( permission ) 
-            || EDIT_GROUP.equals( permission )
-            || DELETE_GROUP.equals( permission ) )
-        {
-            Command command = m_wikiContext.getCommand();
+        } else if ( VIEW_GROUP.equals( permission ) || EDIT_GROUP.equals( permission ) || DELETE_GROUP.equals( permission ) )  {
+            final Command command = m_wikiContext.getCommand();
             gotPermission = false;
-            if ( command instanceof GroupCommand && command.getTarget() != null )
-            {
-                GroupPrincipal group = (GroupPrincipal)command.getTarget();
-                String groupName = group.getName();
+            if ( command instanceof GroupCommand && command.getTarget() != null ) {
+                final GroupPrincipal group = (GroupPrincipal)command.getTarget();
+                final String groupName = group.getName();
                 String action = "view";
-                if( EDIT_GROUP.equals( permission ) )
-                {
+                if( EDIT_GROUP.equals( permission ) ) {
                     action = "edit";
-                }
-                else if ( DELETE_GROUP.equals( permission ) )
-                {
+                } else if ( DELETE_GROUP.equals( permission ) ) {
                     action = "delete";
                 }
                 gotPermission = mgr.checkPermission( session, new GroupPermission( groupName, action ) );
             }
-        }
-        else if ( ALL_PERMISSION.equals( permission ) )
-        {
+        } else if ( ALL_PERMISSION.equals( permission ) ) {
             gotPermission = mgr.checkPermission( session, new AllPermission( m_wikiContext.getEngine().getApplicationName() ) );
-        }
-        else if ( page != null )
-        {
+        } else if ( page != null ) {
             //
-            //  Edit tag also checks that we're not trying to edit an
-            //  old version: they cannot be edited.
+            //  Edit tag also checks that we're not trying to edit an old version: they cannot be edited.
             //
-            if( EDIT.equals(permission) )
-            {
-                WikiPage latest = m_wikiContext.getEngine().getPage( page.getName() );
-                if( page.getVersion() != WikiProvider.LATEST_VERSION &&
-                    latest.getVersion() != page.getVersion() )
-                {
+            if( EDIT.equals(permission) ) {
+                final WikiPage latest = m_wikiContext.getEngine().getPageManager().getPage( page.getName() );
+                if( page.getVersion() != WikiProvider.LATEST_VERSION && latest.getVersion() != page.getVersion() ) {
                     return false;
                 }
             }
 
-            Permission p = PermissionFactory.getPagePermission( page, permission );
-            gotPermission = mgr.checkPermission( session,
-                                                  p );
+            final Permission p = PermissionFactory.getPagePermission( page, permission );
+            gotPermission = mgr.checkPermission( session, p );
         }
         
         return gotPermission;
@@ -170,29 +146,20 @@ public class PermissionTag
     /**
      * Initializes the tag.
      * @return the result of the tag: SKIP_BODY or EVAL_BODY_CONTINUE
-     * @throws IOException this exception will never be thrown
      */
     @Override
-    public final int doWikiStartTag()
-        throws IOException
-    {
-        for( int i = 0; i < m_permissionList.length; i++ )
-        {
-            String perm = m_permissionList[i];
-         
-            boolean hasPermission = false;
-
-            if( perm.charAt(0) == '!' )
-            {
-                hasPermission = !checkPermission( perm.substring(1) );
-            }
-            else
-            {
+    public final int doWikiStartTag() {
+        for( final String perm : m_permissionList ) {
+            final boolean hasPermission;
+            if( perm.charAt( 0 ) == '!' ) {
+                hasPermission = !checkPermission( perm.substring( 1 ) );
+            } else {
                 hasPermission = checkPermission( perm );
             }
-            
-            if( hasPermission )
+
+            if( hasPermission ) {
                 return EVAL_BODY_INCLUDE;
+            }
         }
 
         return SKIP_BODY;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java b/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java
index 34e7e7f..72ee1b3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tasks/pages/SaveWikiPageTask.java
@@ -58,7 +58,7 @@ public class SaveWikiPageTask extends Task {
         engine.getPageManager().putPageText(page, proposedText);
 
         // Refresh the context for post save filtering.
-        engine.getPage(page.getName());
+        engine.getPageManager().getPage(page.getName());
         engine.textToHTML(context, proposedText);
         engine.getFilterManager().doPostSaveFiltering(context, proposedText);
 
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 c3ca5de..5c7af48 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
@@ -486,7 +486,7 @@ public final class CommandResolver
             }
         }
 
-        wikipage = m_engine.getPage( page, version );
+        wikipage = m_engine.getPageManager().getPage( page, version );
 
         if ( wikipage == 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 a61e87f..db56148 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
@@ -18,13 +18,6 @@
  */
 package org.apache.wiki.xmlrpc;
 
-import java.io.ByteArrayInputStream;
-import java.util.Collections;
-import java.util.Date;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -41,6 +34,13 @@ import org.apache.wiki.plugin.WeblogEntryPlugin;
 import org.apache.wiki.plugin.WeblogPlugin;
 import org.apache.xmlrpc.XmlRpcException;
 
+import java.io.ByteArrayInputStream;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+
 /**
  *  Provides handlers for all RPC routines of the MetaWeblog API.
  *  <P>
@@ -122,7 +122,7 @@ public class MetaWeblogHandler
                                     String password )
         throws XmlRpcException
     {
-        WikiPage page = m_context.getEngine().getPage( blogid );
+        WikiPage page = m_context.getEngine().getPageManager().getPage( blogid );
 
         checkPermissions( page, username, password, "view" );
 
@@ -147,9 +147,9 @@ public class MetaWeblogHandler
      */
     private Hashtable<String,Object> makeEntry( WikiPage page )
     {
-        Hashtable<String, Object> ht = new Hashtable<String, Object>();
+        Hashtable<String, Object> ht = new Hashtable<>();
 
-        WikiPage firstVersion = m_context.getEngine().getPage( page.getName(), 1 );
+        WikiPage firstVersion = m_context.getEngine().getPageManager().getPage( page.getName(), 1 );
 
         ht.put("dateCreated", firstVersion.getLastModified());
         ht.put("link", getURL(page.getName()));
@@ -201,7 +201,7 @@ public class MetaWeblogHandler
 
         log.info( "metaWeblog.getRecentPosts() called");
 
-        WikiPage page = m_context.getEngine().getPage( blogid );
+        WikiPage page = m_context.getEngine().getPageManager().getPage( blogid );
 
         checkPermissions( page, username, password, "view" );
 
@@ -256,7 +256,7 @@ public class MetaWeblogHandler
         log.info("metaWeblog.newPost() called");
         WikiEngine engine = m_context.getEngine();
 
-        WikiPage page = engine.getPage( blogid );
+        WikiPage page = engine.getPageManager().getPage( blogid );
         checkPermissions( page, username, password, "createPages" );
 
         try
@@ -312,7 +312,7 @@ public class MetaWeblogHandler
 
         log.info("metaWeblog.newMediaObject() called");
 
-        WikiPage page = engine.getPage( blogid );
+        WikiPage page = engine.getPageManager().getPage( blogid );
         checkPermissions( page, username, password, "upload" );
 
         String name = (String) content.get( "name" );
@@ -357,7 +357,7 @@ public class MetaWeblogHandler
         log.info("metaWeblog.editPost("+postid+") called");
 
         // FIXME: Is postid correct?  Should we determine it from the page name?
-        WikiPage page = engine.getPage( postid );
+        WikiPage page = engine.getPageManager().getPage( postid );
         checkPermissions( page, username, password, "edit" );
 
         try
@@ -396,7 +396,7 @@ public class MetaWeblogHandler
     {
         String wikiname = "FIXME";
 
-        WikiPage page = m_context.getEngine().getPage( wikiname );
+        WikiPage page = m_context.getEngine().getPageManager().getPage( wikiname );
 
         checkPermissions( page, username, password, "view" );
 
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 9fbfe9b..0dc2359 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
@@ -18,14 +18,6 @@
  */
 package org.apache.wiki.xmlrpc;
 
-import java.nio.charset.StandardCharsets;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Vector;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.LinkCollector;
 import org.apache.wiki.WikiContext;
@@ -37,6 +29,14 @@ import org.apache.wiki.auth.permissions.PermissionFactory;
 import org.apache.wiki.util.TextUtil;
 import org.apache.xmlrpc.XmlRpcException;
 
+import java.nio.charset.StandardCharsets;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
 /**
  *  Provides handlers for all RPC routines.
  *
@@ -188,7 +188,7 @@ public class RPCHandler
             throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );
         }
 
-        WikiPage p = m_engine.getPage( pagename );
+        WikiPage p = m_engine.getPageManager().getPage( pagename );
 
         checkPermission( PermissionFactory.getPagePermission( p, PagePermission.VIEW_ACTION ) );
 
@@ -199,7 +199,7 @@ public class RPCHandler
         throws XmlRpcException
     {
         pagename = parsePageCheckCondition( pagename );
-        return encodeWikiPage( m_engine.getPage(pagename) );
+        return encodeWikiPage( m_engine.getPageManager().getPage(pagename) );
     }
 
     public Hashtable getPageInfoVersion( String pagename, int version )
@@ -207,7 +207,7 @@ public class RPCHandler
     {
         pagename = parsePageCheckCondition( pagename );
 
-        return encodeWikiPage( m_engine.getPage( pagename, version ) );
+        return encodeWikiPage( m_engine.getPageManager().getPage( pagename, version ) );
     }
 
     public byte[] getPage( String pagename )
@@ -249,7 +249,7 @@ public class RPCHandler
     {
         pagename = parsePageCheckCondition( pagename );
 
-        WikiPage page = m_engine.getPage( pagename );
+        WikiPage page = m_engine.getPageManager().getPage( pagename );
         String pagedata = m_engine.getPureText( page );
 
         LinkCollector localCollector = new LinkCollector();
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 667c7fc..3b5cff0 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
@@ -18,13 +18,6 @@
  */
 package org.apache.wiki.xmlrpc;
 
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Vector;
-
 import org.apache.wiki.LinkCollector;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -34,6 +27,13 @@ import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.auth.permissions.PermissionFactory;
 import org.apache.xmlrpc.XmlRpcException;
 
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
 /**
  *  Provides handlers for all RPC routines.  These routines are used by
  *  the UTF-8 interface.
@@ -149,7 +149,7 @@ public class RPCHandlerUTF8
             throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );
         }
 
-        WikiPage p = m_engine.getPage( pagename );
+        WikiPage p = m_engine.getPageManager().getPage( pagename );
 
         checkPermission( PermissionFactory.getPagePermission( p, PagePermission.VIEW_ACTION ) );
         return pagename;
@@ -160,7 +160,7 @@ public class RPCHandlerUTF8
     {
         pagename = parsePageCheckCondition( pagename );
 
-        return encodeWikiPage( m_engine.getPage(pagename) );
+        return encodeWikiPage( m_engine.getPageManager().getPage(pagename) );
     }
 
     public Hashtable getPageInfoVersion( String pagename, int version )
@@ -168,7 +168,7 @@ public class RPCHandlerUTF8
     {
         pagename = parsePageCheckCondition( pagename );
 
-        return encodeWikiPage( m_engine.getPage( pagename, version ) );
+        return encodeWikiPage( m_engine.getPageManager().getPage( pagename, version ) );
     }
 
     public String getPage( String pagename )
@@ -210,7 +210,7 @@ public class RPCHandlerUTF8
     {
         pagename = parsePageCheckCondition( pagename );
 
-        WikiPage page = m_engine.getPage( pagename );
+        WikiPage page = m_engine.getPageManager().getPage( pagename );
         String pagedata = m_engine.getPureText( page );
 
         LinkCollector localCollector = new LinkCollector();
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 6115fea..0437b48 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -312,20 +312,15 @@ public class TestEngine extends WikiEngine
     /**
      *  Deletes all attachments related to the given page.
      */
-    public static void deleteAttachments( String page )
-    {
-        Properties properties = getTestProperties();
-
-        try
-        {
-            String files = properties.getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
+    public static void deleteAttachments( final String page ) {
+        final Properties properties = getTestProperties();
 
-            File f = new File( files, TextUtil.urlEncodeUTF8( page ) + BasicAttachmentProvider.DIR_EXTENSION );
+        try {
+            final String files = properties.getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
+            final File f = new File( files, TextUtil.urlEncodeUTF8( page ) + BasicAttachmentProvider.DIR_EXTENSION );
 
             deleteAll( f );
-        }
-        catch( Exception e )
-        {
+        } catch( final Exception e ) {
             log.error("Could not remove attachments.",e);
         }
     }
@@ -333,17 +328,13 @@ public class TestEngine extends WikiEngine
     /**
      *  Makes a temporary file with some content, and returns a handle to it.
      */
-    public File makeAttachmentFile()
-        throws Exception
-    {
-        File tmpFile = File.createTempFile("test","txt");
+    public File makeAttachmentFile() throws Exception {
+        final File tmpFile = File.createTempFile("test","txt");
         tmpFile.deleteOnExit();
 
-        FileWriter out = new FileWriter( tmpFile );
-
-        FileUtil.copyContents( new StringReader( "asdfa???dfzbvasdjkfbwfkUg783gqdwog" ), out );
-
-        out.close();
+        try( final FileWriter out = new FileWriter( tmpFile ) ) {
+            FileUtil.copyContents( new StringReader( "asdfa???dfzbvasdjkfbwfkUg783gqdwog" ), out );
+        }
 
         return tmpFile;
     }
@@ -354,12 +345,9 @@ public class TestEngine extends WikiEngine
      * @param attachmentName
      * @param data
      */
-    public void addAttachment( String pageName, String attachmentName, byte[] data )
-        throws ProviderException, IOException
-    {
-        Attachment att = new Attachment(this,pageName,attachmentName);
-
-        getAttachmentManager().storeAttachment(att, new ByteArrayInputStream(data));
+    public void addAttachment( final String pageName, final String attachmentName, final byte[] data ) throws ProviderException, IOException {
+        final Attachment att = new Attachment( this,pageName,attachmentName );
+        getAttachmentManager().storeAttachment( att, new ByteArrayInputStream( data ) );
     }
 
     /**
@@ -371,36 +359,28 @@ public class TestEngine extends WikiEngine
      * @param content
      * @throws WikiException
      */
-    public void saveText( String pageName, String content )
-        throws WikiException
-    {
+    public void saveText( final String pageName, final String content ) throws WikiException {
         // Build new request and associate our admin session
-        MockHttpServletRequest request = newHttpRequest();
-        WikiSession wikiSession = SessionMonitor.getInstance( this ).find( request.getSession() );
-        this.getAuthenticationManager().login( wikiSession, request,
-                Users.ADMIN,
-                Users.ADMIN_PASS );
+        final MockHttpServletRequest request = newHttpRequest();
+        final WikiSession wikiSession = SessionMonitor.getInstance( this ).find( request.getSession() );
+        this.getAuthenticationManager().login( wikiSession, request, Users.ADMIN, Users.ADMIN_PASS );
 
         // Create page and wiki context
-        WikiPage page = new WikiPage( this, pageName );
-        WikiContext context = new WikiContext( this, request, page );
+        final WikiPage page = new WikiPage( this, pageName );
+        final WikiContext context = new WikiContext( this, request, page );
         saveText( context, content );
     }
 
-    public void saveTextAsJanne( String pageName, String content )
-        throws WikiException
-    {
+    public void saveTextAsJanne( final String pageName, final String content ) throws WikiException {
         // Build new request and associate our Janne session
-        MockHttpServletRequest request = newHttpRequest();
-        WikiSession wikiSession = SessionMonitor.getInstance( this ).find( request.getSession() );
-        this.getAuthenticationManager().login( wikiSession, request,
-                Users.JANNE,
-                Users.JANNE_PASS );
+        final MockHttpServletRequest request = newHttpRequest();
+        final WikiSession wikiSession = SessionMonitor.getInstance( this ).find( request.getSession() );
+        this.getAuthenticationManager().login( wikiSession, request, Users.JANNE, Users.JANNE_PASS );
 
         // Create page and wiki context
-        WikiPage page = new WikiPage( this, pageName );
+        final WikiPage page = new WikiPage( this, pageName );
         page.setAuthor(Users.JANNE);
-        WikiContext context = new WikiContext( this, request, page );
+        final WikiContext context = new WikiContext( this, request, page );
         saveText( context, content );
     }
 
@@ -411,21 +391,17 @@ public class TestEngine extends WikiEngine
      * @param pagename name of the page.
      * @return (english) contents corresponding to the given page name.
      */
-    public String getI18nHTML( String pagename ) {
-        WikiPage page = getPage( pagename, WikiPageProvider.LATEST_VERSION );
-        WikiContext context = new WikiContext( this, newHttpRequest(), page );
+    public String getI18nHTML( final String pagename ) {
+        final WikiPage page = getPageManager().getPage( pagename, WikiPageProvider.LATEST_VERSION );
+        final WikiContext context = new WikiContext( this, newHttpRequest(), page );
         context.setRequestContext( WikiContext.NONE );
         return getHTML( context, page );
     }
 
-    public static void trace()
-    {
-        try
-        {
+    public static void trace() {
+        try {
             throw new Exception("Foo");
-        }
-        catch( Exception e )
-        {
+        } catch( final Exception e ) {
             e.printStackTrace();
         }
     }
@@ -436,7 +412,7 @@ public class TestEngine extends WikiEngine
      * @return the corrected/clean properties
      */
     private static Properties cleanTestProps( final Properties props ) {
-        long millis = System.currentTimeMillis();
+        final long millis = System.currentTimeMillis();
         props.put( AuthenticationManager.PROP_LOGIN_THROTTLING, "false" );
         props.setProperty( "jspwiki.fileSystemProvider.pageDir", cleanNewDirFrom( props.getProperty( "jspwiki.fileSystemProvider.pageDir" ), millis ) );
         props.setProperty( "jspwiki.basicAttachmentProvider.storageDir", cleanNewDirFrom( props.getProperty( "jspwiki.basicAttachmentProvider.storageDir" ), millis ) );
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 4cf1930..ce676ce 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -24,9 +24,7 @@ import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.providers.BasicAttachmentProvider;
-import org.apache.wiki.providers.CachingProvider;
 import org.apache.wiki.providers.FileSystemProvider;
-import org.apache.wiki.providers.VerySimpleProvider;
 import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.util.TextUtil;
 import org.junit.jupiter.api.AfterEach;
@@ -39,55 +37,42 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Properties;
 
-public class WikiEngineTest
-{
+public class WikiEngineTest {
+
     public static final String NAME1 = "Test1";
-    public static final long PAGEPROVIDER_RESCAN_PERIOD = 2;
 
     Properties props = TestEngine.getTestProperties();
-
     TestEngine m_engine;
 
-
     @BeforeEach
-    public void setUp()
-        throws Exception
-    {
+    public void setUp() {
         props.setProperty( WikiEngine.PROP_MATCHPLURALS, "true" );
-
-        CacheManager.getInstance().removeAllCaches();
-
-        TestEngine.emptyWorkDir();
-        m_engine = new TestEngine(props);
+        m_engine = TestEngine.build( props );
     }
 
     @AfterEach
-    public void tearDown()
-    {
-        String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
-
-        if( files != null )
-        {
-            File f = new File( files );
+    public void tearDown() {
+        final String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
 
+        if( files != null ) {
+            final File f = new File( files );
             TestEngine.deleteAll( f );
         }
 
         TestEngine.emptyWorkDir();
+        CacheManager.getInstance().removeAllCaches();
     }
 
     @Test
-    public void testNonExistentDirectory()
-        throws Exception
-    {
-        String tmpdir = "./target";
-        String dirname = "non-existent-directory";
-        String newdir = tmpdir + File.separator + dirname;
+    public void testNonExistentDirectory() throws Exception {
+        final String tmpdir = "./target";
+        final String dirname = "non-existent-directory";
+        final String newdir = tmpdir + File.separator + dirname;
 
         props.setProperty( FileSystemProvider.PROP_PAGEDIR, newdir );
         new TestEngine( props );
 
-        File f = new File( props.getProperty( FileSystemProvider.PROP_PAGEDIR ) );
+        final File f = new File( props.getProperty( FileSystemProvider.PROP_PAGEDIR ) );
         Assertions.assertTrue( f.exists(), "didn't create it" );
         Assertions.assertTrue( f.isDirectory(), "isn't a dir" );
 
@@ -98,30 +83,21 @@ public class WikiEngineTest
      *  Check that calling pageExists( String ) works.
      */
     @Test
-    public void testNonExistentPage()
-        throws Exception
-    {
-        String pagename = "Test1";
-
-        Assertions.assertEquals( false, m_engine.pageExists( pagename ), "Page already exists" );
+    public void testNonExistentPage() {
+        Assertions.assertFalse( m_engine.pageExists( NAME1 ), "Page already exists" );
     }
 
     /**
      *  Check that calling pageExists( WikiPage ) works.
      */
     @Test
-    public void testNonExistentPage2()
-        throws Exception
-    {
-        WikiPage page = new WikiPage(m_engine, "Test1");
-
-        Assertions.assertEquals( false, m_engine.pageExists( page ), "Page already exists" );
+    public void testNonExistentPage2() throws Exception {
+        final WikiPage page = new WikiPage(m_engine, NAME1 );
+        Assertions.assertFalse( m_engine.pageExists( page ), "Page already exists" );
     }
 
     @Test
-    public void testFinalPageName()
-        throws Exception
-    {
+    public void testFinalPageName() throws Exception {
         m_engine.saveText( "Foobar", "1" );
         m_engine.saveText( "Foobars", "2" );
 
@@ -130,9 +106,7 @@ public class WikiEngineTest
     }
 
     @Test
-    public void testFinalPageNameSingular()
-        throws Exception
-    {
+    public void testFinalPageNameSingular() throws Exception {
         m_engine.saveText( "Foobar", "1" );
 
         Assertions.assertEquals( "Foobar", m_engine.getFinalPageName( "Foobars" ), "plural mistake" );
@@ -140,9 +114,7 @@ public class WikiEngineTest
     }
 
     @Test
-    public void testFinalPageNamePlural()
-        throws Exception
-    {
+    public void testFinalPageNamePlural() throws Exception {
         m_engine.saveText( "Foobars", "1" );
 
         Assertions.assertEquals( "Foobars", m_engine.getFinalPageName( "Foobars" ), "plural mistake" );
@@ -150,9 +122,7 @@ public class WikiEngineTest
     }
 
     @Test
-    public void testPutPage()
-        throws Exception
-    {
+    public void testPutPage() throws Exception {
         String text = "Foobar.\r\n";
         String name = NAME1;
 
@@ -284,96 +254,6 @@ public class WikiEngineTest
     }
 
     /**
-     *  English articles too, pathological case...
-     */
-    /*
-    @Test
-    public void testBeautifyTitleArticle2()
-    {
-        String src = "ThisIsAJSPWikiPage";
-
-        Assertions.assertEquals("This Is A JSP Wiki Page", m_engine.beautifyTitle( src ) );
-    }
-    */
-
-    @Test
-    public void testLatestGet()
-        throws Exception
-    {
-        props.setProperty( "jspwiki.pageProvider",
-                           "org.apache.wiki.providers.VerySimpleProvider" );
-        props.setProperty( "jspwiki.usePageCache", "false" );
-
-        WikiEngine engine = new TestEngine( props );
-
-        WikiPage p = engine.getPage( "test", -1 );
-
-        VerySimpleProvider vsp = (VerySimpleProvider) engine.getPageManager().getProvider();
-
-        Assertions.assertEquals( "test", vsp.m_latestReq, "wrong page" );
-        Assertions.assertEquals( -1, vsp.m_latestVers, "wrong version" );
-        Assertions.assertNotNull( p, "null" );
-    }
-
-    @Test
-    public void testLatestGet2()
-        throws Exception
-    {
-        props.setProperty( "jspwiki.pageProvider",
-                           "org.apache.wiki.providers.VerySimpleProvider" );
-        props.setProperty( "jspwiki.usePageCache", "false" );
-
-        WikiEngine engine = new TestEngine( props );
-
-        String p = engine.getText( "test", -1 );
-
-        VerySimpleProvider vsp = (VerySimpleProvider) engine.getPageManager().getProvider();
-
-        Assertions.assertEquals( "test", vsp.m_latestReq, "wrong page" );
-        Assertions.assertEquals( -1, vsp.m_latestVers, "wrong version" );
-        Assertions.assertNotNull( p, "null" );
-    }
-
-    @Test
-    public void testLatestGet3()
-        throws Exception
-    {
-        props.setProperty( "jspwiki.pageProvider",
-                           "org.apache.wiki.providers.VerySimpleProvider" );
-        props.setProperty( "jspwiki.usePageCache", "false" );
-
-        WikiEngine engine = new TestEngine( props );
-
-        String p = engine.getHTML( "test", -1 );
-
-        VerySimpleProvider vsp = (VerySimpleProvider) engine.getPageManager().getProvider();
-
-        Assertions.assertEquals( "test", vsp.m_latestReq, "wrong page" );
-        Assertions.assertEquals( 5, vsp.m_latestVers, "wrong version" );
-        Assertions.assertNotNull( p, "null" );
-    }
-
-    @Test
-    public void testLatestGet4()
-        throws Exception
-    {
-        props.setProperty( "jspwiki.pageProvider",
-                           "org.apache.wiki.providers.VerySimpleProvider" );
-        props.setProperty( "jspwiki.usePageCache", "true" );
-
-        WikiEngine engine = new TestEngine( props );
-
-        String p = engine.getHTML( VerySimpleProvider.PAGENAME, -1 );
-
-        CachingProvider cp = (CachingProvider)engine.getPageManager().getProvider();
-        VerySimpleProvider vsp = (VerySimpleProvider) cp.getRealProvider();
-
-        Assertions.assertEquals( VerySimpleProvider.PAGENAME, vsp.m_latestReq, "wrong page" );
-        Assertions.assertEquals( -1, vsp.m_latestVers,  "wrong version" );
-        Assertions.assertNotNull( p, "null" );
-    }
-
-    /**
      *  Checks, if ReferenceManager is informed of new attachments.
      */
     @Test
@@ -552,141 +432,6 @@ public class WikiEngineTest
         }
     }
 
-
-
-
-    @Test
-    public void testDeletePage()
-        throws Exception
-    {
-        m_engine.saveText( NAME1, "Test" );
-
-        String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
-        File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );
-
-        Assertions.assertTrue( saved.exists(), "Didn't create it!" );
-
-        WikiPage page = m_engine.getPage( NAME1, WikiProvider.LATEST_VERSION );
-
-        m_engine.getPageManager().deletePage( page.getName() );
-
-        Assertions.assertFalse( saved.exists(), "Page has not been removed!" );
-    }
-
-
-    @Test
-    public void testDeletePageAndAttachments()
-        throws Exception
-    {
-        m_engine.saveText( NAME1, "Test" );
-
-        Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
-        att.setAuthor( "FirstPost" );
-        m_engine.getAttachmentManager().storeAttachment( att, m_engine.makeAttachmentFile() );
-
-        String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
-        File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );
-
-        String atts = props.getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
-        File attfile = new File( atts, NAME1+"-att/TestAtt.txt-dir" );
-
-        Assertions.assertTrue( saved.exists(), "Didn't create it!" );
-
-        Assertions.assertTrue( attfile.exists(), "Attachment dir does not exist" );
-
-        WikiPage page = m_engine.getPage( NAME1, WikiProvider.LATEST_VERSION );
-
-        m_engine.getPageManager().deletePage( page.getName() );
-
-        Assertions.assertFalse( saved.exists(), "Page has not been removed!" );
-        Assertions.assertFalse( attfile.exists(), "Attachment has not been removed" );
-    }
-
-    @Test
-    public void testDeletePageAndAttachments2()
-        throws Exception
-    {
-        m_engine.saveText( NAME1, "Test" );
-
-        Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
-        att.setAuthor( "FirstPost" );
-        m_engine.getAttachmentManager().storeAttachment( att, m_engine.makeAttachmentFile() );
-
-        String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
-        File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );
-
-        String atts = props.getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
-        File attfile = new File( atts, NAME1+"-att/TestAtt.txt-dir" );
-
-        Assertions.assertTrue( saved.exists(), "Didn't create it!" );
-
-        Assertions.assertTrue( attfile.exists(), "Attachment dir does not exist" );
-
-        WikiPage page = m_engine.getPage( NAME1, WikiProvider.LATEST_VERSION );
-
-        Assertions.assertNotNull( page, "page" );
-
-        att = m_engine.getAttachmentManager().getAttachmentInfo(NAME1+"/TestAtt.txt");
-
-        m_engine.getPageManager().deletePage(att.getName());
-
-        m_engine.getPageManager().deletePage( NAME1 );
-
-        Assertions.assertNull( m_engine.getPage(NAME1), "Page not removed" );
-        Assertions.assertNull( m_engine.getPage(NAME1+"/TestAtt.txt"), "Att not removed" );
-
-        Collection< String > refs = m_engine.getReferenceManager().findReferrers(NAME1);
-
-        Assertions.assertNull( refs, "referrers" );
-    }
-
-    @Test
-    public void testDeleteVersion()
-        throws Exception
-    {
-        props.setProperty( "jspwiki.pageProvider", "VersioningFileProvider" );
-
-        TestEngine engine = new TestEngine( props );
-        engine.saveText( NAME1, "Test1" );
-        engine.saveText( NAME1, "Test2" );
-        engine.saveText( NAME1, "Test3" );
-
-        WikiPage page = engine.getPage( NAME1, 3 );
-
-        engine.getPageManager().deleteVersion( page );
-
-        Assertions.assertNull( engine.getPage( NAME1, 3 ), "got page" );
-
-        String content = engine.getText( NAME1, WikiProvider.LATEST_VERSION );
-
-        Assertions.assertEquals( "Test2", content.trim(), "content" );
-    }
-
-    @Test
-    public void testDeleteVersion2()
-        throws Exception
-    {
-        props.setProperty( "jspwiki.pageProvider", "VersioningFileProvider" );
-
-        TestEngine engine = new TestEngine( props );
-        engine.saveText( NAME1, "Test1" );
-        engine.saveText( NAME1, "Test2" );
-        engine.saveText( NAME1, "Test3" );
-
-        WikiPage page = engine.getPage( NAME1, 1 );
-
-        engine.getPageManager().deleteVersion( page );
-
-        Assertions.assertNull( engine.getPage( NAME1, 1 ), "got page" );
-
-        String content = engine.getText( NAME1, WikiProvider.LATEST_VERSION );
-
-        Assertions.assertEquals( "Test3", content.trim(), "content" );
-
-        Assertions.assertEquals( "", engine.getText(NAME1, 1).trim(), "content1" );
-    }
-
-
     /**
      *  Tests BugReadingOfVariableNotWorkingForOlderVersions
      * @throws Exception
@@ -705,9 +450,8 @@ public class WikiEngineTest
 
         engine.saveText( NAME1, "[{SET foo=notbar}]");
 
-        WikiPage v1 = engine.getPage( NAME1, 1 );
-
-        WikiPage v2 = engine.getPage( NAME1, 2 );
+        WikiPage v1 = engine.getPageManager().getPage( NAME1, 1 );
+        WikiPage v2 = engine.getPageManager().getPage( NAME1, 2 );
 
         Assertions.assertEquals( "bar", v1.getAttribute("foo"), "V1" );
 
@@ -751,7 +495,7 @@ public class WikiEngineTest
         Collection< String > pages = m_engine.getReferenceManager().findReferrers( "RenameBugTestPage" );
         Assertions.assertEquals( "OldNameTestPage", pages.iterator().next(), "has one" );
 
-        WikiContext ctx = new WikiContext( m_engine, m_engine.getPage("OldNameTestPage") );
+        WikiContext ctx = new WikiContext( m_engine, m_engine.getPageManager().getPage("OldNameTestPage") );
 
         m_engine.getPageRenamer().renamePage( ctx, "OldNameTestPage", "NewNameTestPage", true );
 
@@ -778,7 +522,7 @@ public class WikiEngineTest
 
         for( int i = 0; i < 5; i++ )
         {
-            WikiPage p2 = (WikiPage)m_engine.getPage( NAME1 ).clone();
+            WikiPage p2 = (WikiPage)m_engine.getPageManager().getPage( NAME1 ).clone();
             p2.removeAttribute(WikiPage.CHANGENOTE);
 
             context.setPage( p2 );
@@ -786,7 +530,7 @@ public class WikiEngineTest
             m_engine.saveText( context, "test"+i );
         }
 
-        WikiPage p3 = m_engine.getPage( NAME1, -1 );
+        WikiPage p3 = m_engine.getPageManager().getPage( NAME1, -1 );
 
         Assertions.assertEquals( null, p3.getAttribute(WikiPage.CHANGENOTE) );
     }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
index 674c821..b199b14 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
@@ -277,7 +277,7 @@ public class AuthorizationManagerTest
         att.setAuthor( "FirstPost" );
         m_engine.getAttachmentManager().storeAttachment( att, f );
 
-        Attachment p = (Attachment) m_engine.getPage( "Test/test1.txt" );
+        Attachment p = (Attachment) m_engine.getPageManager().getPage( "Test/test1.txt" );
         Permission view = PermissionFactory.getPagePermission( p, "view" );
         Permission edit = PermissionFactory.getPagePermission( p, "edit" );
 
@@ -309,7 +309,7 @@ public class AuthorizationManagerTest
         att.setAuthor( "FirstPost" );
         m_engine.getAttachmentManager().storeAttachment( att, f );
 
-        Attachment p = (Attachment) m_engine.getPage( "Test/test1.txt" );
+        Attachment p = (Attachment) m_engine.getPageManager().getPage( "Test/test1.txt" );
         Permission view = PermissionFactory.getPagePermission( p, "view" );
         Permission edit = PermissionFactory.getPagePermission( p, "edit" );
 
@@ -450,7 +450,7 @@ public class AuthorizationManagerTest
         String src = "[{ALLOW edit Alice}] ";
         m_engine.saveText( "Test", src );
 
-        WikiPage p = m_engine.getPage( "Test" );
+        WikiPage p = m_engine.getPageManager().getPage( "Test" );
         Permission view = PermissionFactory.getPagePermission( p, "view" );
         Permission edit = PermissionFactory.getPagePermission( p, "edit" );
 
@@ -572,7 +572,7 @@ public class AuthorizationManagerTest
         String src = "[{ALLOW edit Authenticated}] ";
         m_engine.saveText( "Test", src );
 
-        WikiPage p = m_engine.getPage( "Test" );
+        WikiPage p = m_engine.getPageManager().getPage( "Test" );
         Permission view = PermissionFactory.getPagePermission( p, "view" );
         Permission edit = PermissionFactory.getPagePermission( p, "edit" );
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
index e9d770d..05ad867 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
@@ -144,7 +144,7 @@ public class UserManagerTest {
         m_engine.saveText( pageName, "Test text. [{ALLOW view " + oldName + ", " + oldLogin + ", Alice}] More text." );
 
         // 3a. Make sure the page got saved, and that ONLY our test user has permission to read it.
-        WikiPage p = m_engine.getPage( pageName );
+        WikiPage p = m_engine.getPageManager().getPage( pageName );
         Assertions.assertEquals( oldPageCount + 1, pageManager.getTotalPageCount() );
         Assertions.assertNotNull( p.getAcl().getEntry( new WikiPrincipal( oldLogin ) ) );
         Assertions.assertNotNull( p.getAcl().getEntry( new WikiPrincipal( oldName ) ) );
@@ -179,7 +179,7 @@ public class UserManagerTest {
 
         // Test 3: our page should not contain the old wiki name OR login name
         // in the ACL any more (the full name is always used)
-        p = m_engine.getPage( pageName );
+        p = m_engine.getPageManager().getPage( pageName );
         Assertions.assertNull( p.getAcl().getEntry( new WikiPrincipal( oldLogin ) ) );
         Assertions.assertNull( p.getAcl().getEntry( new WikiPrincipal( oldName ) ) );
         Assertions.assertNull( p.getAcl().getEntry( new WikiPrincipal( newLogin ) ) );
@@ -204,7 +204,7 @@ public class UserManagerTest {
         // The test user should still be able to see the page (because the login name matches...)
         pageName = "TestPage2" + now;
         m_engine.saveText( pageName, "More test text. [{ALLOW view " + oldName + ", " + oldLogin + ", Alice}] More text." );
-        p = m_engine.getPage( pageName );
+        p = m_engine.getPageManager().getPage( pageName );
         Assertions.assertEquals( oldPageCount + 1, pageManager.getTotalPageCount() );
         Assertions.assertNotNull( p.getAcl().getEntry( new WikiPrincipal( oldLogin ) ) );
         Assertions.assertNotNull( p.getAcl().getEntry( new WikiPrincipal( oldName ) ) );
@@ -238,7 +238,7 @@ public class UserManagerTest {
 
         // Test 7: our page should not contain the old wiki name OR login name
         // in the ACL any more (the full name is always used)
-        p = m_engine.getPage( pageName );
+        p = m_engine.getPageManager().getPage( pageName );
         Assertions.assertNull( p.getAcl().getEntry( new WikiPrincipal( oldLogin ) ) );
         Assertions.assertNotNull( p.getAcl().getEntry( new WikiPrincipal( oldName ) ) );
         Assertions.assertNull( p.getAcl().getEntry( new WikiPrincipal( newLogin ) ) );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java
index 3326cfc..c6a92e1 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java
@@ -29,49 +29,36 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import java.security.Principal;
-import java.util.Properties;
 import java.util.regex.Matcher;
 
 public class DefaultAclManagerTest
 {
-    TestEngine m_engine;
+    TestEngine m_engine = TestEngine.build();
 
     @BeforeEach
-    public void setUp()
-        throws Exception
-    {
-        Properties props = TestEngine.getTestProperties();
-        m_engine = new TestEngine(props);
-
-        String text = "Foo";
-        m_engine.saveText( "TestDefaultPage", text );
-
-        text = "Bar. [{ALLOW edit Charlie, Herman}] ";
-        m_engine.saveText( "TestAclPage", text );
+    public void setUp() throws Exception {
+        m_engine.saveText( "TestDefaultPage", "Foo" );
+        m_engine.saveText( "TestAclPage", "Bar. [{ALLOW edit Charlie, Herman}] " );
     }
 
     @AfterEach
-    public void tearDown()
-    {
-        try
-        {
+    public void tearDown() {
+        try {
             m_engine.getPageManager().deletePage( "TestDefaultPage" );
             m_engine.getPageManager().deletePage( "TestAclPage" );
-        }
-        catch ( ProviderException e )
-        {
+        } catch ( final ProviderException e ) {
         }
     }
 
     @Test
     public void testGetPermissions()
     {
-        WikiPage page = m_engine.getPage( "TestDefaultPage" );
+        WikiPage page = m_engine.getPageManager().getPage( "TestDefaultPage" );
         Acl acl = m_engine.getAclManager().getPermissions( page );
         Assertions.assertNotNull( page.getAcl() );
         Assertions.assertTrue(page.getAcl().isEmpty());
 
-        page = m_engine.getPage( "TestAclPage" );
+        page = m_engine.getPageManager().getPage( "TestAclPage" );
         acl = m_engine.getAclManager().getPermissions( page );
         Assertions.assertNotNull( page.getAcl() );
         Assertions.assertFalse(page.getAcl().isEmpty());
@@ -172,7 +159,7 @@ public class DefaultAclManagerTest
     public void testPrintAcl()
     {
         // Verify that the printed Acl for the test page is OK
-        WikiPage page = m_engine.getPage( "TestAclPage" );
+        WikiPage page = m_engine.getPageManager().getPage( "TestAclPage" );
         Acl acl = m_engine.getAclManager().getPermissions( page );
         String aclString = DefaultAclManager.printAcl( acl );
         Assertions.assertEquals( "[{ALLOW edit Charlie,Herman}]\n", aclString );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
index c4dc60e..d6d2fb1 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
@@ -75,16 +75,16 @@ public class PageRenamerTest
 
         m_engine.saveText("TestPage", "the big lazy dog thing" );
 
-        WikiPage p = m_engine.getPage("TestPage");
+        WikiPage p = m_engine.getPageManager().getPage("TestPage");
 
         WikiContext context = new WikiContext(m_engine, p);
 
         m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", false);
 
-        WikiPage newpage = m_engine.getPage("FooTest");
+        WikiPage newpage = m_engine.getPageManager().getPage("FooTest");
 
         Assertions.assertNotNull( newpage, "no new page" );
-        Assertions.assertNull( m_engine.getPage("TestPage"), "old page not gone" );
+        Assertions.assertNull( m_engine.getPageManager().getPage("TestPage"), "old page not gone" );
 
         // Refmgr
         Collection< String > refs = m_engine.getReferenceManager().findCreated();
@@ -101,7 +101,7 @@ public class PageRenamerTest
         m_engine.saveText("TestPage", "foofoo" );
         m_engine.saveText("TestPage2", "[TestPage]");
 
-        WikiPage p = m_engine.getPage("TestPage");
+        WikiPage p = m_engine.getPageManager().getPage("TestPage");
 
         WikiContext context = new WikiContext(m_engine, p);
 
@@ -127,7 +127,7 @@ public class PageRenamerTest
         m_engine.saveText("TestPage", "foofoo" );
         m_engine.saveText("TestPage2", "TestPage");
 
-        WikiPage p = m_engine.getPage("TestPage");
+        WikiPage p = m_engine.getPageManager().getPage("TestPage");
 
         WikiContext context = new WikiContext(m_engine, p);
 
@@ -152,7 +152,7 @@ public class PageRenamerTest
         m_engine.saveText("TestPage", "foofoo" );
         m_engine.saveText("TestPage2", "[TestPage#heading1]");
 
-        WikiPage p = m_engine.getPage("TestPage");
+        WikiPage p = m_engine.getPageManager().getPage("TestPage");
 
         WikiContext context = new WikiContext(m_engine, p);
 
@@ -177,7 +177,7 @@ public class PageRenamerTest
         m_engine.saveText("TestPage", "foofoo" );
         m_engine.saveText("TestPage2", "[TestPage] [TestPage] [linktext|TestPage] TestPage [linktext|TestPage] [TestPage#Anchor] [TestPage] TestPage [TestPage]");
 
-        WikiPage p = m_engine.getPage("TestPage");
+        WikiPage p = m_engine.getPageManager().getPage("TestPage");
 
         WikiContext context = new WikiContext(m_engine, p);
 
@@ -205,7 +205,7 @@ public class PageRenamerTest
         m_engine.saveText("Test","foo");
         m_engine.saveText("TestPage2", "[Test] [Test#anchor] test Test [test] [link|test] [link|test]");
 
-        WikiPage p = m_engine.getPage("TestPage");
+        WikiPage p = m_engine.getPageManager().getPage("TestPage");
 
         WikiContext context = new WikiContext(m_engine, p);
 
@@ -225,7 +225,7 @@ public class PageRenamerTest
 
         m_engine.addAttachment("TestPage", "foo.txt", "testing".getBytes() );
         m_engine.addAttachment("TestPage", "bar.jpg", "pr0n".getBytes() );
-        WikiPage p = m_engine.getPage("TestPage");
+        WikiPage p = m_engine.getPageManager().getPage("TestPage");
 
         WikiContext context = new WikiContext(m_engine, p);
 
@@ -263,7 +263,7 @@ public class PageRenamerTest
 
         rename( "TestPage", "FooTest" );
 
-        WikiPage p = m_engine.getPage( "FooTest" );
+        WikiPage p = m_engine.getPageManager().getPage( "FooTest" );
 
         Assertions.assertNotNull( p, "no page" );
 
@@ -278,7 +278,7 @@ public class PageRenamerTest
 
         rename( "TestPage", "FooTest" );
 
-        WikiPage p = m_engine.getPage( "FooTest" );
+        WikiPage p = m_engine.getPageManager().getPage( "FooTest" );
 
         Assertions.assertNotNull( p, "no page" );
 
@@ -295,7 +295,7 @@ public class PageRenamerTest
         WikiPage p;
         rename( "TestPage", "FooTest" );
 
-        p = m_engine.getPage( "FooTest" );
+        p = m_engine.getPageManager().getPage( "FooTest" );
 
         Assertions.assertNotNull( p, "no page" );
 
@@ -304,7 +304,7 @@ public class PageRenamerTest
 
     private void rename( String src, String dst ) throws WikiException
     {
-        WikiPage p = m_engine.getPage(src);
+        WikiPage p = m_engine.getPageManager().getPage(src);
 
         WikiContext context = new WikiContext(m_engine, p);
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
index df39c25..b52b706 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
@@ -18,53 +18,215 @@
  */
 
 package org.apache.wiki.pages;
-import java.util.Properties;
 
-import org.apache.log4j.PropertyConfigurator;
+import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.WikiProvider;
+import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.providers.BasicAttachmentProvider;
 import org.apache.wiki.providers.CachingProvider;
+import org.apache.wiki.providers.FileSystemProvider;
+import org.apache.wiki.providers.VerySimpleProvider;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-public class DefaultPageManagerTest
-{
-    Properties props = TestEngine.getTestProperties();
+import java.io.File;
+import java.util.Collection;
+import java.util.Properties;
+
+public class DefaultPageManagerTest {
 
-    TestEngine engine;
+    static final String NAME1 = "Test1";
 
-    @BeforeEach
-    public void setUp()
-        throws Exception
-    {
-        PropertyConfigurator.configure(props);
-        engine = new TestEngine(props);
-    }
+    TestEngine engine = TestEngine.build();
 
     @AfterEach
-    public void tearDown()
-    {
+    public void tearDown() {
+        final String files = engine.getWikiProperties().getProperty( FileSystemProvider.PROP_PAGEDIR );
+
+        if( files != null ) {
+            final File f = new File( files );
+            TestEngine.deleteAll( f );
+        }
+
+        TestEngine.emptyWorkDir();
+        CacheManager.getInstance().removeAllCaches();
     }
 
     @Test
-    public void testPageCacheExists()
-        throws Exception
-    {
-        props.setProperty( "jspwiki.usePageCache", "true" );
-        PageManager m = new DefaultPageManager( engine, props );
+    public void testPageCacheExists() throws Exception {
+        engine.getWikiProperties().setProperty( "jspwiki.usePageCache", "true" );
+        final PageManager m = new DefaultPageManager( engine, engine.getWikiProperties() );
 
         Assertions.assertTrue( m.getProvider() instanceof CachingProvider );
     }
 
     @Test
-    public void testPageCacheNotInUse()
-        throws Exception
-    {
+    public void testPageCacheNotInUse() throws Exception {
+        engine.getWikiProperties().setProperty( "jspwiki.usePageCache", "false" );
+        final PageManager m = new DefaultPageManager( engine, engine.getWikiProperties() );
+
+        Assertions.assertFalse( m.getProvider() instanceof CachingProvider );
+    }
+
+    @Test
+    public void testDeletePage() throws Exception {
+        engine.saveText( NAME1, "Test" );
+        final String files = engine.getWikiProperties().getProperty( FileSystemProvider.PROP_PAGEDIR );
+        final File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );
+        Assertions.assertTrue( saved.exists(), "Didn't create it!" );
+
+        final WikiPage page = engine.getPageManager().getPage( NAME1, WikiProvider.LATEST_VERSION );
+        engine.getPageManager().deletePage( page.getName() );
+        Assertions.assertFalse( saved.exists(), "Page has not been removed!" );
+    }
+
+    @Test
+    public void testDeletePageAndAttachments() throws Exception {
+        engine.saveText( NAME1, "Test" );
+        final Attachment att = new Attachment( engine, NAME1, "TestAtt.txt" );
+        att.setAuthor( "FirstPost" );
+        engine.getAttachmentManager().storeAttachment( att, engine.makeAttachmentFile() );
+
+        final String files = engine.getWikiProperties().getProperty( FileSystemProvider.PROP_PAGEDIR );
+        final File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );
+
+        final String atts = engine.getWikiProperties().getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
+        final File attfile = new File( atts, NAME1+"-att/TestAtt.txt-dir" );
+
+        Assertions.assertTrue( saved.exists(), "Didn't create it!" );
+        Assertions.assertTrue( attfile.exists(), "Attachment dir does not exist" );
+
+        final WikiPage page = engine.getPageManager().getPage( NAME1, WikiProvider.LATEST_VERSION );
+
+        engine.getPageManager().deletePage( page.getName() );
+
+        Assertions.assertFalse( saved.exists(), "Page has not been removed!" );
+        Assertions.assertFalse( attfile.exists(), "Attachment has not been removed" );
+    }
+
+    @Test
+    public void testDeletePageAndAttachments2() throws Exception {
+        engine.saveText( NAME1, "Test" );
+        Attachment att = new Attachment( engine, NAME1, "TestAtt.txt" );
+        att.setAuthor( "FirstPost" );
+        engine.getAttachmentManager().storeAttachment( att, engine.makeAttachmentFile() );
+
+        final String files = engine.getWikiProperties().getProperty( FileSystemProvider.PROP_PAGEDIR );
+        final File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );
+
+        final String atts = engine.getWikiProperties().getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
+        final File attfile = new File( atts, NAME1+"-att/TestAtt.txt-dir" );
+
+        Assertions.assertTrue( saved.exists(), "Didn't create it!" );
+        Assertions.assertTrue( attfile.exists(), "Attachment dir does not exist" );
+
+        final WikiPage page = engine.getPageManager().getPage( NAME1, WikiProvider.LATEST_VERSION );
+        Assertions.assertNotNull( page, "page" );
+
+        att = engine.getAttachmentManager().getAttachmentInfo(NAME1+"/TestAtt.txt");
+        engine.getPageManager().deletePage(att.getName());
+        engine.getPageManager().deletePage( NAME1 );
+        Assertions.assertNull( engine.getPageManager().getPage(NAME1), "Page not removed" );
+        Assertions.assertNull( engine.getPageManager().getPage(NAME1+"/TestAtt.txt"), "Att not removed" );
+
+        final Collection< String > refs = engine.getReferenceManager().findReferrers(NAME1);
+        Assertions.assertNull( refs, "referrers" );
+    }
+
+    @Test
+    public void testDeleteVersion() throws Exception {
+        final Properties props = engine.getWikiProperties();
+        props.setProperty( "jspwiki.pageProvider", "VersioningFileProvider" );
+        final TestEngine engine = new TestEngine( props );
+        engine.saveText( NAME1, "Test1" );
+        engine.saveText( NAME1, "Test2" );
+        engine.saveText( NAME1, "Test3" );
+
+        final WikiPage page = engine.getPageManager().getPage( NAME1, 3 );
+        engine.getPageManager().deleteVersion( page );
+        Assertions.assertNull( engine.getPageManager().getPage( NAME1, 3 ), "got page" );
+
+        final String content = engine.getText( NAME1, WikiProvider.LATEST_VERSION );
+        Assertions.assertEquals( "Test2", content.trim(), "content" );
+    }
+
+    @Test
+    public void testDeleteVersion2() throws Exception {
+        final Properties props = engine.getWikiProperties();
+        props.setProperty( "jspwiki.pageProvider", "VersioningFileProvider" );
+        final TestEngine engine = new TestEngine( props );
+        engine.saveText( NAME1, "Test1" );
+        engine.saveText( NAME1, "Test2" );
+        engine.saveText( NAME1, "Test3" );
+
+        final WikiPage page = engine.getPageManager().getPage( NAME1, 1 );
+        engine.getPageManager().deleteVersion( page );
+        Assertions.assertNull( engine.getPageManager().getPage( NAME1, 1 ), "got page" );
+
+        final String content = engine.getText( NAME1, WikiProvider.LATEST_VERSION );
+        Assertions.assertEquals( "Test3", content.trim(), "content" );
+        Assertions.assertEquals( "", engine.getText(NAME1, 1).trim(), "content1" );
+    }
+
+    @Test
+    public void testLatestGet() throws Exception {
+        final Properties props = engine.getWikiProperties();
+        props.setProperty( "jspwiki.pageProvider", "org.apache.wiki.providers.VerySimpleProvider" );
         props.setProperty( "jspwiki.usePageCache", "false" );
-        PageManager m = new DefaultPageManager( engine, props );
+        final WikiEngine engine = new TestEngine( props );
+        final WikiPage p = engine.getPageManager().getPage( "test", -1 );
+        final VerySimpleProvider vsp = (VerySimpleProvider) engine.getPageManager().getProvider();
+
+        Assertions.assertEquals( "test", vsp.m_latestReq, "wrong page" );
+        Assertions.assertEquals( -1, vsp.m_latestVers, "wrong version" );
+        Assertions.assertNotNull( p, "null" );
+    }
+
+    @Test
+    public void testLatestGet2() throws Exception {
+        final Properties props = engine.getWikiProperties();
+        props.setProperty( "jspwiki.pageProvider", "org.apache.wiki.providers.VerySimpleProvider" );
+        props.setProperty( "jspwiki.usePageCache", "false" );
+        final WikiEngine engine = new TestEngine( props );
+        final String p = engine.getText( "test", -1 );
+        final VerySimpleProvider vsp = (VerySimpleProvider) engine.getPageManager().getProvider();
+
+        Assertions.assertEquals( "test", vsp.m_latestReq, "wrong page" );
+        Assertions.assertEquals( -1, vsp.m_latestVers, "wrong version" );
+        Assertions.assertNotNull( p, "null" );
+    }
+
+    @Test
+    public void testLatestGet3() throws Exception {
+        final Properties props = engine.getWikiProperties();
+        props.setProperty( "jspwiki.pageProvider", "org.apache.wiki.providers.VerySimpleProvider" );
+        props.setProperty( "jspwiki.usePageCache", "false" );
+        final WikiEngine engine = new TestEngine( props );
+        final String p = engine.getHTML( "test", -1 );
+        final VerySimpleProvider vsp = (VerySimpleProvider) engine.getPageManager().getProvider();
+
+        Assertions.assertEquals( "test", vsp.m_latestReq, "wrong page" );
+        Assertions.assertEquals( 5, vsp.m_latestVers, "wrong version" );
+        Assertions.assertNotNull( p, "null" );
+    }
+
+    @Test
+    public void testLatestGet4() throws Exception {
+        final Properties props = engine.getWikiProperties();
+        props.setProperty( "jspwiki.pageProvider", "org.apache.wiki.providers.VerySimpleProvider" );
+        props.setProperty( "jspwiki.usePageCache", "true" );
+        final WikiEngine engine = new TestEngine( props );
+        final String p = engine.getHTML( VerySimpleProvider.PAGENAME, -1 );
+        final CachingProvider cp = (CachingProvider)engine.getPageManager().getProvider();
+        final VerySimpleProvider vsp = (VerySimpleProvider) cp.getRealProvider();
 
-        Assertions.assertTrue( !(m.getProvider() instanceof CachingProvider) );
+        Assertions.assertEquals( VerySimpleProvider.PAGENAME, vsp.m_latestReq, "wrong page" );
+        Assertions.assertEquals( -1, vsp.m_latestVers,  "wrong version" );
+        Assertions.assertNotNull( p, "null" );
     }
 
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
index 4ac3c19..90eaff2 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
@@ -71,7 +71,7 @@ public class IfPluginTest {
         String expected = "<p>Content visible for Janne Jalkanen</p>\n";
 
         testEngine.saveText( "Test", src );
-        WikiPage page = testEngine.getPage( "Test", WikiPageProvider.LATEST_VERSION );
+        WikiPage page = testEngine.getPageManager().getPage( "Test", WikiPageProvider.LATEST_VERSION );
         WikiContext context = getJanneBasedWikiContextFor( page );
 
         String res = testEngine.getHTML( context, page );
@@ -92,7 +92,7 @@ public class IfPluginTest {
         String expected = "\n";
 
         testEngine.saveText( "Test", src );
-        WikiPage page = testEngine.getPage( "Test", WikiPageProvider.LATEST_VERSION );
+        WikiPage page = testEngine.getPageManager().getPage( "Test", WikiPageProvider.LATEST_VERSION );
         WikiContext context = getJanneBasedWikiContextFor( page );
 
         String res = testEngine.getHTML( context, page );
@@ -113,7 +113,7 @@ public class IfPluginTest {
         String expected = "<p>Content visible for 127.0.0.1</p>\n";
 
         testEngine.saveText( "Test", src );
-        WikiPage page = testEngine.getPage( "Test", WikiPageProvider.LATEST_VERSION );
+        WikiPage page = testEngine.getPageManager().getPage( "Test", WikiPageProvider.LATEST_VERSION );
         WikiContext context = getJanneBasedWikiContextFor( page );
 
         String res = testEngine.getHTML( context, page );
@@ -134,7 +134,7 @@ public class IfPluginTest {
         String expected = "\n";
 
         testEngine.saveText( "Test", src );
-        WikiPage page = testEngine.getPage( "Test", WikiPageProvider.LATEST_VERSION );
+        WikiPage page = testEngine.getPageManager().getPage( "Test", WikiPageProvider.LATEST_VERSION );
         WikiContext context = getJanneBasedWikiContextFor( page );
 
         String res = testEngine.getHTML( context, page );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java
index 63222ad..d7a8f6b 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java
@@ -18,8 +18,7 @@
  */
 package org.apache.wiki.plugin;
 
-import java.util.Properties;
-
+import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
@@ -29,7 +28,7 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import net.sf.ehcache.CacheManager;
+import java.util.Properties;
 
 public class PageViewPluginTest
 {
@@ -66,9 +65,9 @@ public class PageViewPluginTest
     @Test
     public void testShowCountsBasic() throws Exception
     {
-        WikiPage page1 = testEngine.getPage( "TestPage01" );
+        WikiPage page1 = testEngine.getPageManager().getPage( "TestPage01" );
         WikiContext context1 = new WikiContext( testEngine, page1 );
-        WikiPage page2 = testEngine.getPage( "TestPage02" );
+        WikiPage page2 = testEngine.getPageManager().getPage( "TestPage02" );
         WikiContext context2 = new WikiContext( testEngine, page2 );
 
         // generate counts:
@@ -80,7 +79,7 @@ public class PageViewPluginTest
         String pageViewPageContent = "[{PageViewPlugin show='list''\n\n* {1} ({2} views)\n}]";
         testEngine.saveText( "PageViews", pageViewPageContent );
 
-        WikiPage pageviews = testEngine.getPage( "PageViews" );
+        WikiPage pageviews = testEngine.getPageManager().getPage( "PageViews" );
         WikiContext contextPV = new WikiContext( testEngine, pageviews );
 
         String result = testEngine.getHTML( contextPV, pageviews );
@@ -96,9 +95,9 @@ public class PageViewPluginTest
     {
         testEngine.saveText( "TestPageExcluded", "this is test page that should be excluded [{PageViewPlugin}]" );
 
-        WikiPage page1 = testEngine.getPage( "TestPage01" );
+        WikiPage page1 = testEngine.getPageManager().getPage( "TestPage01" );
         WikiContext context1 = new WikiContext( testEngine, page1 );
-        WikiPage page2 = testEngine.getPage( "TestPage02" );
+        WikiPage page2 = testEngine.getPageManager().getPage( "TestPage02" );
         WikiContext context2 = new WikiContext( testEngine, page2 );
 
         // generate counts:
@@ -110,7 +109,7 @@ public class PageViewPluginTest
         String pageViewPageContent = "[{PageViewPlugin show='list' exclude='TestPageExcl*' '\n\n* {1} ({2} views)\n}]";
         testEngine.saveText( "PageViews", pageViewPageContent );
 
-        WikiPage pageviews = testEngine.getPage( "PageViews" );
+        WikiPage pageviews = testEngine.getPageManager().getPage( "PageViews" );
         WikiContext contextPV = new WikiContext( testEngine, pageviews );
 
         String result = testEngine.getHTML( contextPV, pageviews );
@@ -127,9 +126,9 @@ public class PageViewPluginTest
     @Test
     public void testShowCountsSorted() throws Exception
     {
-        WikiPage page1 = testEngine.getPage( "TestPage01" );
+        WikiPage page1 = testEngine.getPageManager().getPage( "TestPage01" );
         WikiContext context1 = new WikiContext( testEngine, page1 );
-        WikiPage page2 = testEngine.getPage( "TestPage02" );
+        WikiPage page2 = testEngine.getPageManager().getPage( "TestPage02" );
         WikiContext context2 = new WikiContext( testEngine, page2 );
 
         // generate counts:
@@ -141,7 +140,7 @@ public class PageViewPluginTest
         String pageViewPageContent = "[{PageViewPlugin show='list' sort=count '\n\n* {1} ({2} views)\n}]";
         testEngine.saveText( "PageViews", pageViewPageContent );
 
-        WikiPage pageviews = testEngine.getPage( "PageViews" );
+        WikiPage pageviews = testEngine.getPageManager().getPage( "PageViews" );
         WikiContext contextPV = new WikiContext( testEngine, pageviews );
 
         String result = testEngine.getHTML( contextPV, pageviews );
@@ -161,13 +160,13 @@ public class PageViewPluginTest
         testEngine.saveText( "TestPage03", "this is test page 03 [{PageViewPlugin}]" );
         testEngine.saveText( "TestPage04", "this is test page 04 [{PageViewPlugin}]" );
 
-        WikiPage page1 = testEngine.getPage( "TestPage01" );
+        WikiPage page1 = testEngine.getPageManager().getPage( "TestPage01" );
         WikiContext context1 = new WikiContext( testEngine, page1 );
-        WikiPage page2 = testEngine.getPage( "TestPage02" );
+        WikiPage page2 = testEngine.getPageManager().getPage( "TestPage02" );
         WikiContext context2 = new WikiContext( testEngine, page2 );
-        WikiPage page3 = testEngine.getPage( "TestPage03" );
+        WikiPage page3 = testEngine.getPageManager().getPage( "TestPage03" );
         WikiContext context3 = new WikiContext( testEngine, page3 );
-        WikiPage page4 = testEngine.getPage( "TestPage04" );
+        WikiPage page4 = testEngine.getPageManager().getPage( "TestPage04" );
         WikiContext context4 = new WikiContext( testEngine, page4 );
 
         // generate counts:
@@ -181,7 +180,7 @@ public class PageViewPluginTest
         String pageViewPageContent = "[{PageViewPlugin show='list' entries=3'\n\n* {1} ({2} views)\n}]";
         testEngine.saveText( "PageViews", pageViewPageContent );
 
-        WikiPage pageviews = testEngine.getPage( "PageViews" );
+        WikiPage pageviews = testEngine.getPageManager().getPage( "PageViews" );
         WikiContext contextPV = new WikiContext( testEngine, pageviews );
 
         String result = testEngine.getHTML( contextPV, pageviews );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/providers/CachingProviderTest.java b/jspwiki-main/src/test/java/org/apache/wiki/providers/CachingProviderTest.java
index 5a34e13..6aa93d8 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/providers/CachingProviderTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/providers/CachingProviderTest.java
@@ -20,14 +20,12 @@
 package org.apache.wiki.providers;
 
 import net.sf.ehcache.CacheManager;
-import org.apache.log4j.PropertyConfigurator;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.util.FileUtil;
 import org.awaitility.Awaitility;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import java.io.File;
@@ -38,25 +36,13 @@ import java.util.Properties;
 
 public class CachingProviderTest
 {
-    protected TestEngine testEngine;
-
-    @BeforeEach
-    public void setUp()
-        throws Exception
-    {
-        TestEngine.emptyWorkDir();
-        CacheManager.getInstance().removeAllCaches();
-
-        Properties props2 = TestEngine.getTestProperties();
-        testEngine = new TestEngine(props2);
-        PropertyConfigurator.configure(props2);
-    }
+    protected TestEngine testEngine = TestEngine.build();
 
     @AfterEach
-    public void tearDown()
-    {
-        TestEngine.emptyWorkDir();
+    public void tearDown() {
         testEngine.deleteTestPage("Testi");
+        TestEngine.emptyWorkDir();
+        CacheManager.getInstance().removeAllCaches();
     }
 
     /**
@@ -81,7 +67,7 @@ public class CachingProviderTest
         Assertions.assertEquals( 0, p.m_pageExistsCalls, "pageExists" );
         Assertions.assertEquals( 4, p.m_getPageTextCalls, "getPageText" );
 
-        engine.getPage( "Foo" );
+        engine.getPageManager().getPage( "Foo" );
 
         Assertions.assertEquals( 0, p.m_pageExistsCalls, "pageExists2" );
     }
@@ -105,8 +91,8 @@ public class CachingProviderTest
         FileUtil.copyContents( new StringReader(content), out );
         out.close();
 
-        Awaitility.await( "testSneakyAdd" ).until( () -> engine.getPage( "Testi" ) != null );
-        WikiPage p = engine.getPage( "Testi" );
+        Awaitility.await( "testSneakyAdd" ).until( () -> engine.getPageManager().getPage( "Testi" ) != null );
+        WikiPage p = engine.getPageManager().getPage( "Testi" );
         Assertions.assertNotNull( p, "page did not exist?" );
 
         String text = engine.getText( "Testi");
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java b/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
index 8d9da15..5f9f703 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/providers/VersioningFileProviderTest.java
@@ -27,7 +27,6 @@ import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.util.FileUtil;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import java.io.File;
@@ -52,37 +51,23 @@ public class VersioningFileProviderTest
                 + "#Wed Jan 01 12:27:57 GMT 2012" + "\n"
                 + "author=" + OLD_AUTHOR + "\n";
 
-    // we always use the same properties for this suite, but
-    // they can be changed by our tests and also TestEngine,
-    // and so must be reloaded from source for each test case
-    private Properties PROPS = TestEngine.getTestProperties("/jspwiki-vers-custom.properties");
+    private Properties PROPS = TestEngine.getTestProperties( "/jspwiki-vers-custom.properties" );
+    private TestEngine engine = TestEngine.build( PROPS );
 
     // this is the testing page directory
-    private String files;
+    private String files = engine.getWikiProperties().getProperty( AbstractFileProvider.PROP_PAGEDIR );
 
-    private TestEngine engine;
-
-    @BeforeEach
-    public void setUp()
-        throws Exception
-    {
-        // make sure that the reference manager cache is cleaned first
-        TestEngine.emptyWorkDir(null);
-
-        engine = new TestEngine(PROPS);
-        files = engine.getWikiProperties().getProperty( AbstractFileProvider.PROP_PAGEDIR );
-    }
 
     @AfterEach
-    public void tearDown()
-    {
+    public void tearDown() {
         // Remove all/any files and subdirs left in test page directory
         TestEngine.deleteAll( new File(files) );
 
-        // jspwiki always uses a singleton CacheManager, so
-        // clear the cache at the end of every test case to avoid
-        // polluting another test case
+        // clear the cache at the end of every test case to avoid polluting another test case
         CacheManager.getInstance().removeAllCaches();
+
+        // make sure that the reference manager cache is cleaned first
+        TestEngine.emptyWorkDir(null);
     }
 
     /*
@@ -104,7 +89,7 @@ public class VersioningFileProviderTest
         String res = engine.getText( NAME1 );
         Assertions.assertEquals( fakeWikiPage, res, "fetch latest should work" );
 
-        WikiPage page = engine.getPage( NAME1, 1 );
+        WikiPage page = engine.getPageManager().getPage( NAME1, 1 );
         Assertions.assertEquals( 1, page.getVersion(), "original version expected" );
         Assertions.assertEquals( OLD_AUTHOR, page.getAuthor(), "original author" );
     }
@@ -128,7 +113,7 @@ public class VersioningFileProviderTest
         res = engine.getText( NAME1, 1 ); // Should be the first version.
         Assertions.assertEquals( "foobar", res, "fetch by direct version did not work" );
 
-        WikiPage page = engine.getPage( NAME1 );
+        WikiPage page = engine.getPageManager().getPage( NAME1 );
         Assertions.assertEquals( 1, page.getVersion(), "original version expected" );
         Assertions.assertNull( page.getAuthor(), "original author not expected" );
     }
@@ -156,7 +141,7 @@ public class VersioningFileProviderTest
         res = engine.getText( NAME1, 1 ); // Should be the first version.
         Assertions.assertEquals( fakeWikiPage, res, "fetch by direct version did not work" );
 
-        WikiPage page = engine.getPage( NAME1, 1 );
+        WikiPage page = engine.getPageManager().getPage( NAME1, 1 );
         Assertions.assertEquals( 1, page.getVersion(), "original version expected" );
         Assertions.assertEquals( OLD_AUTHOR, page.getAuthor(), "original author" );
     }
@@ -201,11 +186,11 @@ public class VersioningFileProviderTest
         String result4 = engine.getText( NAME1, 1 );
         Assertions.assertEquals( fakeWikiPage, result4, "fetch original by version Assertions.failed" );
 
-        WikiPage pageNew = engine.getPage( NAME1, 2 );
+        WikiPage pageNew = engine.getPageManager().getPage( NAME1, 2 );
         Assertions.assertEquals( 2, pageNew.getVersion(), "new version" );
         Assertions.assertEquals( "Guest", pageNew.getAuthor(), "new author" );
 
-        WikiPage pageOld = engine.getPage( NAME1, 1 );
+        WikiPage pageOld = engine.getPageManager().getPage( NAME1, 1 );
         Assertions.assertEquals( 1, pageOld.getVersion(), "old version" );
         Assertions.assertEquals( OLD_AUTHOR, pageOld.getAuthor(), "old author" );
     }
@@ -253,15 +238,15 @@ public class VersioningFileProviderTest
         String result4 = engine.getText( NAME1, 2 );
         Assertions.assertEquals( text2, result4, "fetch original by version Assertions.failed" );
 
-        WikiPage pageNew = engine.getPage( NAME1 );
+        WikiPage pageNew = engine.getPageManager().getPage( NAME1 );
         Assertions.assertEquals( 3, pageNew.getVersion(), "newest version" );
         Assertions.assertEquals( pageNew.getAuthor(), "Guest", "newest author" );
 
-        WikiPage pageMiddle = engine.getPage( NAME1, 2 );
+        WikiPage pageMiddle = engine.getPageManager().getPage( NAME1, 2 );
         Assertions.assertEquals( 2, pageMiddle.getVersion(), "middle version" );
         Assertions.assertEquals( Users.JANNE, pageMiddle.getAuthor(), "middle author" );
 
-        WikiPage pageOld = engine.getPage( NAME1, 1 );
+        WikiPage pageOld = engine.getPageManager().getPage( NAME1, 1 );
         Assertions.assertEquals( 1, pageOld.getVersion(), "old version" );
         Assertions.assertEquals( OLD_AUTHOR, pageOld.getAuthor(), "old author" );
     }
@@ -320,15 +305,15 @@ public class VersioningFileProviderTest
         String result4 = engine.getText( NAME1, 2 );
         Assertions.assertEquals( text2, result4, "fetch original by version Assertions.failed" );
 
-        WikiPage pageNew = engine.getPage( NAME1 );
+        WikiPage pageNew = engine.getPageManager().getPage( NAME1 );
         Assertions.assertEquals( 3, pageNew.getVersion(), "newest version" );
         Assertions.assertEquals( "Guest", pageNew.getAuthor(), "newest author" );
 
-        WikiPage pageMiddle = engine.getPage( NAME1, 2 );
+        WikiPage pageMiddle = engine.getPageManager().getPage( NAME1, 2 );
         Assertions.assertEquals( 2, pageMiddle.getVersion(), "middle version" );
         Assertions.assertEquals( Users.JANNE, pageMiddle.getAuthor(), "middle author" );
 
-        WikiPage pageOld = engine.getPage( NAME1, 1 );
+        WikiPage pageOld = engine.getPageManager().getPage( NAME1, 1 );
         Assertions.assertEquals( 1, pageOld.getVersion(), "old version" );
         Assertions.assertEquals( OLD_AUTHOR, pageOld.getAuthor(), "old author" );
     }
@@ -347,7 +332,7 @@ public class VersioningFileProviderTest
             engine.saveText( name, text );
         }
 
-        WikiPage pageinfo = engine.getPage( NAME1 );
+        WikiPage pageinfo = engine.getPageManager().getPage( NAME1 );
 
         Assertions.assertEquals( maxver, pageinfo.getVersion(), "wrong version" );
 
@@ -376,7 +361,7 @@ public class VersioningFileProviderTest
 
         engine.saveText( NAME1, text );
 
-        WikiPage page = engine.getPage( NAME1, 1 );
+        WikiPage page = engine.getPageManager().getPage( NAME1, 1 );
 
         Assertions.assertEquals( NAME1, page.getName(), "name" );
         Assertions.assertEquals( 1, page.getVersion(), "version" );
@@ -390,7 +375,7 @@ public class VersioningFileProviderTest
 
         engine.saveText( NAME1, text );
 
-        WikiPage res = engine.getPage(NAME1);
+        WikiPage res = engine.getPageManager().getPage(NAME1);
 
         Assertions.assertEquals( 1, res.getVersion() );
     }
@@ -407,7 +392,7 @@ public class VersioningFileProviderTest
         engine.saveText( NAME1, text2 );
         engine.saveText( NAME1, text3 );
 
-        WikiPage res = engine.getPage(NAME1);
+        WikiPage res = engine.getPageManager().getPage(NAME1);
 
         Assertions.assertEquals( 3, res.getVersion(), "wrong version" );
 
@@ -428,13 +413,13 @@ public class VersioningFileProviderTest
         engine.saveText( NAME1, text2 );
         engine.saveText( NAME1, text3 );
 
-        WikiPage res = engine.getPage(NAME1);
+        WikiPage res = engine.getPageManager().getPage(NAME1);
 
         Assertions.assertEquals( 3, res.getVersion(), "wrong version" );
 
-        Assertions.assertEquals( 1, engine.getPage( NAME1, 1 ).getVersion(), "ver1" );
-        Assertions.assertEquals( 2, engine.getPage( NAME1, 2 ).getVersion(), "ver2" );
-        Assertions.assertEquals( 3, engine.getPage( NAME1, 3 ).getVersion(), "ver3" );
+        Assertions.assertEquals( 1, engine.getPageManager().getPage( NAME1, 1 ).getVersion(), "ver1" );
+        Assertions.assertEquals( 2, engine.getPageManager().getPage( NAME1, 2 ).getVersion(), "ver2" );
+        Assertions.assertEquals( 3, engine.getPageManager().getPage( NAME1, 3 ).getVersion(), "ver3" );
 }
 
     /**
@@ -452,7 +437,7 @@ public class VersioningFileProviderTest
         engine.saveText( NAME1, text2 );
         engine.saveText( NAME1, text3 );
 
-        WikiPage res = engine.getPage(NAME1);
+        WikiPage res = engine.getPageManager().getPage(NAME1);
 
         Assertions.assertEquals( 3, res.getVersion(), "wrong version" );
 
@@ -464,7 +449,7 @@ public class VersioningFileProviderTest
     @Test
     public void testNonexistentPage()
     {
-        Assertions.assertNull( engine.getPage("fjewifjeiw") );
+        Assertions.assertNull( engine.getPageManager().getPage("fjewifjeiw") );
     }
 
     @Test
@@ -546,7 +531,7 @@ public class VersioningFileProviderTest
 
         engine.saveText( context, "test" );
 
-        WikiPage p2 = engine.getPage( NAME1 );
+        WikiPage p2 = engine.getPageManager().getPage( NAME1 );
 
         Assertions.assertEquals( "Test change", p2.getAttribute(WikiPage.CHANGENOTE) );
     }
@@ -566,11 +551,11 @@ public class VersioningFileProviderTest
         context.getPage().setAttribute(WikiPage.CHANGENOTE, "Change 2" );
         engine.saveText( context, "test2" );
 
-        WikiPage p2 = engine.getPage( NAME1, 1 );
+        WikiPage p2 = engine.getPageManager().getPage( NAME1, 1 );
 
         Assertions.assertEquals( "Test change", p2.getAttribute(WikiPage.CHANGENOTE) );
 
-        WikiPage p3 = engine.getPage( NAME1, 2 );
+        WikiPage p3 = engine.getPageManager().getPage( NAME1, 2 );
 
         Assertions.assertEquals( "Change 2", p3.getAttribute(WikiPage.CHANGENOTE) );
     }
@@ -588,7 +573,7 @@ public class VersioningFileProviderTest
 
         for( int i = 0; i < 5; i++ )
         {
-            WikiPage p2 = (WikiPage)engine.getPage( NAME1 ).clone();
+            WikiPage p2 = (WikiPage)engine.getPageManager().getPage( NAME1 ).clone();
             p2.removeAttribute(WikiPage.CHANGENOTE);
 
             context.setPage( p2 );
@@ -596,7 +581,7 @@ public class VersioningFileProviderTest
             engine.saveText( context, "test"+i );
         }
 
-        WikiPage p3 = engine.getPage( NAME1, -1 );
+        WikiPage p3 = engine.getPageManager().getPage( NAME1, -1 );
 
         Assertions.assertEquals( null, p3.getAttribute(WikiPage.CHANGENOTE) );
     }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
index cf5aada..06962d9 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
@@ -58,7 +58,7 @@ public class RenderingManagerTest {
 
         for( int i = 0; i < 300; i++ )
         {
-            WikiPage page = m_engine.getPage( "TestPage" );
+            WikiPage page = m_engine.getPageManager().getPage( "TestPage" );
             String pagedata = m_engine.getPureText( page );
 
             WikiContext context = new WikiContext( m_engine, page );
@@ -81,7 +81,7 @@ public class RenderingManagerTest {
 
         for( int i = 0; i < 300; i++ )
         {
-            WikiPage page = m_engine.getPage( "TestPage" );
+            WikiPage page = m_engine.getPageManager().getPage( "TestPage" );
             String pagedata = m_engine.getPureText( page );
 
             WikiContext context = new WikiContext( m_engine, page );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/rss/RSSGeneratorTest.java b/jspwiki-main/src/test/java/org/apache/wiki/rss/RSSGeneratorTest.java
index aa58605..ce8949d 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/rss/RSSGeneratorTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/rss/RSSGeneratorTest.java
@@ -22,11 +22,7 @@
  */
 package org.apache.wiki.rss;
 
-import java.io.File;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-
+import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
@@ -38,30 +34,31 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import net.sf.ehcache.CacheManager;
+import java.io.File;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
 
 
 /**
  *
  *  @since
  */
-public class RSSGeneratorTest
-{
+public class RSSGeneratorTest {
+
     TestEngine m_testEngine;
     Properties props = TestEngine.getTestProperties();
 
     @BeforeEach
-    public void setUp() throws Exception
-    {
+    public void setUp() {
         props.setProperty( RSSGenerator.PROP_GENERATE_RSS, "true" );
-        CacheManager.getInstance().removeAllCaches();
-        m_testEngine = new TestEngine(props);
+        m_testEngine = TestEngine.build( props );
     }
 
     @AfterEach
-    public void tearDown() throws Exception
-    {
+    public void tearDown() {
         TestEngine.deleteAll( new File(props.getProperty( FileSystemProvider.PROP_PAGEDIR )) );
+        CacheManager.getInstance().removeAllCaches();
     }
 
     @Test
@@ -79,7 +76,7 @@ public class RSSGeneratorTest
 
         RSSGenerator gen = m_testEngine.getRSSGenerator();
 
-        WikiContext context = new WikiContext( m_testEngine, m_testEngine.getPage("TestBlog") );
+        WikiContext context = new WikiContext( m_testEngine, m_testEngine.getPageManager().getPage("TestBlog") );
 
         WeblogPlugin blogplugin = new WeblogPlugin();
 
@@ -110,7 +107,7 @@ public class RSSGeneratorTest
 
         RSSGenerator gen = m_testEngine.getRSSGenerator();
 
-        WikiContext context = new WikiContext( m_testEngine, m_testEngine.getPage("TestBlog") );
+        WikiContext context = new WikiContext( m_testEngine, m_testEngine.getPageManager().getPage("TestBlog") );
 
         WeblogPlugin blogplugin = new WeblogPlugin();
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java b/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java
index d7a2688..20ed0ac 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/stress/StressTestVersioningProvider.java
@@ -18,32 +18,22 @@
  */
 package org.apache.wiki.stress;
 
-import java.io.File;
-import java.util.Collection;
-import java.util.Properties;
-
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.providers.FileSystemProvider;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 
+import java.io.File;
+import java.util.Collection;
+import java.util.Properties;
 
-public class StressTestVersioningProvider 
-{
+
+public class StressTestVersioningProvider {
     public static final String NAME1 = "Test1";
 
     Properties props = TestEngine.getTestProperties("/jspwiki-vers-custom.properties");
-
-    TestEngine engine;
-
-    @BeforeEach
-    public void setUp()
-        throws Exception
-    {
-        engine = new TestEngine(props);
-    }
+    TestEngine engine = TestEngine.build( props );
 
     @AfterEach
     public void tearDown()
@@ -77,7 +67,7 @@ public class StressTestVersioningProvider
         mark.stop();
 
         System.out.println("Benchmark: "+mark.toString(2000)+" pages/second");
-        WikiPage pageinfo = engine.getPage( NAME1 );
+        WikiPage pageinfo = engine.getPageManager().getPage( NAME1 );
 
         Assertions.assertEquals( maxver, pageinfo.getVersion(), "wrong version" );
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java
index a557d5c..634bc7d 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java
@@ -124,7 +124,7 @@ public class CommandResolverTest {
 
     @Test
     public void testFindWikiActionWithParams() {
-        final WikiPage page = m_engine.getPage( "SinglePage" );
+        final WikiPage page = m_engine.getPageManager().getPage( "SinglePage" );
 
         // Passing an EDIT request with page param yields a wrapped action
         MockHttpServletRequest request = m_engine.newHttpRequest( "/Edit.jsp?page=SinglePage" );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java
index a5a7b83..5e222d9 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/ui/PageCommandTest.java
@@ -64,7 +64,7 @@ public class PageCommandTest {
     public void testTargetedCommand() throws Exception {
         final TestEngine testEngine = TestEngine.build();
         testEngine.saveText( "TestPage", "This is a test." );
-        final WikiPage testPage = testEngine.getPage( "TestPage" );
+        final WikiPage testPage = testEngine.getPageManager().getPage( "TestPage" );
 
         // Get view command
         Command a = PageCommand.VIEW;
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/xmlrpc/RPCHandlerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/xmlrpc/RPCHandlerTest.java
index fcbac61..3ed8c2d 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/xmlrpc/RPCHandlerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/xmlrpc/RPCHandlerTest.java
@@ -19,12 +19,7 @@
 
 package org.apache.wiki.xmlrpc;
 
-import java.util.Calendar;
-import java.util.Date;
-import java.util.Hashtable;
-import java.util.Properties;
-import java.util.Vector;
-
+import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
@@ -35,7 +30,11 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import net.sf.ehcache.CacheManager;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Hashtable;
+import java.util.Properties;
+import java.util.Vector;
 
 public class RPCHandlerTest
 {
@@ -87,7 +86,7 @@ public class RPCHandlerTest
         Vector previousChanges = m_handler.getRecentChanges( time );
 
         m_engine.saveText( NAME1, "Foo" );
-        WikiPage directInfo = m_engine.getPage( NAME1 );
+        WikiPage directInfo = m_engine.getPageManager().getPage( NAME1 );
         time = getCalendarTime( directInfo.getLastModified() );
         Vector recentChanges = m_handler.getRecentChanges( time );
 
@@ -105,7 +104,7 @@ public class RPCHandlerTest
         Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
         att.setAuthor( "FirstPost" );
         m_engine.getAttachmentManager().storeAttachment( att, m_engine.makeAttachmentFile() );
-        WikiPage directInfo = m_engine.getPage( NAME1 );
+        WikiPage directInfo = m_engine.getPageManager().getPage( NAME1 );
         time = getCalendarTime( directInfo.getLastModified() );
         Vector recentChanges = m_handler.getRecentChanges( time );
 
@@ -117,7 +116,7 @@ public class RPCHandlerTest
         throws Exception
     {
         m_engine.saveText( NAME1, "Foobar.[{ALLOW view Anonymous}]" );
-        WikiPage directInfo = m_engine.getPage( NAME1 );
+        WikiPage directInfo = m_engine.getPageManager().getPage( NAME1 );
 
         Hashtable ht = m_handler.getPageInfo( NAME1 );
         Assertions.assertEquals( (String)ht.get( "name" ), NAME1, "name" );
diff --git a/jspwiki-markdown/src/test/java/org/apache/wiki/render/MarkdownRendererTest.java b/jspwiki-markdown/src/test/java/org/apache/wiki/render/MarkdownRendererTest.java
index 58b05b6..4ae2dde 100755
--- a/jspwiki-markdown/src/test/java/org/apache/wiki/render/MarkdownRendererTest.java
+++ b/jspwiki-markdown/src/test/java/org/apache/wiki/render/MarkdownRendererTest.java
@@ -18,12 +18,7 @@
  */
 package org.apache.wiki.render;
 
-import java.io.BufferedReader;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
+import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -37,7 +32,11 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-import net.sf.ehcache.CacheManager;
+import java.io.BufferedReader;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
 
 
 public class MarkdownRendererTest {
@@ -106,14 +105,14 @@ public class MarkdownRendererTest {
         Assertions.assertEquals( "<p> This should be visible if the ACL allows you to see it</p>\n", translate( src ) );
         // in any case, we also check that the created wikipage has the ACL added
         Assertions.assertEquals( "  user = PerryMason: ((\"org.apache.wiki.auth.permissions.PagePermission\",\"JSPWiki:testpage\",\"view\"))\n",
-        		             testEngine.getPage( PAGE_NAME ).getAcl().toString() );
+        		             testEngine.getPageManager().getPage( PAGE_NAME ).getAcl().toString() );
     }
 
     @Test
     public void testMarkupExtensionMetadata() throws Exception {
         String src = "[{SET Perry='Mason'}]() Some text after setting metadata";
         Assertions.assertEquals( "<p> Some text after setting metadata</p>\n", translate( src ) );
-        Assertions.assertEquals( "Mason", testEngine.getPage( PAGE_NAME ).getAttribute( "Perry" ) );
+        Assertions.assertEquals( "Mason", testEngine.getPageManager().getPage( PAGE_NAME ).getAttribute( "Perry" ) );
     }
 
     @Test
@@ -271,7 +270,6 @@ public class MarkdownRendererTest {
 
     @BeforeEach
     public void setUp() throws Exception {
-        CacheManager.getInstance().removeAllCaches();
         props.setProperty( "jspwiki.translatorReader.matchEnglishPlurals", "true" );
         props.setProperty( "jspwiki.fileSystemProvider.pageDir", "./target/md-pageDir" );
         props.setProperty( "jspwiki.renderingManager.markupParser", MarkdownParser.class.getName() );
@@ -287,6 +285,7 @@ public class MarkdownRendererTest {
         }
 
         created.clear();
+        CacheManager.getInstance().removeAllCaches();
     }
 
     String translate( final String src ) throws Exception {
diff --git a/jspwiki-war/src/main/webapp/Comment.jsp b/jspwiki-war/src/main/webapp/Comment.jsp
index 1577189..5b998a9 100644
--- a/jspwiki-war/src/main/webapp/Comment.jsp
+++ b/jspwiki-war/src/main/webapp/Comment.jsp
@@ -87,7 +87,7 @@
     String changenote = TextUtil.replaceEntities( request.getParameter( "changenote" ) );
 
     WikiPage wikipage = wikiContext.getPage();
-    WikiPage latestversion = wiki.getPage( pagereq );
+    WikiPage latestversion = wiki.getPageManager().getPage( pagereq );
 
     session.removeAttribute( EditorManager.REQ_EDITEDTEXT );
 
diff --git a/jspwiki-war/src/main/webapp/Delete.jsp b/jspwiki-war/src/main/webapp/Delete.jsp
index b20fcce..40063d3 100644
--- a/jspwiki-war/src/main/webapp/Delete.jsp
+++ b/jspwiki-war/src/main/webapp/Delete.jsp
@@ -45,7 +45,7 @@
     String pagereq = wikiContext.getName();
 
     WikiPage wikipage      = wikiContext.getPage();
-    WikiPage latestversion = wiki.getPage( pagereq );
+    WikiPage latestversion = wiki.getPageManager().getPage( pagereq );
 
     String delete = request.getParameter( "delete" );
     String deleteall = request.getParameter( "delete-all" );
@@ -65,7 +65,7 @@
     {
         log.info("Deleting page "+pagereq+". User="+request.getRemoteUser()+", host="+HttpUtil.getRemoteAddress(request) );
 
-        wiki.deletePage( pagereq );
+        wiki.getPageManager().deletePage( pagereq );
 
         FixedQueue trail = (FixedQueue) session.getAttribute( BreadcrumbsTag.BREADCRUMBTRAIL_KEY );
         if( trail != null )
@@ -89,10 +89,10 @@
             {
                 int version = Integer.parseInt( paramName.substring(7) );
 
-                WikiPage p = wiki.getPage( pagereq, version );
+                WikiPage p = wiki.getPageManager().getPage( pagereq, version );
 
                 log.debug("Deleting version "+version);
-                wiki.deleteVersion( p );
+                wiki.getPageManager().deleteVersion( p );
             }
         }
 
diff --git a/jspwiki-war/src/main/webapp/Edit.jsp b/jspwiki-war/src/main/webapp/Edit.jsp
index 002a832..1178cc7 100644
--- a/jspwiki-war/src/main/webapp/Edit.jsp
+++ b/jspwiki-war/src/main/webapp/Edit.jsp
@@ -92,7 +92,7 @@
     }
 
     WikiPage wikipage = wikiContext.getPage();
-    WikiPage latestversion = wiki.getPage( pagereq );
+    WikiPage latestversion = wiki.getPageManager().getPage( pagereq );
 
     if( latestversion == null )
     {
diff --git a/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp b/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp
index f4cd8d6..7d02d4a 100644
--- a/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/InfoContent.jsp
@@ -44,7 +44,7 @@
   String creationAuthor ="";
 
   //FIXME -- seems not to work correctly for attachments !!
-  WikiPage firstPage = c.getEngine().getPage( wikiPage.getName(), 1 );
+  WikiPage firstPage = c.getEngine().getPageManager().getPage( wikiPage.getName(), 1 );
   if( firstPage != null )
   {
     creationAuthor = firstPage.getAuthor();
diff --git a/jspwiki-war/src/main/webapp/templates/210/PageTab.jsp b/jspwiki-war/src/main/webapp/templates/210/PageTab.jsp
index 05fde13..5b892a4 100644
--- a/jspwiki-war/src/main/webapp/templates/210/PageTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/PageTab.jsp
@@ -52,7 +52,7 @@
           <%--<wiki:PageVersion/>--%>
           <select id="version" name="version" onchange="this.form.submit();" >
 <% 
-   int latestVersion = c.getEngine().getPage( pagename, WikiProvider.LATEST_VERSION ).getVersion();
+   int latestVersion = c.getEngine().getPageManager().getPage( pagename, WikiProvider.LATEST_VERSION ).getVersion();
    int thisVersion = p.getVersion();
 
    if( thisVersion == WikiProvider.LATEST_VERSION ) thisVersion = latestVersion; //should not happen
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp
index 4192bb0..a99e778 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/CKeditor.jsp
@@ -66,7 +66,7 @@
   String clone = request.getParameter( "clone" );
   if( clone != null )
   {
-    WikiPage p = engine.getPage( clone );
+    WikiPage p = engine.getPageManager().getPage( clone );
     if( p != null )
     {
         AuthorizationManager mgr = engine.getAuthorizationManager();
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp
index 1fd54f0..16e33a0 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/FCK.jsp
@@ -55,7 +55,7 @@
   String clone = request.getParameter( "clone" );
   if( clone != null )
   {
-    WikiPage p = engine.getPage( clone );
+    WikiPage p = engine.getPageManager().getPage( clone );
     if( p != null )
     {
         AuthorizationManager mgr = engine.getAuthorizationManager();
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp
index 96d72ca..0073bbb 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/TinyMCE.jsp
@@ -66,7 +66,7 @@
   String clone = request.getParameter( "clone" );
   if( clone != null )
   {
-    WikiPage p = engine.getPage( clone );
+    WikiPage p = engine.getPageManager().getPage( clone );
     if( p != null )
     {
         AuthorizationManager mgr = engine.getAuthorizationManager();
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp
index 6a6bc71..22c1c34 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/plain.jsp
@@ -48,7 +48,7 @@
   String clone = request.getParameter( "clone" );
   if( clone != null )
   {
-    WikiPage p = engine.getPage( clone );
+    WikiPage p = engine.getPageManager().getPage( clone );
     if( p != null )
     {
         AuthorizationManager mgr = engine.getAuthorizationManager();
diff --git a/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp b/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp
index 4893ba2..3bc866c 100644
--- a/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp
+++ b/jspwiki-war/src/main/webapp/templates/210/editors/wysiwyg.jsp
@@ -48,7 +48,7 @@
   String clone = request.getParameter( "clone" );
   if( clone != null )
   {
-    WikiPage p = engine.getPage( clone );
+    WikiPage p = engine.getPageManager().getPage( clone );
     if( p != null )
     {
         AuthorizationManager mgr = engine.getAuthorizationManager();
diff --git a/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp b/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp
index ef39366..bfda22b 100644
--- a/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/InfoContent.jsp
@@ -42,7 +42,7 @@
   String creationAuthor ="";
 
   //FIXME -- seems not to work correctly for attachments !!
-  WikiPage firstPage = c.getEngine().getPage( wikiPage.getName(), 1 );
+  WikiPage firstPage = c.getEngine().getPageManager().getPage( wikiPage.getName(), 1 );
   if( firstPage != null )
   {
     creationAuthor = firstPage.getAuthor();
diff --git a/jspwiki-war/src/main/webapp/templates/default/PageTab.jsp b/jspwiki-war/src/main/webapp/templates/default/PageTab.jsp
index 05ceafd..1a17317 100644
--- a/jspwiki-war/src/main/webapp/templates/default/PageTab.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/PageTab.jsp
@@ -41,7 +41,7 @@
     WikiContext c = WikiContext.findContext( pageContext );
   %>
   <c:set var="thisVersion" value="<%= c.getPage().getVersion() %>" />
-  <c:set var="latestVersion" value="<%= c.getEngine().getPage( c.getPage().getName(), WikiProvider.LATEST_VERSION ).getVersion() %>" />
+  <c:set var="latestVersion" value="<%= c.getEngine().getPageManager().getPage( c.getPage().getName(), WikiProvider.LATEST_VERSION ).getVersion() %>" />
 
   <form action="<wiki:Link format='url' jsp='Wiki.jsp'/>"
         method="get"  accept-charset='UTF-8'>
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
index fe62516..c3c60e2 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
@@ -68,7 +68,7 @@
   String clone = request.getParameter( "clone" );
   if( clone != null )
   {
-    WikiPage p = engine.getPage( clone );
+    WikiPage p = engine.getPageManager().getPage( clone );
     if( p != null )
     {
         AuthorizationManager mgr = engine.getAuthorizationManager();
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
index 28eb602..2acd953 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
@@ -66,7 +66,7 @@
   String clone = request.getParameter( "clone" );
   if( clone != null )
   {
-    WikiPage p = engine.getPage( clone );
+    WikiPage p = engine.getPageManager().getPage( clone );
     if( p != null )
     {
         AuthorizationManager mgr = engine.getAuthorizationManager();
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp
index e3ba123..bc657a6 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/plain.jsp
@@ -48,7 +48,7 @@
   String clone = request.getParameter( "clone" );
   if( clone != null )
   {
-    WikiPage p = engine.getPage( clone );
+    WikiPage p = engine.getPageManager().getPage( clone );
     if( p != null )
     {
         AuthorizationManager mgr = engine.getAuthorizationManager();
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp
index 8f66f7f..6c62d9a 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/wysiwyg.jsp
@@ -60,7 +60,7 @@
   String clone = request.getParameter( "clone" );
   if( clone != null )
   {
-    WikiPage p = engine.getPage( clone );
+    WikiPage p = engine.getPageManager().getPage( clone );
     if( p != null )
     {
         AuthorizationManager mgr = engine.getAuthorizationManager();


[jspwiki] 19/32: WikiEngine#getPluginManager() and WikiEngine#getFilterManager() now only return their associated interface

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 be8e23f761fa4eb7a98571c59bcfb13a5bdf3c29
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Jan 5 17:08:58 2020 +0100

    WikiEngine#getPluginManager() and WikiEngine#getFilterManager() now only return their associated interface
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java | 14 ++++----------
 1 file changed, 4 insertions(+), 10 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 6333552..4308c3b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -1490,15 +1490,11 @@ public class WikiEngine  {
     /**
      *  Returns the current plugin manager.
      *
-     *  In 2.10 the PluginManager will be returned instead of the generic
-     *
      *  @since 1.6.1
      *  @return The current PluginManager instance
      */
-    @SuppressWarnings("unchecked")
-    public < T extends PluginManager > T getPluginManager()
-    {
-        return (T)m_pluginManager;
+    public PluginManager getPluginManager() {
+        return m_pluginManager;
     }
 
     /**
@@ -1567,10 +1563,8 @@ public class WikiEngine  {
      *  @since 2.1.88
      *  @return The current FilterManager instance
      */
-    @SuppressWarnings("unchecked")
-    public < T extends FilterManager > T getFilterManager()
-    {
-        return (T)m_filterManager;
+    public FilterManager getFilterManager() {
+        return m_filterManager;
     }
 
     /**


[jspwiki] 22/32: JSPWIKI-120: move pageExist(..) methods to PageManager, renamed as wikiPageExist(..)

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 74e8560d25dc2969e02c079ce5cf9e45e4feb559
Author: juanpablo <ju...@apache.org>
AuthorDate: Tue Jan 7 21:31:57 2020 +0100

    JSPWIKI-120: move pageExist(..) methods to PageManager, renamed as wikiPageExist(..)
    
    pageExist(..) methods on PageManager look for pages on the underlying WikiPageProvider, whereas wikiPageExis(..) ones look for all kind of wiki pages: WiiPages, Attachments and special pages (i.e. certain kind of references without an underlying WikiPage)
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 117 +----------
 .../org/apache/wiki/pages/DefaultPageManager.java  |  52 ++++-
 .../java/org/apache/wiki/pages/PageManager.java    |  55 ++++-
 .../org/apache/wiki/plugin/BugReportHandler.java   | 224 ++++++++-------------
 .../main/java/org/apache/wiki/plugin/IfPlugin.java | 131 ++++++------
 .../apache/wiki/plugin/RecentChangesPlugin.java    |   2 +-
 .../apache/wiki/plugin/ReferredPagesPlugin.java    | 150 +++++++-------
 .../java/org/apache/wiki/plugin/WeblogPlugin.java  |   2 +-
 .../wiki/references/DefaultReferenceManager.java   |   6 +-
 .../apache/wiki/tags/AttachmentsIteratorTag.java   |  97 ++++-----
 .../main/java/org/apache/wiki/tags/AuthorTag.java  |  47 ++---
 .../java/org/apache/wiki/tags/BreadcrumbsTag.java  |   8 +-
 .../java/org/apache/wiki/tags/CalendarTag.java     |   2 +-
 .../java/org/apache/wiki/tags/CheckVersionTag.java |  90 +++------
 .../java/org/apache/wiki/tags/DiffLinkTag.java     |   2 +-
 .../org/apache/wiki/tags/HasAttachmentsTag.java    |  28 +--
 .../org/apache/wiki/tags/HistoryIteratorTag.java   |   2 +-
 .../java/org/apache/wiki/tags/InsertPageTag.java   |   2 +-
 .../java/org/apache/wiki/tags/NoSuchPageTag.java   |   2 +-
 .../java/org/apache/wiki/tags/PageInfoLinkTag.java |  57 ++----
 .../java/org/apache/wiki/tags/PageSizeTag.java     |   3 +-
 .../java/org/apache/wiki/tags/WikiTagBase.java     |  68 +++----
 .../java/org/apache/wiki/tasks/TasksManager.java   |   9 +-
 .../java/org/apache/wiki/xmlrpc/RPCHandler.java    |  91 +++------
 .../org/apache/wiki/xmlrpc/RPCHandlerUTF8.java     |   4 +-
 .../test/java/org/apache/wiki/WikiEngineTest.java  |  42 +---
 .../wiki/attachment/AttachmentManagerTest.java     |  10 +-
 .../apache/wiki/pages/DefaultPageManagerTest.java  |  45 ++++-
 .../apache/wiki/workflow/ApprovalWorkflowTest.java |   8 +-
 jspwiki-war/src/main/webapp/Login.jsp              |   3 +-
 jspwiki-war/src/main/webapp/UserPreferences.jsp    |   4 +-
 jspwiki-war/src/main/webapp/rss.jsp                |   2 +-
 32 files changed, 565 insertions(+), 800 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 a6183f4..d6c94e9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -701,8 +701,7 @@ public class WikiEngine  {
             pages.addAll( m_attachmentManager.getAllAttachments() );
 
             // Build a new manager with default key lists.
-            if( m_referenceManager == null )
-            {
+            if( m_referenceManager == null ) {
                 m_referenceManager = ClassUtil.getMappedObject(ReferenceManager.class.getName(), this );
                 m_referenceManager.initialize( pages );
             }
@@ -722,7 +721,6 @@ public class WikiEngine  {
      *
      *  @return The wiki properties
      */
-
     public Properties getWikiProperties()
     {
         return m_properties;
@@ -977,18 +975,15 @@ public class WikiEngine  {
     }
 
     /**
-     *  Beautifies the title of the page by appending non-breaking spaces
-     *  in suitable places.  This is really suitable only for HTML output,
+     *  Beautifies the title of the page by appending non-breaking spaces in suitable places.  This is really suitable only for HTML output,
      *  as it uses the &amp;nbsp; -character.
      *
      *  @param title The title to beautify
      *  @return A beautified title.
      *  @since 2.1.127
      */
-    public String beautifyTitleNoBreak( String title )
-    {
-        if( m_beautifyTitle )
-        {
+    public String beautifyTitleNoBreak( final String title ) {
+        if( m_beautifyTitle ) {
             return TextUtil.beautifyString( title, "&nbsp;" );
         }
 
@@ -996,112 +991,14 @@ public class WikiEngine  {
     }
 
     /**
-     *  Returns true, if the requested page (or an alias) exists.  Will consider
-     *  any version as existing.  Will also consider attachments.
-     *
-     *  @param page WikiName of the page.
-     *  @return true, if page (or attachment) exists.
-     */
-    public boolean pageExists( String page )
-    {
-        Attachment att = null;
-
-        try
-        {
-            if( m_commandResolver.getSpecialPageReference(page) != null ) return true;
-
-            if( getFinalPageName( page ) != null )
-            {
-                return true;
-            }
-
-            att = getAttachmentManager().getAttachmentInfo( (WikiContext)null, page );
-        }
-        catch( ProviderException e )
-        {
-            log.debug("pageExists() failed to find attachments",e);
-        }
-
-        return att != null;
-    }
-
-    /**
-     *  Returns true, if the requested page (or an alias) exists with the
-     *  requested version.
-     *
-     *  @param page Page name
-     *  @param version Page version
-     *  @return True, if page (or alias, or attachment) exists
-     *  @throws ProviderException If the provider fails.
-     */
-    public boolean pageExists( String page, int version )
-        throws ProviderException
-    {
-        if( m_commandResolver.getSpecialPageReference(page) != null ) return true;
-
-        String finalName = getFinalPageName( page );
-
-        boolean isThere = false;
-
-        if( finalName != null )
-        {
-            //
-            //  Go and check if this particular version of this page
-            //  exists.
-            //
-            isThere = m_pageManager.pageExists( finalName, version );
-        }
-
-        if( isThere == false )
-        {
-            //
-            //  Go check if such an attachment exists.
-            //
-            try
-            {
-                isThere = getAttachmentManager().getAttachmentInfo( (WikiContext)null, page, version ) != null;
-            }
-            catch( ProviderException e )
-            {
-                log.debug("pageExists() failed to find attachments",e);
-            }
-        }
-
-        return isThere;
-    }
-
-    /**
-     *  Returns true, if the requested page (or an alias) exists, with the
-     *  specified version in the WikiPage.
-     *
-     *  @param page A WikiPage object describing the name and version.
-     *  @return true, if the page (or alias, or attachment) exists.
-     *  @throws ProviderException If something goes badly wrong.
-     *  @since 2.0
-     */
-    public boolean pageExists( WikiPage page )
-        throws ProviderException
-    {
-        if( page != null )
-        {
-            return pageExists( page.getName(), page.getVersion() );
-        }
-        return false;
-    }
-
-    /**
-     *  Returns the correct page name, or null, if no such
-     *  page can be found.  Aliases are considered. This
-     *  method simply delegates to
+     *  Returns the correct page name, or null, if no such page can be found.  Aliases are considered. This method simply delegates to
      *  {@link org.apache.wiki.ui.CommandResolver#getFinalPageName(String)}.
      *  @since 2.0
      *  @param page Page name.
      *  @return The rewritten page name, or null, if the page does not exist.
      *  @throws ProviderException If something goes wrong in the backend.
      */
-    public String getFinalPageName( String page )
-        throws ProviderException
-    {
+    public String getFinalPageName( final String page ) throws ProviderException {
         return m_commandResolver.getFinalPageName( page );
     }
 
@@ -1377,7 +1274,7 @@ public class WikiEngine  {
 
         // Check if creation of empty pages is allowed; bail if not
         final boolean allowEmpty = TextUtil.getBooleanProperty( m_properties, PROP_ALLOW_CREATION_OF_EMPTY_PAGES, false );
-        if ( !allowEmpty && !pageExists( page ) && text.trim().equals( "" ) ) {
+        if ( !allowEmpty && !m_pageManager.wikiPageExists( page ) && text.trim().equals( "" ) ) {
             return;
         }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
index d47f910..229889e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/DefaultPageManager.java
@@ -467,6 +467,56 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
 
     /**
      * {@inheritDoc}
+     * @see org.apache.wiki.pages.PageManager#wikiPageExists(java.lang.String)
+     */
+    public boolean wikiPageExists( final String page ) {
+        if( m_engine.getCommandResolver().getSpecialPageReference( page ) != null ) {
+            return true;
+        }
+
+        Attachment att = null;
+        try {
+            if( m_engine.getFinalPageName( page ) != null ) {
+                return true;
+            }
+
+            att = m_engine.getAttachmentManager().getAttachmentInfo( null, page );
+        } catch( final ProviderException e ) {
+            LOG.debug( "pageExists() failed to find attachments", e );
+        }
+
+        return att != null;
+    }
+
+    /**
+     * {@inheritDoc}
+     * @see org.apache.wiki.pages.PageManager#wikiPageExists(java.lang.String, int)
+     */
+    public boolean wikiPageExists( final String page, final int version ) throws ProviderException {
+        if( m_engine.getCommandResolver().getSpecialPageReference( page ) != null ) {
+            return true;
+        }
+
+        boolean isThere = false;
+        final String finalName = m_engine.getFinalPageName( page );
+        if( finalName != null ) {
+            isThere = pageExists( finalName, version );
+        }
+
+        if( !isThere ) {
+            //  Go check if such an attachment exists.
+            try {
+                isThere = m_engine.getAttachmentManager().getAttachmentInfo( null, page, version ) != null;
+            } catch( final ProviderException e ) {
+                LOG.debug( "wikiPageExists() failed to find attachments", e );
+            }
+        }
+
+        return isThere;
+    }
+
+    /**
+     * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#deleteVersion(org.apache.wiki.WikiPage)
      */
     @Override
@@ -474,7 +524,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         if( page instanceof Attachment ) {
             m_engine.getAttachmentManager().deleteVersion( ( Attachment )page );
         } else {
-            m_provider.deleteVersion(page.getName(), page.getVersion());
+            m_provider.deleteVersion( page.getName(), page.getVersion() );
             // FIXME: If this was the latest, reindex Lucene, update RefMgr
         }
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index e3435fb..632e3b4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -261,7 +261,7 @@ public interface PageManager extends WikiEventListener {
     Set< WikiPage > getRecentChanges();
 
     /**
-     * Returns true, if the page exists (any version).
+     * Returns true, if the page exists (any version) on the underlying WikiPageProvider.
      *
      * @param pageName Name of the page.
      * @return A boolean value describing the existence of a page
@@ -270,7 +270,7 @@ public interface PageManager extends WikiEventListener {
     boolean pageExists( String pageName ) throws ProviderException;
 
     /**
-     * Checks for existence of a specific page and version.
+     * Checks for existence of a specific page and version on the underlying WikiPageProvider.
      *
      * @param pageName Name of the page
      * @param version  The version to check
@@ -281,6 +281,57 @@ public interface PageManager extends WikiEventListener {
     boolean pageExists( String pageName, int version ) throws ProviderException;
 
     /**
+     *  Checks for existence of a specific page and version denoted by a WikiPage on the underlying WikiPageProvider.
+     *
+     *  @param page A WikiPage object describing the name and version.
+     *  @return true, if the page (or alias, or attachment) exists.
+     *  @throws ProviderException If something goes badly wrong.
+     *  @since 2.0
+     */
+    default boolean pageExists( final WikiPage page ) throws ProviderException {
+        if( page != null ) {
+            return pageExists( page.getName(), page.getVersion() );
+        }
+        return false;
+    }
+
+    /**
+     *  Returns true, if the requested page (or an alias) exists.  Will consider any version as existing. Will check for all types of
+     *  WikiPages: wiki pages themselves, attachments and special pages (non-existant references to other pages).
+     *
+     *  @param page WikiName of the page.
+     *  @return true, if page (or attachment) exists.
+     */
+    boolean wikiPageExists( String page );
+
+    /**
+     *  Returns true, if the requested page (or an alias) exists with the requested version. Will check for all types of
+     *  WikiPages: wiki pages themselves, attachments and special pages (non-existant references to other pages).
+     *
+     *  @param page Page name
+     *  @param version Page version
+     *  @return True, if page (or alias, or attachment) exists
+     *  @throws ProviderException If the provider fails.
+     */
+    boolean wikiPageExists( String page, int version ) throws ProviderException;
+
+    /**
+     *  Returns true, if the requested page (or an alias) exists, with the specified version in the WikiPage. Will check for all types of
+     *  WikiPages: wiki pages themselves, attachments and special pages (non-existant references to other pages).
+     *
+     *  @param page A WikiPage object describing the name and version.
+     *  @return true, if the page (or alias, or attachment) exists.
+     *  @throws ProviderException If something goes badly wrong.
+     *  @since 2.0
+     */
+    default boolean wikiPageExists( final WikiPage page ) throws ProviderException {
+        if( page != null ) {
+            return wikiPageExists( page.getName(), page.getVersion() );
+        }
+        return false;
+    }
+
+    /**
      * Deletes only a specific version of a WikiPage.
      *
      * @param page The page to delete.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java
index 8fb20a3..8ad5f9b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/BugReportHandler.java
@@ -18,13 +18,6 @@
  */
 package org.apache.wiki.plugin;
 
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.security.Principal;
-import java.text.MessageFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -36,6 +29,17 @@ import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.preferences.Preferences;
 
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.security.Principal;
+import java.text.MessageFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Map;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.StringTokenizer;
+
 /**
  *  Provides a handler for bug reports.  Still under construction.
  *
@@ -49,10 +53,10 @@ import org.apache.wiki.preferences.Preferences;
  *  </ul>
  *
  */
-public class BugReportHandler
-    implements WikiPlugin
-{
-    private static Logger log = Logger.getLogger( BugReportHandler.class );
+public class BugReportHandler implements WikiPlugin {
+
+    private static final Logger log = Logger.getLogger( BugReportHandler.class );
+    private static final String DEFAULT_DATEFORMAT = "dd-MMM-yyyy HH:mm:ss zzz";
 
     /** Parameter name for setting the title.  Value is <tt>{@value}</tt>. */
     public static final String PARAM_TITLE          = "title";
@@ -65,148 +69,105 @@ public class BugReportHandler
     /** Parameter name for setting the page.  Value is <tt>{@value}</tt>. */
     public static final String PARAM_PAGE           = "page";
 
-    private static final String DEFAULT_DATEFORMAT = "dd-MMM-yyyy HH:mm:ss zzz";
-
     /**
      *  {@inheritDoc}
      */
-    public String execute( WikiContext context, Map<String, String> params )
-        throws PluginException
-    {
-        String    title;
-        String    description;
-        String    version;
-        String    submitter = null;
-        SimpleDateFormat format = new SimpleDateFormat( DEFAULT_DATEFORMAT );
-        ResourceBundle rb = Preferences.getBundle( context, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
-
-        title       = params.get( PARAM_TITLE );
-        description = params.get( PARAM_DESCRIPTION );
-        version     = params.get( PARAM_VERSION );
-
-        Principal wup = context.getCurrentUser();
-
-        if( wup != null )
-        {
+    public String execute( final WikiContext context, final Map< String, String > params ) throws PluginException {
+        final String title = params.get( PARAM_TITLE );
+        String description = params.get( PARAM_DESCRIPTION );
+        String version = params.get( PARAM_VERSION );
+        String submitter = null;
+        final SimpleDateFormat format = new SimpleDateFormat( DEFAULT_DATEFORMAT );
+        final ResourceBundle rb = Preferences.getBundle( context, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
+        final Principal wup = context.getCurrentUser();
+
+        if( wup != null ) {
             submitter = wup.getName();
         }
 
-        if( title == null ) throw new PluginException(rb.getString("bugreporthandler.titlerequired"));
-        if( title.length() == 0 ) return "";
+        if( title == null ) {
+            throw new PluginException(rb.getString("bugreporthandler.titlerequired"));
+        }
+        if( title.length() == 0 ) {
+            return "";
+        }
 
-        if( description == null ) description = "";
-        if( version == null ) version = "unknown";
+        if( description == null ) {
+            description = "";
+        }
+        if( version == null ) {
+            version = "unknown";
+        }
 
-        Properties mappings = parseMappings( params.get( PARAM_MAPPINGS ) );
+        final Properties mappings = parseMappings( params.get( PARAM_MAPPINGS ) );
 
-        //
         //  Start things
-        //
+        try {
+            final StringWriter str = new StringWriter();
+            final PrintWriter out = new PrintWriter( str );
+            final Date d = new Date();
 
-        try
-        {
-            StringWriter str = new StringWriter();
-            PrintWriter out = new PrintWriter( str );
-
-            Date d = new Date();
-
-            //
             //  Outputting of basic data
-            //
-            out.println("|"+mappings.getProperty(PARAM_TITLE,"Title")+"|"+title);
-            out.println("|"+mappings.getProperty("date","Date")+"|"+format.format(d));
-            out.println("|"+mappings.getProperty(PARAM_VERSION,"Version")+"|"+version);
-            if( submitter != null )
-            {
-                out.println("|"+mappings.getProperty("submitter","Submitter")+
-                            "|"+submitter);
+            out.println( "|" + mappings.getProperty(PARAM_TITLE,"Title" ) + "|" + title );
+            out.println( "|" + mappings.getProperty("date","Date" ) + "|" + format.format( d ) );
+            out.println( "|" + mappings.getProperty(PARAM_VERSION,"Version" ) + "|" + version );
+            if( submitter != null ) {
+                out.println("|"+mappings.getProperty("submitter","Submitter") + "|" + submitter );
             }
 
-            //
             //  Outputting the other parameters added to this.
-            //
-            for( Iterator<Map.Entry<String, String>>  i = params.entrySet().iterator(); i.hasNext(); )
-            {
-                Map.Entry<String, String> entry = i.next();
-
-                if( entry.getKey().equals( PARAM_TITLE ) ||
-                    entry.getKey().equals( PARAM_DESCRIPTION ) ||
-                    entry.getKey().equals( PARAM_VERSION ) ||
-                    entry.getKey().equals( PARAM_MAPPINGS ) ||
-                    entry.getKey().equals( PARAM_PAGE ) ||
-                    entry.getKey().startsWith("_") )
-                {
-                    // Ignore this
-                }
-                else
-                {
-                    //
-                    //  If no mapping has been defined, just ignore
-                    //  it.
-                    //
-                    String head = mappings.getProperty( entry.getKey(), entry.getKey() );
-                    if( head.length() > 0 )
-                    {
-                        out.println("|"+head+
-                                    "|"+entry.getValue());
+            for( final Map.Entry< String, String > entry : params.entrySet() ) {
+                if( !( entry.getKey().equals( PARAM_TITLE ) ||
+                       entry.getKey().equals( PARAM_DESCRIPTION ) ||
+                       entry.getKey().equals( PARAM_VERSION ) ||
+                       entry.getKey().equals( PARAM_MAPPINGS ) ||
+                       entry.getKey().equals( PARAM_PAGE ) ||
+                       entry.getKey().startsWith( "_" )
+                     ) ) {
+                    //  If no mapping has been defined, just ignore it.
+                    final String head = mappings.getProperty( entry.getKey(), entry.getKey() );
+                    if( head.length() > 0 ) {
+                        out.println( "|" + head + "|" + entry.getValue() );
                     }
                 }
             }
 
             out.println();
             out.println( description );
-
             out.close();
 
-            //
             //  Now create a new page for this bug report
-            //
-            String pageName = findNextPage( context, title, params.get( PARAM_PAGE ) );
-
-            WikiPage newPage = new WikiPage( context.getEngine(), pageName );
-            WikiContext newContext = (WikiContext)context.clone();
+            final String pageName = findNextPage( context, title, params.get( PARAM_PAGE ) );
+            final WikiPage newPage = new WikiPage( context.getEngine(), pageName );
+            final WikiContext newContext = (WikiContext)context.clone();
             newContext.setPage( newPage );
+            context.getEngine().saveText( newContext, str.toString() );
 
-            context.getEngine().saveText( newContext,
-                                          str.toString() );
-
-            MessageFormat formatter = new MessageFormat("");
+            final MessageFormat formatter = new MessageFormat("");
             formatter.applyPattern( rb.getString("bugreporthandler.new") );
-            String[] args = { "<a href=\""+context.getViewURL(pageName)+"\">"+pageName+"</a>" };
+            final String[] args = { "<a href=\""+context.getViewURL(pageName)+"\">"+pageName+"</a>" };
 
             return formatter.format( args );
-        }
-        catch( RedirectException e )
-        {
+        } catch( final RedirectException e ) {
             log.info("Saving not allowed, reason: '"+e.getMessage()+"', can't redirect to "+e.getRedirect());
-
             throw new PluginException("Saving not allowed, reason: "+e.getMessage());
-        }
-        catch( WikiException e )
-        {
-            log.error("Unable to save page!",e);
-
-            return rb.getString("bugreporthandler.unable");
+        } catch( final WikiException e ) {
+            log.error( "Unable to save page!", e );
+            return rb.getString("bugreporthandler.unable" );
         }
     }
 
     /**
-     *  Finds a free page name for adding the bug report.  Tries to construct a page,
-     *  and if it's found, adds a number to it and tries again.
+     *  Finds a free page name for adding the bug report.  Tries to construct a page, and if it's found, adds a number to it
+     *  and tries again.
      */
-    private synchronized String findNextPage( WikiContext context,
-                                              String title,
-                                              String baseName )
-    {
-        String basicPageName = ((baseName != null)?baseName:"Bug")+MarkupParser.cleanLink(title);
-
-        WikiEngine engine = context.getEngine();
+    private synchronized String findNextPage( final WikiContext context, final String title, final String baseName ) {
+        final String basicPageName = ( ( baseName != null ) ? baseName : "Bug" ) + MarkupParser.cleanLink( title );
+        final WikiEngine engine = context.getEngine();
 
         String pageName = basicPageName;
         long   lastbug  = 2;
-
-        while( engine.pageExists( pageName ) )
-        {
+        while( engine.getPageManager().wikiPageExists( pageName ) ) {
             pageName = basicPageName + lastbug++;
         }
 
@@ -218,37 +179,30 @@ public class BugReportHandler
      *  <p>
      *  FIXME: Should probably be in TextUtil or somewhere.
      */
-    private Properties parseMappings( String mappings )
-    {
-        Properties props = new Properties();
-
-        if( mappings == null ) return props;
-
-        StringTokenizer tok = new StringTokenizer( mappings, ";" );
-
-        while( tok.hasMoreTokens() )
-        {
-            String t = tok.nextToken();
-
-            int colon = t.indexOf("=");
+    private Properties parseMappings( final String mappings ) {
+        final Properties props = new Properties();
+        if( mappings == null ) {
+            return props;
+        }
 
-            String key;
-            String value;
+        final StringTokenizer tok = new StringTokenizer( mappings, ";" );
+        while( tok.hasMoreTokens() ) {
+            final String t = tok.nextToken();
+            final int colon = t.indexOf("=");
+            final String key;
+            final String value;
 
-            if( colon > 0 )
-            {
+            if( colon > 0 ) {
                 key = t.substring(0,colon);
                 value = t.substring(colon+1);
-            }
-            else
-            {
+            } else {
                 key = t;
                 value = "";
             }
 
             props.setProperty( key, value );
         }
-
         return props;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/IfPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/IfPlugin.java
index a4902f7..64305d0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/IfPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/IfPlugin.java
@@ -188,62 +188,60 @@ public class IfPlugin implements WikiPlugin
         return include;
     }
 
-    private static boolean checkExists( WikiContext context, String page, String exists )
-    {
-        if( exists == null ) return false;
-        return !context.getEngine().pageExists(page) ^ TextUtil.isPositive(exists);
+    private static boolean checkExists( final WikiContext context, final String page, final String exists ) {
+        if( exists == null ) {
+            return false;
+        }
+        return !context.getEngine().getPageManager().wikiPageExists( page ) ^ TextUtil.isPositive(exists);
     }
 
-    private static boolean checkVarExists( String varContent, String exists )
-    {
-        if( exists == null ) return false;
-        return (varContent == null ) ^ TextUtil.isPositive(exists);
+    private static boolean checkVarExists( final String varContent, final String exists ) {
+        if( exists == null ) {
+            return false;
+        }
+        return varContent == null ^ TextUtil.isPositive( exists );
     }
 
-    private static boolean checkGroup( WikiContext context, String group )
-    {
-        if( group == null ) return false;
-        String[] groupList = StringUtils.split(group,'|');
+    private static boolean checkGroup( final WikiContext context, final String group ) {
+        if( group == null ) {
+            return false;
+        }
+        final String[] groupList = StringUtils.split(group,'|');
         boolean include = false;
 
-        for( int i = 0; i < groupList.length; i++ )
-        {
-            String gname = groupList[i];
+        for( final String grp : groupList ) {
+            String gname = grp;
             boolean invert = false;
-            if( groupList[i].startsWith("!") )
-            {
-                if( groupList[i].length() > 1 ) 
-                {
-                    gname = groupList[i].substring( 1 );
+            if( grp.startsWith( "!" ) ) {
+                if( grp.length() > 1 ) {
+                    gname = grp.substring( 1 );
                 }
                 invert = true;
             }
 
-            Principal g = context.getEngine().getAuthorizationManager().resolvePrincipal(gname);
+            final Principal g = context.getEngine().getAuthorizationManager().resolvePrincipal( gname );
 
             include |= context.getEngine().getAuthorizationManager().isUserInRole( context.getWikiSession(), g ) ^ invert;
         }
         return include;
     }
 
-    private static boolean checkUser( WikiContext context, String user )
-    {
-        if( user == null || context.getCurrentUser() == null ) return false;
+    private static boolean checkUser( final WikiContext context, final String user ) {
+        if( user == null || context.getCurrentUser() == null ) {
+            return false;
+        }
 
-        String[] list = StringUtils.split(user,'|');
+        final String[] list = StringUtils.split(user,'|');
         boolean include = false;
 
-        for( int i = 0; i < list.length; i++ )
-        {
-            String userToCheck = list[i];
+        for( final String usr : list ) {
+            String userToCheck = usr;
             boolean invert = false;
-            if( list[i].startsWith("!") )
-            {
+            if( usr.startsWith( "!" ) ) {
                 invert = true;
                 // strip !
-                if(  user.length() > 1 ) 
-                {
-                    userToCheck = list[i].substring( 1 );
+                if( user.length() > 1 ) {
+                    userToCheck = usr.substring( 1 );
                 }
             }
 
@@ -253,67 +251,56 @@ public class IfPlugin implements WikiPlugin
     }
 
     // TODO: Add subnetwork matching, e.g. 10.0.0.0/8
-    private static boolean checkIP( WikiContext context, String ipaddr )
-    {
-        if( ipaddr == null || context.getHttpRequest() == null ) return false;
+    private static boolean checkIP( final WikiContext context, final String ipaddr ) {
+        if( ipaddr == null || context.getHttpRequest() == null ) {
+            return false;
+        }
 
-        
-        String[] list = StringUtils.split(ipaddr,'|');
+        final String[] list = StringUtils.split(ipaddr,'|');
         boolean include = false;
 
-        for( int i = 0; i < list.length; i++ )
-        {
-            String ipaddrToCheck = list[i];
+        for( final String ip : list ) {
+            String ipaddrToCheck = ip;
             boolean invert = false;
-            if( list[i].startsWith("!") )
-            {
+            if( ip.startsWith( "!" ) ) {
                 invert = true;
                 // strip !
-                if(  list[i].length() > 1 ) 
-                {
-                    ipaddrToCheck = list[i].substring( 1 );
+                if( ip.length() > 1 ) {
+                    ipaddrToCheck = ip.substring( 1 );
                 }
             }
 
-            include |= ipaddrToCheck.equals( HttpUtil.getRemoteAddress(context.getHttpRequest()) ) ^ invert;
+            include |= ipaddrToCheck.equals( HttpUtil.getRemoteAddress( context.getHttpRequest() ) ) ^ invert;
         }
         return include;
     }
 
-    private static boolean doMatch( String content, String pattern )
-        throws PluginException
-    {
-        PatternCompiler compiler = new Perl5Compiler();
-        PatternMatcher  matcher  = new Perl5Matcher();
+    private static boolean doMatch( final String content, final String pattern ) throws PluginException {
+        final PatternCompiler compiler = new Perl5Compiler();
+        final PatternMatcher  matcher  = new Perl5Matcher();
 
-        try
-        {
-            Pattern matchp = compiler.compile( pattern, Perl5Compiler.SINGLELINE_MASK );
-            // m_exceptPattern = compiler.compile( exceptPattern, Perl5Compiler.SINGLELINE_MASK );
+        try {
+            final Pattern matchp = compiler.compile( pattern, Perl5Compiler.SINGLELINE_MASK );
             return matcher.matches( content, matchp );
-        }
-        catch( MalformedPatternException e )
-        {
-            throw new PluginException("Faulty pattern "+pattern);
+        } catch( final MalformedPatternException e ) {
+            throw new PluginException( "Faulty pattern " + pattern );
         }
 
     }
 
-    private static boolean checkContains( String pagecontent, String matchPattern )
-        throws PluginException
-    {
-        if( pagecontent == null || matchPattern == null ) return false;
+    private static boolean checkContains( final String pagecontent, final String matchPattern ) throws PluginException {
+        if( pagecontent == null || matchPattern == null ) {
+            return false;
+        }
 
         return doMatch( pagecontent, ".*"+matchPattern+".*" );
     }
 
-    private static boolean checkIs( String content, String matchPattern )
-        throws PluginException
-    {
-        if( content == null || matchPattern == null ) return false;
-
-        matchPattern = "^"+matchPattern+"$";
-
-        return doMatch(content, matchPattern);
+    private static boolean checkIs( final String content, final String matchPattern ) throws PluginException {
+        if( content == null || matchPattern == null ) {
+            return false;
+        }
+        return doMatch( content, "^" + matchPattern + "$");
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java
index 16c1d41..642041c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/RecentChangesPlugin.java
@@ -182,7 +182,7 @@ public class RecentChangesPlugin extends AbstractReferralPlugin implements WikiP
                     authorinfo.setAttribute( XHTML.ATTR_class, "author" );
                     
                     if( author != null ) {
-                        if( engine.pageExists( author ) ) {
+                        if( engine.getPageManager().wikiPageExists( author ) ) {
                             authorinfo.addContent( XhtmlUtil.link( context.getURL( WikiContext.VIEW, author ), author ) );
                         } else {
                             authorinfo.addContent( author );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferredPagesPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferredPagesPlugin.java
index a586057..a284660 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferredPagesPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferredPagesPlugin.java
@@ -36,7 +36,6 @@ import org.apache.wiki.util.TextUtil;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.Map;
 
 
@@ -56,7 +55,7 @@ import java.util.Map;
  */
 public class ReferredPagesPlugin implements WikiPlugin {
 
-    private static Logger log = Logger.getLogger( ReferredPagesPlugin.class );
+    private static final Logger log = Logger.getLogger( ReferredPagesPlugin.class );
     private WikiEngine     m_engine;
     private int            m_depth;
     private HashSet<String> m_exists  = new HashSet<>();
@@ -94,20 +93,29 @@ public class ReferredPagesPlugin implements WikiPlugin {
     /**
      *  {@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 {
         m_engine = context.getEngine();
-
-        WikiPage         page   = context.getPage();
-        if( page == null ) return "";
+        final WikiPage page = context.getPage();
+        if( page == null ) {
+            return "";
+        }
 
         // parse parameters
         String rootname = params.get( PARAM_ROOT );
-        if( rootname == null ) rootname = page.getName() ;
+        if( rootname == null ) {
+            rootname = page.getName() ;
+        }
 
         String format = params.get( PARAM_FORMAT );
-        if( format == null) format = "";
-        if( format.indexOf( "full" ) >=0 ) m_formatCompact = false ;
-        if( format.indexOf( "sort" ) >=0 ) m_formatSort    = true  ;
+        if( format == null) {
+            format = "";
+        }
+        if( format.contains( "full" ) ) {
+            m_formatCompact = false ;
+        }
+        if( format.contains( "sort" ) ) {
+            m_formatSort = true  ;
+        }
 
         m_depth = TextUtil.parseIntParameter( params.get( PARAM_DEPTH ), MIN_DEPTH );
         if( m_depth > MAX_DEPTH )  m_depth = MAX_DEPTH;
@@ -126,43 +134,34 @@ public class ReferredPagesPlugin implements WikiPlugin {
         //
         // do the actual work
         //
-        String href  = context.getViewURL(rootname);
-        String title = "ReferredPagesPlugin: depth["+m_depth+
-                       "] include["+includePattern+"] exclude["+excludePattern+
-                       "] format["+(m_formatCompact ? "compact" : "full") +
-                       (m_formatSort ? " sort" : "") + "]";
-
-        m_result.append("<div class=\"ReferredPagesPlugin\">\n");
-        m_result.append("<a class=\"wikipage\" href=\""+ href +
-                        "\" title=\"" + TextUtil.replaceEntities(title) +
-                        "\">" + TextUtil.replaceEntities(rootname) + "</a>\n");
-        m_exists.add(rootname);
+        final String href  = context.getViewURL( rootname );
+        final String title = "ReferredPagesPlugin: depth[" + m_depth +
+                             "] include[" + includePattern + "] exclude[" + excludePattern +
+                             "] format[" + ( m_formatCompact ? "compact" : "full" ) +
+                             ( m_formatSort ? " sort" : "" ) + "]";
+
+        m_result.append( "<div class=\"ReferredPagesPlugin\">\n" );
+        m_result.append( "<a class=\"wikipage\" href=\""+ href +
+                         "\" title=\"" + TextUtil.replaceEntities( title ) +
+                         "\">" + TextUtil.replaceEntities( rootname ) + "</a>\n" );
+        m_exists.add( rootname );
 
         // pre compile all needed patterns
         // glob compiler :  * is 0..n instance of any char  -- more convenient as input
         // perl5 compiler : .* is 0..n instances of any char -- more powerful
         //PatternCompiler g_compiler = new GlobCompiler();
-        PatternCompiler compiler = new Perl5Compiler();
-
-        try
-        {
-            m_includePattern = compiler.compile(includePattern);
-
-            m_excludePattern = compiler.compile(excludePattern);
-        }
-        catch( MalformedPatternException e )
-        {
-            if (m_includePattern == null )
-            {
-                throw new PluginException("Illegal include pattern detected.");
-            }
-            else if (m_excludePattern == null )
-            {
-                throw new PluginException("Illegal exclude pattern detected.");
-            }
-            else
-            {
-                throw new PluginException("Illegal internal pattern detected.");
+        final PatternCompiler compiler = new Perl5Compiler();
+
+        try {
+            m_includePattern = compiler.compile( includePattern );
+            m_excludePattern = compiler.compile( excludePattern );
+        } catch( final MalformedPatternException e ) {
+            if( m_includePattern == null ) {
+                throw new PluginException( "Illegal include pattern detected." );
+            } else if( m_excludePattern == null ) {
+                throw new PluginException( "Illegal exclude pattern detected." );
+            } else {
+                throw new PluginException( "Illegal internal pattern detected." );
             }
         }
 
@@ -179,41 +178,50 @@ public class ReferredPagesPlugin implements WikiPlugin {
     /**
      * Retrieves a list of all referred pages. Is called recursively depending on the depth parameter.
      */
-    private void getReferredPages( WikiContext context, String pagename, int depth ) {
-        if( depth >= m_depth ) return;  // end of recursion
-        if( pagename == null ) return;
-        if( !m_engine.pageExists(pagename) ) return;
-
-        ReferenceManager mgr = m_engine.getReferenceManager();
-
-        Collection<String> allPages = mgr.findRefersTo( pagename );
+    private void getReferredPages( final WikiContext context, final String pagename, int depth ) {
+        if( depth >= m_depth ) {
+            return;  // end of recursion
+        }
+        if( pagename == null ) {
+            return;
+        }
+        if( !m_engine.getPageManager().wikiPageExists(pagename) ) {
+            return;
+        }
 
+        final ReferenceManager mgr = m_engine.getReferenceManager();
+        final Collection< String > allPages = mgr.findRefersTo( pagename );
         handleLinks( context, allPages, ++depth, pagename );
     }
 
-    private void handleLinks(WikiContext context,Collection<String> links, int depth, String pagename) {
+    private void handleLinks( final WikiContext context, final Collection<String> links, final int depth, final String pagename) {
         boolean isUL = false;
-        HashSet<String> localLinkSet = new HashSet<>();  // needed to skip multiple
+        final HashSet< String > localLinkSet = new HashSet<>();  // needed to skip multiple
         // links to the same page
-        localLinkSet.add(pagename);
+        localLinkSet.add( pagename );
 
-        ArrayList<String> allLinks = new ArrayList<>();
+        final ArrayList< String > allLinks = new ArrayList<>();
 
         if( links != null )
             allLinks.addAll( links );
 
         if( m_formatSort ) context.getEngine().getPageManager().getPageSorter().sort( allLinks );
 
-        for( Iterator<String> i = allLinks.iterator(); i.hasNext(); ) {
-            String link = i.next() ;
-
-            if( localLinkSet.contains( link ) ) continue; // skip multiple links to the same page
+        for( final String link : allLinks ) {
+            if( localLinkSet.contains( link ) ) {
+                continue; // skip multiple links to the same page
+            }
             localLinkSet.add( link );
 
-            if( !m_engine.pageExists( link ) ) continue; // hide links to non existing pages
-
-            if(  m_matcher.matches( link , m_excludePattern ) ) continue;
-            if( !m_matcher.matches( link , m_includePattern ) ) continue;
+            if( !m_engine.getPageManager().wikiPageExists( link ) ) {
+                continue; // hide links to non existing pages
+            }
+            if(  m_matcher.matches( link , m_excludePattern ) ) {
+                continue;
+            }
+            if( !m_matcher.matches( link , m_includePattern ) ) {
+                continue;
+            }
 
             if( m_exists.contains( link ) ) {
                 if( !m_formatCompact ) {
@@ -223,12 +231,9 @@ public class ReferredPagesPlugin implements WikiPlugin {
                     }
 
                     //See https://www.w3.org/wiki/HTML_lists  for proper nesting of UL and LI
-                    m_result.append("<li> " + TextUtil.replaceEntities(link) + "\n");
-
+                    m_result.append( "<li> " + TextUtil.replaceEntities(link) + "\n" );
                     getReferredPages( context, link, depth );  // added recursive call - on general request
-
-                    m_result.append("\n</li>\n");
-
+                    m_result.append( "\n</li>\n" );
                 }
             } else {
                 if( !isUL ) {
@@ -236,16 +241,11 @@ public class ReferredPagesPlugin implements WikiPlugin {
                     m_result.append("<ul>\n");
                 }
 
-                String href = context.getURL(WikiContext.VIEW,link);
-                m_result.append("<li><a class=\"wikipage\" href=\""+ href + "\">"
-                                + TextUtil.replaceEntities(link) + "</a>\n" );
-
+                final String href = context.getURL( WikiContext.VIEW, link );
+                m_result.append( "<li><a class=\"wikipage\" href=\"" + href + "\">" + TextUtil.replaceEntities(link) + "</a>\n" );
                 m_exists.add( link );
-
                 getReferredPages( context, link, depth );
-
-                m_result.append("\n</li>\n");
-
+                m_result.append( "\n</li>\n" );
             }
         }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
index 63e3cd8..cb719e3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
@@ -404,7 +404,7 @@ public class WeblogPlugin
 
         if( author != null )
         {
-            if( engine.pageExists(author) )
+            if( engine.getPageManager().wikiPageExists(author) )
             {
                 author = "<a href=\""+entryCtx.getURL( WikiContext.VIEW, author )+"\">"+engine.beautifyTitle(author)+"</a>";
             }
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 8d867cb..803484f 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
@@ -468,7 +468,7 @@ public class DefaultReferenceManager extends BasicPageFilter implements Referenc
 
                 // We won't put it back again if it becomes empty and does not exist.  It will be added
                 // later on anyway, if it becomes referenced again.
-                if( !( refBy.isEmpty() && !m_engine.pageExists( referredPageName ) ) ) {
+                if( !( refBy.isEmpty() && !m_engine.getPageManager().wikiPageExists( referredPageName ) ) ) {
                     m_referredBy.put( referredPageName, refBy );
                 }
             }
@@ -604,7 +604,7 @@ public class DefaultReferenceManager extends BasicPageFilter implements Referenc
 
             // If the page is referred to by no one AND it doesn't even exist, we might just as well forget about this
             // entry. It will be added again elsewhere if new references appear.
-            if( ( oldRefBy == null || oldRefBy.isEmpty() ) && !m_engine.pageExists( referredPage ) ) {
+            if( ( oldRefBy == null || oldRefBy.isEmpty() ) && !m_engine.getPageManager().wikiPageExists( referredPage ) ) {
                 m_referredBy.remove( referredPage );
             }
         }
@@ -728,7 +728,7 @@ public class DefaultReferenceManager extends BasicPageFilter implements Referenc
         for( final Collection<String> refs : allReferences ) {
             if( refs != null ) {
                 for( final String aReference : refs ) {
-                    if( !m_engine.pageExists( aReference ) ) {
+                    if( !m_engine.getPageManager().wikiPageExists( aReference ) ) {
                         uncreated.add( aReference );
                     }
                 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/AttachmentsIteratorTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/AttachmentsIteratorTag.java
index f3e301c..232e4ca 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/AttachmentsIteratorTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/AttachmentsIteratorTag.java
@@ -18,12 +18,6 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-import java.util.List;
-
-import javax.servlet.jsp.JspWriter;
-import javax.servlet.jsp.PageContext;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -32,6 +26,12 @@ import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.attachment.AttachmentManager;
 
+import javax.servlet.jsp.JspWriter;
+import javax.servlet.jsp.PageContext;
+import java.io.IOException;
+import java.util.List;
+
+
 /**
  *  Iterates through the list of attachments one has.
  *
@@ -42,27 +42,21 @@ import org.apache.wiki.attachment.AttachmentManager;
  *
  *  @since 2.0
  */
-
 // FIXME: Too much in common with IteratorTag - REFACTOR
-public class AttachmentsIteratorTag
-    extends IteratorTag
-{
+public class AttachmentsIteratorTag extends IteratorTag {
     private static final long serialVersionUID = 0L;
     
-    static    Logger    log = Logger.getLogger( AttachmentsIteratorTag.class );
+    private static final Logger log = Logger.getLogger( AttachmentsIteratorTag.class );
 
     /**
      *  {@inheritDoc}
      */
     @Override
-    public final int doStartTag()
-    {
-        m_wikiContext = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT,
-                                                                PageContext.REQUEST_SCOPE );
-
-        WikiEngine        engine = m_wikiContext.getEngine();
-        AttachmentManager mgr    = engine.getAttachmentManager();
-        WikiPage          page;
+    public final int doStartTag()  {
+        m_wikiContext = (WikiContext) pageContext.getAttribute( WikiTagBase.ATTR_CONTEXT, PageContext.REQUEST_SCOPE );
+        final WikiEngine engine = m_wikiContext.getEngine();
+        final AttachmentManager mgr = engine.getAttachmentManager();
+        final WikiPage page;
 
         page = m_wikiContext.getPage();
 
@@ -71,14 +65,11 @@ public class AttachmentsIteratorTag
             return SKIP_BODY;
         }
 
-        try
-        {
-            if( page != null && engine.pageExists(page) )
-            {
-                List< Attachment > atts = mgr.listAttachments( page );
+        try {
+            if( page != null && engine.getPageManager().wikiPageExists(page) ) {
+                final List< Attachment > atts = mgr.listAttachments( page );
 
-                if( atts == null )
-                {
+                if( atts == null ) {
                     log.debug("No attachments to display.");
                     // There are no attachments included
                     return SKIP_BODY;
@@ -86,32 +77,21 @@ public class AttachmentsIteratorTag
 
                 m_iterator = atts.iterator();
 
-                if( m_iterator.hasNext() )
-                {
-                    Attachment  att = (Attachment) m_iterator.next();
-
-                    WikiContext context = (WikiContext)m_wikiContext.clone();
+                if( m_iterator.hasNext() ) {
+                    final Attachment  att = (Attachment) m_iterator.next();
+                    final WikiContext context = (WikiContext)m_wikiContext.clone();
                     context.setPage( att );
-                    pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
-                                              context,
-                                              PageContext.REQUEST_SCOPE );
-
+                    pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT, context, PageContext.REQUEST_SCOPE );
                     pageContext.setAttribute( getId(), att );
-                }
-                else
-                {
+                } else {
                     return SKIP_BODY;
                 }
-            }
-            else
-            {
+            } else {
                 return SKIP_BODY;
             }
 
             return EVAL_BODY_BUFFERED;
-        }
-        catch( ProviderException e )
-        {
+        } catch( final ProviderException e ) {
             log.fatal("Provider failed while trying to iterator through history",e);
             // FIXME: THrow something.
         }
@@ -123,33 +103,23 @@ public class AttachmentsIteratorTag
      *  {@inheritDoc}
      */
     @Override
-    public final int doAfterBody()
-    {
-        if( bodyContent != null )
-        {
-            try
-            {
-                JspWriter out = getPreviousOut();
+    public final int doAfterBody() {
+        if( bodyContent != null ) {
+            try {
+                final JspWriter out = getPreviousOut();
                 out.print(bodyContent.getString());
                 bodyContent.clearBody();
-            }
-            catch( IOException e )
-            {
+            } catch( final IOException e ) {
                 log.error("Unable to get inner tag text", e);
                 // FIXME: throw something?
             }
         }
 
-        if( m_iterator != null && m_iterator.hasNext() )
-        {
-            Attachment att = (Attachment) m_iterator.next();
-
-            WikiContext context = (WikiContext)m_wikiContext.clone();
+        if( m_iterator != null && m_iterator.hasNext() ) {
+            final Attachment att = ( Attachment )m_iterator.next();
+            final WikiContext context = ( WikiContext )m_wikiContext.clone();
             context.setPage( att );
-            pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,
-                                      context,
-                                      PageContext.REQUEST_SCOPE );
-
+            pageContext.setAttribute( WikiTagBase.ATTR_CONTEXT,  context, PageContext.REQUEST_SCOPE );
             pageContext.setAttribute( getId(), att );
 
             return EVAL_BODY_BUFFERED;
@@ -157,4 +127,5 @@ public class AttachmentsIteratorTag
 
         return SKIP_BODY;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/AuthorTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/AuthorTag.java
index 444d187..caac8e3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/AuthorTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/AuthorTag.java
@@ -18,8 +18,6 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.i18n.InternationalizationManager;
@@ -29,21 +27,19 @@ import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.util.TextUtil;
 
+import java.io.IOException;
+
 /**
- *  Writes the author name of the current page, including a link to that page,
- *  if that page exists.
+ *  Writes the author name of the current page, including a link to that page, if that page exists.
  *
  *  @since 2.0
  */
-public class AuthorTag
-    extends WikiTagBase
-{
+public class AuthorTag extends WikiTagBase {
     private static final long serialVersionUID = 0L;
 
-
     public String m_format = "";
 
-    public void setFormat( String format )
+    public void setFormat( final String format )
     {
         m_format = format;  //empty or "plain"
     }
@@ -52,40 +48,29 @@ public class AuthorTag
      *  {@inheritDoc}
      */
     @Override
-    public final int doWikiStartTag()
-        throws IOException
-    {
-        WikiEngine engine = m_wikiContext.getEngine();
-        WikiPage   page   = m_wikiContext.getPage();
-
+    public final int doWikiStartTag() throws IOException {
+        final WikiEngine engine = m_wikiContext.getEngine();
+        final WikiPage   page   = m_wikiContext.getPage();
         String author = page.getAuthor();
 
-        if( author != null && author.length() > 0 )
-        {
+        if( author != null && author.length() > 0 ) {
             author = TextUtil.replaceEntities(author);
 
-            if( engine.pageExists(author) && !( "plain".equalsIgnoreCase( m_format ) ) )
-            {
-                // FIXME: It's very boring to have to do this.
-                //        Slow, too.
-
-                RenderingManager mgr = engine.getRenderingManager();
-
-                MarkupParser p = mgr.getParser( m_wikiContext, "["+author+"|"+author+"]" );
-
-                WikiDocument d = p.parse();
-
+            if( engine.getPageManager().wikiPageExists(author) && !( "plain".equalsIgnoreCase( m_format ) ) ) {
+                // FIXME: It's very boring to have to do this.  Slow, too.
+                final RenderingManager mgr = engine.getRenderingManager();
+                final MarkupParser p = mgr.getParser( m_wikiContext, "["+author+"|"+author+"]" );
+                final WikiDocument d = p.parse();
                 author = mgr.getHTML( m_wikiContext, d );
             }
 
             pageContext.getOut().print( author );
-        }
-        else
-        {
+        } else {
             pageContext.getOut().print( Preferences.getBundle( m_wikiContext, InternationalizationManager.CORE_BUNDLE )
                                                    .getString( "common.unknownauthor" ) );
         }
 
         return SKIP_BODY;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/BreadcrumbsTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/BreadcrumbsTag.java
index dcdd7d8..0ffa258 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/BreadcrumbsTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/BreadcrumbsTag.java
@@ -18,14 +18,12 @@
  */
 package org.apache.wiki.tags;
 
+import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.util.TextUtil;
 
 import javax.servlet.http.HttpSession;
 import javax.servlet.jsp.JspWriter;
-
-import org.apache.log4j.Logger;
-
 import java.io.IOException;
 import java.io.Serializable;
 import java.util.LinkedList;
@@ -124,7 +122,7 @@ public class BreadcrumbsTag extends WikiTagBase
         } else {
             //  check if page still exists (could be deleted/renamed by another user)
             for (int i = 0;i<trail.size();i++) {
-                if (!m_wikiContext.getEngine().pageExists(trail.get(i))) {
+                if (!m_wikiContext.getEngine().getPageManager().wikiPageExists(trail.get(i))) {
                     trail.remove(i);
                 }
             }
@@ -132,7 +130,7 @@ public class BreadcrumbsTag extends WikiTagBase
 
         if (m_wikiContext.getRequestContext().equals(WikiContext.VIEW))
         {
-            if (m_wikiContext.getEngine().pageExists(page))
+            if (m_wikiContext.getEngine().getPageManager().wikiPageExists(page))
             {
                 if (trail.isEmpty())
                 {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/CalendarTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/CalendarTag.java
index f8f19ae..cbfd2f0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/CalendarTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/CalendarTag.java
@@ -144,7 +144,7 @@ public class CalendarTag extends WikiTagBase {
         if( m_pageFormat != null ) {
             final String pagename = m_pageFormat.format( day.getTime() );
             
-            if( engine.pageExists( pagename ) ) {
+            if( engine.getPageManager().wikiPageExists( pagename ) ) {
                 if( m_urlFormat != null ) {
                     final String url = m_urlFormat.format( day.getTime() );
                     result = "<td class=\"link\"><a href=\""+url+"\">"+day.get( Calendar.DATE )+"</a></td>";
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/CheckVersionTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/CheckVersionTag.java
index 2e170c1..c51bf6f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/CheckVersionTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/CheckVersionTag.java
@@ -21,9 +21,6 @@ package org.apache.wiki.tags;
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
-import org.apache.wiki.api.exceptions.ProviderException;
-
-import java.io.IOException;
 
 /**
  *  Does a version check on the page.  Mode is as follows:
@@ -37,13 +34,11 @@ import java.io.IOException;
  *
  *  @since 2.0
  */
-public class CheckVersionTag
-    extends WikiTagBase
-{
+public class CheckVersionTag extends WikiTagBase {
+
     private static final long serialVersionUID = 0L;
     
-    private static enum VersionMode
-    {
+    private enum VersionMode {
         LATEST, NOTLATEST, FIRST, NOTFIRST
     }
 
@@ -53,8 +48,7 @@ public class CheckVersionTag
      * {@inheritDoc}
      */
     @Override
-    public void initTag()
-    {
+    public void initTag() {
         super.initTag();
         m_mode = VersionMode.LATEST;
     }
@@ -64,22 +58,14 @@ public class CheckVersionTag
      *  
      *  @param arg The mode to set.
      */
-    public void setMode( String arg )
-    {
-        if( "latest".equals(arg) )
-        {
+    public void setMode( final String arg ) {
+        if( "latest".equals(arg) ) {
             m_mode = VersionMode.LATEST;
-        }
-        else if( "notfirst".equals(arg) )
-        {
+        } else if( "notfirst".equals(arg) ) {
             m_mode = VersionMode.NOTFIRST;
-        }
-        else if( "first".equals(arg) )
-        {
+        } else if( "first".equals(arg) ) {
             m_mode = VersionMode.FIRST;
-        }
-        else
-        {
+        } else {
             m_mode = VersionMode.NOTLATEST;
         }
     }
@@ -88,52 +74,28 @@ public class CheckVersionTag
      *  {@inheritDoc}
      */
     @Override
-    public final int doWikiStartTag()
-        throws IOException,
-               ProviderException
-    {
-        WikiEngine engine = m_wikiContext.getEngine();
-        WikiPage   page   = m_wikiContext.getPage();
-
-        if( page != null && engine.pageExists(page.getName()) )
-        {
-            int version = page.getVersion();
-            boolean include = false;
-
-            WikiPage latest = engine.getPageManager().getPage( page.getName() );
-
-            //log.debug("Doing version check: this="+page.getVersion()+
-            //          ", latest="+latest.getVersion());
-
-            switch( m_mode )
-            {
-                case LATEST:
-                    include = (version < 0) || (latest.getVersion() == version);
-                    break;
-
-                case NOTLATEST:
-                    include = (version > 0) && (latest.getVersion() != version);
-                    break;
-
-                case FIRST:
-                    include = (version == 1 ) || (version < 0 && latest.getVersion() == 1);
-                    break;
-
-                case NOTFIRST:
-                    include = version > 1;
-                    break;
-                
-                default:
-                    throw new InternalWikiException("Mode which is not available!");
+    public final int doWikiStartTag() {
+        final WikiEngine engine = m_wikiContext.getEngine();
+        final WikiPage   page   = m_wikiContext.getPage();
+
+        if( page != null && engine.getPageManager().wikiPageExists(page.getName()) ) {
+            final int version = page.getVersion();
+            final boolean include;
+            final WikiPage latest = engine.getPageManager().getPage( page.getName() );
+
+            switch( m_mode ) {
+                case LATEST    : include = (version < 0) || (latest.getVersion() == version); break;
+                case NOTLATEST : include = (version > 0) && (latest.getVersion() != version); break;
+                case FIRST     : include = (version == 1 ) || (version < 0 && latest.getVersion() == 1); break;
+                case NOTFIRST  : include = version > 1; break;
+                default: throw new InternalWikiException("Mode which is not available!");
             }
 
-            if( include )
-            {
-                // log.debug("INCLD");
+            if( include ) {
                 return EVAL_BODY_INCLUDE;
             }
         }
-
         return SKIP_BODY;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/DiffLinkTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/DiffLinkTag.java
index 3e9a827..d660c46 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/DiffLinkTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/DiffLinkTag.java
@@ -97,7 +97,7 @@ public class DiffLinkTag extends WikiLinkTag {
         int r2;
 
         //  In case the page does not exist, we fail silently.
-        if( !engine.pageExists( pageName ) ) {
+        if( !engine.getPageManager().wikiPageExists( pageName ) ) {
             return SKIP_BODY;
         }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/HasAttachmentsTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/HasAttachmentsTag.java
index 3b27a3f..0192b7d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/HasAttachmentsTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/HasAttachmentsTag.java
@@ -18,8 +18,6 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
@@ -37,29 +35,23 @@ public class HasAttachmentsTag extends WikiTagBase {
     private static final long serialVersionUID = 0L;
     private static final Logger log = Logger.getLogger( HasAttachmentsTag.class );
     
-    public final int doWikiStartTag()
-        throws IOException
-    {
-        WikiEngine engine = m_wikiContext.getEngine();
-        WikiPage   page   = m_wikiContext.getPage();
-        AttachmentManager mgr = engine.getAttachmentManager();
-
-        try
-        {
-            if( page != null && engine.pageExists(page) && mgr.attachmentsEnabled() )
-            {
-                if( mgr.hasAttachments(page) )
-                {
+    public final int doWikiStartTag() {
+        final WikiEngine engine = m_wikiContext.getEngine();
+        final WikiPage page = m_wikiContext.getPage();
+        final AttachmentManager mgr = engine.getAttachmentManager();
+
+        try {
+            if( page != null && engine.getPageManager().wikiPageExists(page) && mgr.attachmentsEnabled() ) {
+                if( mgr.hasAttachments(page) ) {
                     return EVAL_BODY_INCLUDE;
                 }
             }
-        }
-        catch( ProviderException e )
-        {
+        } catch( final ProviderException e ) {
             log.fatal("Provider failed while trying to check for attachements",e);
             // FIXME: THrow something.
         }
 
         return SKIP_BODY;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/HistoryIteratorTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/HistoryIteratorTag.java
index 694b4a5..5134cfa 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/HistoryIteratorTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/HistoryIteratorTag.java
@@ -52,7 +52,7 @@ public class HistoryIteratorTag extends IteratorTag  {
         final WikiPage page = m_wikiContext.getPage();
 
         try {
-            if( page != null && engine.pageExists( page ) ) {
+            if( page != null && engine.getPageManager().wikiPageExists( page ) ) {
                 final List< WikiPage > versions = engine.getPageManager().getVersionHistory( page.getName() );
 
                 if( versions == null ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java
index e7f62d5..2f547b6 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/InsertPageTag.java
@@ -94,7 +94,7 @@ public class InsertPageTag extends WikiTagBase {
 
         if( m_pageName == null ) {
             insertedPage = m_wikiContext.getPage();
-            if( !engine.pageExists(insertedPage) ) return SKIP_BODY;
+            if( !engine.getPageManager().wikiPageExists(insertedPage) ) return SKIP_BODY;
         } else {
             insertedPage = engine.getPageManager().getPage( m_pageName );
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/NoSuchPageTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/NoSuchPageTag.java
index 8fca495..40bfdb0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/NoSuchPageTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/NoSuchPageTag.java
@@ -60,7 +60,7 @@ public class NoSuchPageTag extends WikiTagBase {
             page = engine.getPageManager().getPage( m_pageName );
         }
 
-        if( page != null && engine.pageExists( page.getName(), page.getVersion() ) ) {
+        if( page != null && engine.getPageManager().wikiPageExists( page.getName(), page.getVersion() ) ) {
             return SKIP_BODY;
         }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/PageInfoLinkTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/PageInfoLinkTag.java
index 6de2e22..bcc170b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/PageInfoLinkTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/PageInfoLinkTag.java
@@ -18,13 +18,13 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-import javax.servlet.jsp.JspWriter;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 
+import javax.servlet.jsp.JspWriter;
+import java.io.IOException;
+
 /**
  *  Writes a link to the Wiki PageInfo.  Body of the link becomes the actual text.
  *
@@ -38,63 +38,46 @@ import org.apache.wiki.WikiPage;
  *  @since 2.0
  */
 // FIXME: Refactor together with LinkToTag and EditLinkTag.
-public class PageInfoLinkTag
-    extends WikiLinkTag
-{
+public class PageInfoLinkTag extends WikiLinkTag {
+
     private static final long serialVersionUID = 0L;
     public String m_title = "";
     public String m_accesskey = "";
     
-    public void setTitle( String title )
+    public void setTitle( final String title )
     {
         m_title = title;
     }
 
-    public void setAccesskey( String access )
+    public void setAccesskey( final String access )
     {
         m_accesskey = access;
     }
     
-    public final int doWikiStartTag()
-        throws IOException
-    {
-        WikiEngine engine = m_wikiContext.getEngine();
+    public final int doWikiStartTag() throws IOException {
+        final WikiEngine engine = m_wikiContext.getEngine();
         String     pageName = m_pageName;
 
-        if( m_pageName == null )
-        {
-            WikiPage p = m_wikiContext.getPage();
-
-            if( p != null )
-            {
+        if( m_pageName == null ) {
+            final WikiPage p = m_wikiContext.getPage();
+            if( p != null ) {
                 pageName = p.getName();
-            }
-            else
-            {
+            } else {
                 return SKIP_BODY;
             }
         }
 
-        if( engine.pageExists(pageName) )
-        {
-            JspWriter out = pageContext.getOut();
-
-            String url = m_wikiContext.getURL( WikiContext.INFO, pageName );
+        if( engine.getPageManager().wikiPageExists(pageName) ) {
+            final JspWriter out = pageContext.getOut();
+            final String url = m_wikiContext.getURL( WikiContext.INFO, pageName );
 
-            switch( m_format )
-            {
-              case ANCHOR:
-                out.print("<a class=\"pageinfo\" href=\""+url+"\" accesskey=\"" 
-                          + m_accesskey + "\" title=\"" + m_title + "\">");
-                break;
-              case URL:
-                out.print( url );
-                break;
+            switch( m_format ) {
+              case ANCHOR: out.print("<a class=\"pageinfo\" href=\""+url+"\" accesskey=\"" + m_accesskey + "\" title=\"" + m_title + "\">"); break;
+              case URL: out.print( url ); break;
             }
-
             return EVAL_BODY_INCLUDE;
         }
-
         return SKIP_BODY;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/PageSizeTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/PageSizeTag.java
index 617a7ad..0e5764f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/PageSizeTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/PageSizeTag.java
@@ -43,7 +43,7 @@ public class PageSizeTag extends WikiTagBase {
             if( page != null ) {
                 long size = page.getSize();
 
-                if( size == -1 && engine.pageExists(page) ) { // should never happen with attachments
+                if( size == -1 && engine.getPageManager().wikiPageExists( page ) ) { // should never happen with attachments
                     size = engine.getPageManager().getPureText( page.getName(), page.getVersion() ).length();
                     page.setSize( size );
                 }
@@ -57,4 +57,5 @@ public class PageSizeTag extends WikiTagBase {
 
         return SKIP_BODY;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/WikiTagBase.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/WikiTagBase.java
index a078059..8d2b0be 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/WikiTagBase.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/WikiTagBase.java
@@ -18,78 +18,59 @@
  */
 package org.apache.wiki.tags;
 
+import org.apache.log4j.Logger;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.util.TextUtil;
+
 import javax.servlet.jsp.JspException;
 import javax.servlet.jsp.PageContext;
 import javax.servlet.jsp.tagext.TagSupport;
 import javax.servlet.jsp.tagext.TryCatchFinally;
 
-import org.apache.log4j.Logger;
-
-import org.apache.wiki.WikiContext;
-import org.apache.wiki.util.TextUtil;
 
 /**
- *  Base class for JSPWiki tags.  You do not necessarily have
- *  to derive from this class, since this does some initialization.
+ *  Base class for JSPWiki tags.  You do not necessarily have to derive from this class, since this does some initialization.
  *  <P>
- *  This tag is only useful if you're having an "empty" tag, with
- *  no body content.
+ *  This tag is only useful if you're having an "empty" tag, with no body content.
  *
  *  @since 2.0
  */
-public abstract class WikiTagBase
-    extends TagSupport
-    implements TryCatchFinally
-{
+public abstract class WikiTagBase extends TagSupport implements TryCatchFinally {
+
     private static final long serialVersionUID = -1409836349293777141L;
+    private static final Logger log = Logger.getLogger( WikiTagBase.class );
 
     public static final String ATTR_CONTEXT = "jspwiki.context";
 
-    private static final Logger log = Logger.getLogger( WikiTagBase.class );
-
     protected WikiContext m_wikiContext;
 
     /**
-     *   This method calls the parent setPageContext() but it also
-     *   provides a way for a tag to initialize itself before
-     *   any of the setXXX() methods are called.
+     * This method calls the parent setPageContext() but it also provides a way for a tag to initialize itself before
+     * any of the setXXX() methods are called.
      */
-    public void setPageContext(PageContext arg0)
-    {
-        super.setPageContext(arg0);
-        
+    public void setPageContext( final PageContext arg0 ) {
+        super.setPageContext( arg0 );
         initTag();
     }
 
     /**
-     *  This method is called when the tag is encountered within a new request,
-     *  but before the setXXX() methods are called. 
+     *  This method is called when the tag is encountered within a new request, but before the setXXX() methods are called.
      *  The default implementation does nothing.
      *  @since 2.3.92
      */
-    public void initTag()
-    {
+    public void initTag() {
         m_wikiContext = null;
-        return;
     }
     
-    public int doStartTag()
-        throws JspException
-    {
-        try
-        {
-            m_wikiContext = (WikiContext) pageContext.getAttribute( ATTR_CONTEXT,
-                                                                    PageContext.REQUEST_SCOPE );
-
-            if( m_wikiContext == null )
-            {
+    public int doStartTag() throws JspException {
+        try {
+            m_wikiContext = ( WikiContext )pageContext.getAttribute( ATTR_CONTEXT, PageContext.REQUEST_SCOPE );
+            if( m_wikiContext == null ) {
                 throw new JspException("WikiContext may not be NULL - serious internal problem!");
             }
 
             return doWikiStartTag();
-        }
-        catch( Exception e )
-        {
+        } catch( final Exception e ) {
             log.error( "Tag failed", e );
             throw new JspException( "Tag failed, check logs: "+e.getMessage() );
         }
@@ -101,14 +82,11 @@ public abstract class WikiTagBase
      */
     public abstract int doWikiStartTag() throws Exception;
 
-    public int doEndTag()
-        throws JspException
-    {
+    public int doEndTag() throws JspException {
         return EVAL_PAGE;
     }
 
-    public void doCatch( Throwable th ) throws Throwable
-    {
+    public void doCatch( final Throwable th ) throws Throwable {
     	log.error( th.getMessage(), th );
     }
 
@@ -117,7 +95,7 @@ public abstract class WikiTagBase
         m_wikiContext = null;
     }
 
-    public void setId(String id)
+    public void setId( final String id)
     {
         super.setId( TextUtil.replaceEntities( id ) );
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tasks/TasksManager.java b/jspwiki-main/src/main/java/org/apache/wiki/tasks/TasksManager.java
index 70ab717..f2a7b61 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tasks/TasksManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tasks/TasksManager.java
@@ -18,19 +18,18 @@
  */
 package org.apache.wiki.tasks;
 
-import java.security.Principal;
-import java.util.Locale;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.workflow.Step;
-import org.apache.wiki.workflow.Task;
+
+import java.security.Principal;
+import java.util.Locale;
 
 /**
  * Manager responsible of creation of the different JSPWiki {@link Step}s.
  * 
  * Instances of classes generated by this TasksManager are assumed to have been added to an approval workflow via 
- * {@link org.apache.wiki.workflow.WorkflowBuilder#buildApprovalWorkflow(Principal, String, Task, String, org.apache.wiki.workflow.Fact[], Task, String)};
+ * {@link org.apache.wiki.workflow.WorkflowBuilder#buildApprovalWorkflow(Principal, String, Step, String, org.apache.wiki.workflow.Fact[], Step, String)};
  * they will not function correctly otherwise.
  */
 public interface TasksManager {
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 3ab3355..b197d1d 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
@@ -34,7 +34,6 @@ import java.util.Calendar;
 import java.util.Collection;
 import java.util.Date;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.Set;
 import java.util.Vector;
 
@@ -43,21 +42,10 @@ import java.util.Vector;
  *
  *  @since 1.6.6
  */
-// We could use WikiEngine directly, but because of introspection it would
-// show just too many methods to be safe.
-public class RPCHandler
-    extends AbstractRPCHandler
-{
-    private static Logger log = Logger.getLogger( RPCHandler.class );
+// We could use WikiEngine directly, but because of introspection it would show just too many methods to be safe.
+public class RPCHandler extends AbstractRPCHandler {
 
-    /**
-     *  {@inheritDoc}
-     */
-    @Override
-    public void initialize( WikiContext ctx )
-    {
-        super.initialize( ctx );
-    }
+    private static final Logger log = Logger.getLogger( RPCHandler.class );
 
     /**
      *  Converts Java string into RPC string.
@@ -83,23 +71,19 @@ public class RPCHandler
         return src.getBytes( StandardCharsets.UTF_8 );
     }
 
-    public String getApplicationName()
-    {
+    public String getApplicationName() {
         checkPermission( PagePermission.VIEW );
         return toRPCString(m_engine.getApplicationName());
     }
 
-    public Vector getAllPages()
-    {
+    public Vector getAllPages() {
         checkPermission( PagePermission.VIEW );
         Collection< WikiPage > pages = m_engine.getPageManager().getRecentChanges();
         Vector<String> result = new Vector<>();
 
-        for( WikiPage p : pages )
-        {
-            if( !(p instanceof Attachment) )
-            {
-                result.add( toRPCString(p.getName()) );
+        for( final WikiPage p : pages ) {
+            if( !( p instanceof Attachment ) ) {
+                result.add( toRPCString( p.getName() ) );
             }
         }
 
@@ -181,7 +165,7 @@ public class RPCHandler
     {
         pagename = fromRPCString( pagename );
 
-        if( !m_engine.pageExists(pagename) )
+        if( !m_engine.getPageManager().wikiPageExists(pagename) )
         {
             throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );
         }
@@ -229,17 +213,13 @@ public class RPCHandler
         return toRPCBase64( m_engine.getHTML( pagename ) );
     }
 
-    public byte[] getPageHTMLVersion( String pagename, int version )
-        throws XmlRpcException
-    {
+    public byte[] getPageHTMLVersion( String pagename, int version ) throws XmlRpcException {
         pagename = parsePageCheckCondition( pagename );
 
         return toRPCBase64( m_engine.getHTML( pagename, version ) );
     }
 
-    public Vector listLinks( String pagename )
-        throws XmlRpcException
-    {
+    public Vector listLinks( String pagename ) throws XmlRpcException {
         pagename = parsePageCheckCondition( pagename );
 
         WikiPage page = m_engine.getPageManager().getPage( pagename );
@@ -252,21 +232,15 @@ public class RPCHandler
         WikiContext context = new WikiContext( m_engine, page );
         context.setVariable( WikiEngine.PROP_REFSTYLE, "absolute" );
 
-        m_engine.textToHTML( context,
-                             pagedata,
-                             localCollector,
-                             extCollector,
-                             attCollector );
+        m_engine.textToHTML( context, pagedata, localCollector, extCollector, attCollector );
 
         Vector<Hashtable<String, String>> result = new Vector<>();
 
         //
         //  Add local links.
         //
-        for( Iterator< String > i = localCollector.getLinks().iterator(); i.hasNext(); )
-        {
-            String link = i.next();
-            Hashtable< String, String > ht = new Hashtable<>();
+        for( final String link : localCollector.getLinks() ) {
+            Hashtable<String, String> ht = new Hashtable<>();
             ht.put( "page", toRPCString( link ) );
             ht.put( "type", LINK_LOCAL );
 
@@ -277,17 +251,13 @@ public class RPCHandler
             //
 
             //
-            //  FIXME: The current link collector interface is not very good, since
-            //  it causes this.
+            //  FIXME: The current link collector interface is not very good, since it causes this.
             //
 
-            if( m_engine.pageExists(link) )
-            {
-                ht.put( "href", context.getURL(WikiContext.VIEW,link) );
-            }
-            else
-            {
-                ht.put( "href", context.getURL(WikiContext.EDIT,link) );
+            if( m_engine.getPageManager().wikiPageExists( link ) ) {
+                ht.put( "href", context.getURL( WikiContext.VIEW, link ) );
+            } else {
+                ht.put( "href", context.getURL( WikiContext.EDIT, link ) );
             }
 
             result.add( ht );
@@ -296,37 +266,26 @@ public class RPCHandler
         //
         // Add links to inline attachments
         //
-        for( Iterator< String > i = attCollector.getLinks().iterator(); i.hasNext(); )
-        {
-            String link = i.next();
-
-            Hashtable< String, String > ht = new Hashtable< >();
-
+        for( String link : attCollector.getLinks() ) {
+            Hashtable<String, String> ht = new Hashtable<>();
             ht.put( "page", toRPCString( link ) );
             ht.put( "type", LINK_LOCAL );
             ht.put( "href", context.getURL( WikiContext.ATTACH, link ) );
-
             result.add( ht );
         }
 
         //
-        // External links don't need to be changed into XML-RPC strings,
-        // simply because URLs are by definition ASCII.
+        // External links don't need to be changed into XML-RPC strings, simply because URLs are by definition ASCII.
         //
-
-        for( Iterator< String > i = extCollector.getLinks().iterator(); i.hasNext(); )
-        {
-            String link = i.next();
-
-            Hashtable< String, String > ht = new Hashtable< >();
-
+        for( String link : extCollector.getLinks() ) {
+            Hashtable<String, String> ht = new Hashtable<>();
             ht.put( "page", link );
             ht.put( "type", LINK_EXTERNAL );
             ht.put( "href", link );
-
             result.add( ht );
         }
 
         return result;
     }
+
 }
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 0390aff..b5a5c0f 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
@@ -126,7 +126,7 @@ public class RPCHandlerUTF8 extends AbstractRPCHandler {
      *  @throws XmlRpcException, if there is something wrong with the page.
      */
     private String parsePageCheckCondition( final String pagename ) throws XmlRpcException {
-        if( !m_engine.pageExists(pagename) ) {
+        if( !m_engine.getPageManager().wikiPageExists(pagename) ) {
             throw new XmlRpcException( ERR_NOPAGE, "No such page '"+pagename+"' found, o master." );
         }
 
@@ -189,7 +189,7 @@ public class RPCHandlerUTF8 extends AbstractRPCHandler {
             ht.put( "page", link );
             ht.put( "type", LINK_LOCAL );
 
-            if( m_engine.pageExists( link ) ) {
+            if( m_engine.getPageManager().wikiPageExists( link ) ) {
                 ht.put( "href", context.getViewURL( link ) );
             } else {
                 ht.put( "href", context.getURL( WikiContext.EDIT, link ) );
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 6ecffce..d2718b0 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -25,7 +25,6 @@ import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.providers.FileSystemProvider;
 import org.apache.wiki.references.ReferenceManager;
-import org.apache.wiki.util.TextUtil;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
@@ -76,23 +75,6 @@ public class WikiEngineTest {
         f.delete();
     }
 
-    /**
-     *  Check that calling pageExists( String ) works.
-     */
-    @Test
-    public void testNonExistentPage() {
-        Assertions.assertFalse( m_engine.pageExists( NAME1 ), "Page already exists" );
-    }
-
-    /**
-     *  Check that calling pageExists( WikiPage ) works.
-     */
-    @Test
-    public void testNonExistentPage2() throws Exception {
-        final WikiPage page = new WikiPage(m_engine, NAME1 );
-        Assertions.assertFalse( m_engine.pageExists( page ), "Page already exists" );
-    }
-
     @Test
     public void testFinalPageName() throws Exception {
         m_engine.saveText( "Foobar", "1" );
@@ -370,8 +352,8 @@ public class WikiEngineTest {
         final WikiContext ctx = new WikiContext( m_engine, m_engine.getPageManager().getPage("OldNameTestPage") );
         m_engine.getPageRenamer().renamePage( ctx, "OldNameTestPage", "NewNameTestPage", true );
 
-        Assertions.assertFalse( m_engine.pageExists( "OldNameTestPage"), "did not vanish" );
-        Assertions.assertTrue( m_engine.pageExists( "NewNameTestPage"), "did not appear" );
+        Assertions.assertFalse( m_engine.getPageManager().wikiPageExists( "OldNameTestPage"), "did not vanish" );
+        Assertions.assertTrue( m_engine.getPageManager().wikiPageExists( "NewNameTestPage"), "did not appear" );
 
         pages = m_engine.getReferenceManager().findReferrers( "RenameBugTestPage" );
         Assertions.assertEquals( 1, pages.size(),  "wrong # of referrers" );
@@ -396,24 +378,4 @@ public class WikiEngineTest {
         Assertions.assertNull( p3.getAttribute( WikiPage.CHANGENOTE ) );
     }
 
-    @Test
-    public void testCreatePage() throws Exception {
-        final String text = "Foobar.\r\n";
-        final String name = "mrmyxpltz";
-        Assertions.assertFalse( m_engine.pageExists( name ), "page should not exist right now" );
-
-        m_engine.saveText( name, text );
-        Assertions.assertTrue( m_engine.pageExists( name ), "page does not exist" );
-    }
-
-    @Test
-    public void testCreateEmptyPage() throws Exception {
-        final String text = "";
-        final String name = "mrmxyzptlk";
-        Assertions.assertFalse( m_engine.pageExists( name ), "page should not exist right now" );
-
-        m_engine.saveText( name, text );
-        Assertions.assertFalse( m_engine.pageExists( name ), "page should not exist right now neither" );
-    }
-
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
index 8128b47..46a5ece 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
@@ -289,7 +289,7 @@ public class AttachmentManagerTest
 
         m_manager.storeAttachment( att, makeAttachmentFile() );
 
-        Assertions.assertTrue( m_engine.pageExists( NAME1+"/test1" ), "attachment disappeared" );
+        Assertions.assertTrue( m_engine.getPageManager().wikiPageExists( NAME1+"/test1" ), "attachment disappeared" );
     }
 
     @Test
@@ -301,7 +301,7 @@ public class AttachmentManagerTest
 
         m_manager.storeAttachment( att, makeAttachmentFile() );
 
-        Assertions.assertTrue( m_engine.pageExists( att.getName() ), "attachment disappeared" );
+        Assertions.assertTrue( m_engine.getPageManager().wikiPageExists( att.getName() ), "attachment disappeared" );
     }
 
     @Test
@@ -313,7 +313,7 @@ public class AttachmentManagerTest
 
         m_manager.storeAttachment( att, makeAttachmentFile() );
 
-        Assertions.assertTrue( m_engine.pageExists( NAME1+"/test file.bin" ), "attachment disappeared" );
+        Assertions.assertTrue( m_engine.getPageManager().wikiPageExists( NAME1+"/test file.bin" ), "attachment disappeared" );
     }
 
     @Test
@@ -325,7 +325,7 @@ public class AttachmentManagerTest
 
         m_manager.storeAttachment( att, makeAttachmentFile() );
 
-        Assertions.assertTrue( m_engine.pageExists( att.getName() ), "attachment disappeared" );
+        Assertions.assertTrue( m_engine.getPageManager().wikiPageExists( att.getName() ), "attachment disappeared" );
     }
 
     @Test
@@ -337,7 +337,7 @@ public class AttachmentManagerTest
 
         m_manager.storeAttachment( att, makeAttachmentFile() );
 
-        Assertions.assertTrue( m_engine.pageExists( att.getName() ), "attachment disappeared" );
+        Assertions.assertTrue( m_engine.getPageManager().wikiPageExists( att.getName() ), "attachment disappeared" );
     }
 
     @Test
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
index 6d934e4..1897db6 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
@@ -57,6 +57,23 @@ public class DefaultPageManagerTest {
         CacheManager.getInstance().removeAllCaches();
     }
 
+    /**
+     *  Check that calling pageExists( String ) works.
+     */
+    @Test
+    public void testNonExistentPage() {
+        Assertions.assertFalse( engine.getPageManager().wikiPageExists( NAME1 ), "Page already exists" );
+    }
+
+    /**
+     *  Check that calling pageExists( WikiPage ) works.
+     */
+    @Test
+    public void testNonExistentPage2() throws Exception {
+        final WikiPage page = new WikiPage( engine, NAME1 );
+        Assertions.assertFalse( engine.getPageManager().wikiPageExists( page ), "Page already exists" );
+    }
+
     @Test
     public void testPageCacheExists() throws Exception {
         engine.getWikiProperties().setProperty( "jspwiki.usePageCache", "true" );
@@ -231,12 +248,32 @@ public class DefaultPageManagerTest {
     }
 
     @Test
+    public void testCreatePage() throws Exception {
+        final String text = "Foobar.\r\n";
+        final String name = "mrmyxpltz";
+        Assertions.assertFalse( engine.getPageManager().wikiPageExists( name ), "page should not exist right now" );
+
+        engine.saveText( name, text );
+        Assertions.assertTrue( engine.getPageManager().wikiPageExists( name ), "page does not exist" );
+    }
+
+    @Test
+    public void testCreateEmptyPage() throws Exception {
+        final String text = "";
+        final String name = "mrmxyzptlk";
+        Assertions.assertFalse( engine.getPageManager().wikiPageExists( name ), "page should not exist right now" );
+
+        engine.saveText( name, text );
+        Assertions.assertFalse( engine.getPageManager().wikiPageExists( name ), "page should not exist right now neither" );
+    }
+
+    @Test
     public void testPutPage() throws Exception {
         final String text = "Foobar.\r\n";
         final String name = NAME1;
         engine.saveText( name, text );
 
-        Assertions.assertTrue( engine.pageExists( name ), "page does not exist" );
+        Assertions.assertTrue( engine.getPageManager().wikiPageExists( name ), "page does not exist" );
         Assertions.assertEquals( text, engine.getPageManager().getText( name ), "wrong content" );
     }
 
@@ -246,7 +283,7 @@ public class DefaultPageManagerTest {
         final String name = NAME1;
         engine.saveText( name, text );
 
-        Assertions.assertTrue( engine.pageExists( name ), "page does not exist" );
+        Assertions.assertTrue( engine.getPageManager().wikiPageExists( name ), "page does not exist" );
         Assertions.assertEquals( "Foobar. &amp;quot;\r\n", engine.getPageManager().getText( name ), "wrong content" );
     }
 
@@ -259,7 +296,7 @@ public class DefaultPageManagerTest {
         final String name = NAME1;
         engine.saveText( name, text );
 
-        Assertions.assertTrue( engine.pageExists( name ), "page does not exist" );
+        Assertions.assertTrue( engine.getPageManager().wikiPageExists( name ), "page does not exist" );
         Assertions.assertEquals( "Foobar. &quot;\r\n", engine.getPageManager().getText( name ), "wrong content" );
     }
 
@@ -269,7 +306,7 @@ public class DefaultPageManagerTest {
         final String name = NAME1;
         engine.saveText( name, text );
 
-        Assertions.assertTrue( engine.pageExists( name ), "page does not exist" );
+        Assertions.assertTrue( engine.getPageManager().wikiPageExists( name ), "page does not exist" );
         // saveText uses normalizePostData to assure it conforms to certain rules
         Assertions.assertEquals( TextUtil.normalizePostData( text ), engine.getPageManager().getText( name ), "wrong content" );
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
index 5e03505..a149a57 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
@@ -194,7 +194,7 @@ public class ApprovalWorkflowTest {
         }
 
         // How do we know the workflow works? Well, first of all the page shouldn't exist yet...
-        Assertions.assertFalse( m_engine.pageExists(pageName));
+        Assertions.assertFalse( m_engine.getPageManager().wikiPageExists(pageName));
 
         // Second, GroupPrincipal Admin should see a Decision in its queue
         Collection< Decision > decisions = m_dq.getActorDecisions( m_engine.adminSession() );
@@ -203,7 +203,7 @@ public class ApprovalWorkflowTest {
         // Now, approve the decision and it should go away, and page should appear.
         Decision decision = (Decision)decisions.iterator().next();
         decision.decide(Outcome.DECISION_APPROVE);
-        Assertions.assertTrue( m_engine.pageExists(pageName));
+        Assertions.assertTrue( m_engine.getPageManager().wikiPageExists(pageName));
         decisions = m_dq.getActorDecisions( m_engine.adminSession() );
         Assertions.assertEquals(0, decisions.size());
 
@@ -227,7 +227,7 @@ public class ApprovalWorkflowTest {
         }
 
         // How do we know the workflow works? Well, first of all the page shouldn't exist yet...
-        Assertions.assertFalse( m_engine.pageExists(pageName));
+        Assertions.assertFalse( m_engine.getPageManager().wikiPageExists(pageName));
 
         // ...and there should be a Decision in GroupPrincipal Admin's queue
         Collection< Decision > decisions = m_dq.getActorDecisions( m_engine.adminSession() );
@@ -236,7 +236,7 @@ public class ApprovalWorkflowTest {
         // Now, DENY the decision and the page should still not exist...
         Decision decision = (Decision)decisions.iterator().next();
         decision.decide(Outcome.DECISION_DENY);
-        Assertions.assertFalse( m_engine.pageExists(pageName) );
+        Assertions.assertFalse( m_engine.getPageManager().wikiPageExists(pageName) );
 
         // ...but there should also be a notification decision in Janne's queue
         decisions = m_dq.getActorDecisions( m_engine.janneSession() );
diff --git a/jspwiki-war/src/main/webapp/Login.jsp b/jspwiki-war/src/main/webapp/Login.jsp
index 8d44a3a..35d0ec2 100644
--- a/jspwiki-war/src/main/webapp/Login.jsp
+++ b/jspwiki-war/src/main/webapp/Login.jsp
@@ -179,8 +179,7 @@
 
         // If wiki page was "Login", redirect to main, otherwise use the page supplied
         String redirectPage = request.getParameter( "redirect" );
-        if( !wiki.pageExists( redirectPage ) )
-        {
+        if( !wiki.getPageManager().wikiPageExists( redirectPage ) ) {
            redirectPage = wiki.getFrontPage();
         }
         String viewUrl = ( "Login".equals( redirectPage ) ) ? "Wiki.jsp" : wiki.getViewURL( redirectPage );
diff --git a/jspwiki-war/src/main/webapp/UserPreferences.jsp b/jspwiki-war/src/main/webapp/UserPreferences.jsp
index 700d0b0..7f58ded 100644
--- a/jspwiki-war/src/main/webapp/UserPreferences.jsp
+++ b/jspwiki-war/src/main/webapp/UserPreferences.jsp
@@ -97,7 +97,7 @@
         {
             String redirectPage = request.getParameter( "redirect" );
 
-            if( !wiki.pageExists( redirectPage ) )
+            if( !wiki.getPageManager().wikiPageExists( redirectPage ) )
             {
                redirectPage = wiki.getFrontPage();
             }
@@ -116,7 +116,7 @@
         CookieAssertionLoginModule.setUserCookie( response, assertedName );
 
         String redirectPage = request.getParameter( "redirect" );
-        if( !wiki.pageExists( redirectPage ) )
+        if( !wiki.getPageManager().wikiPageExists( redirectPage ) )
         {
           redirectPage = wiki.getFrontPage();
         }
diff --git a/jspwiki-war/src/main/webapp/rss.jsp b/jspwiki-war/src/main/webapp/rss.jsp
index 95f1570..0adb70c 100644
--- a/jspwiki-war/src/main/webapp/rss.jsp
+++ b/jspwiki-war/src/main/webapp/rss.jsp
@@ -61,7 +61,7 @@
         return;
     }
 
-    if( wikipage == null || !wiki.pageExists(wikipage.getName()) )
+    if( wikipage == null || !wiki.getPageManager().wikiPageExists(wikipage.getName()) )
     {
         response.sendError( 404, "No such page "+wikipage.getName() );
         return;


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

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 c9bc3c74ca42bd0def073e01821c91bbd5dfae8a
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 9 23:16:28 2020 +0100

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

diff --git a/ChangeLog.md b/ChangeLog.md
index 7f4dc83..681d7c7 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -17,6 +17,31 @@ specific language governing permissions and limitations
 under the License.
 -->
 
+**2020-01-09  Juan Pablo Santos (juanpablo AT apache DOT org)**
+
+* _2.11.0-M7-git-04_
+
+* [JSPWIKI-120](https://issues.apache.org/jira/browse/JSPWIKI-120): Separate rendering engine from core - following methods moved from 
+`WikiEngine` to `PageManager`
+    * `deletePage(..)` and `deleteVersion(..)` methods 
+    * `getPage(..)`
+    * `pageExist(..)` methods, renamed as `wikiPageExist(..)`
+    * `saveText()`
+    * `getText(..)` methods
+    * `getPureText( String, int )`
+    * `getRecentChanges()`
+    * `getVersionHistory()`
+    * `getCurrentProvider()` 
+    * `getCurrentProviderInfo()` and `getPageCount` were deleted - use instead existing `getProviderDescription()` and `getTotalPageCount` 
+    methods from `PageManager`
+* `WorkflowManager` renamed as `org.apache.wiki.workflow.DefaultWorkflowManager`, with new 
+ `org.apache.wiki.workflow.WorkflowManager` extracted as interface of the latter
+* Explicit casting from `WikiEngine#getAttribute()` and ` WikiPage#getAttribute()` no longer needed in most cases now
+* `TestEngine` now includes test class and method where it was created next to the timestamp, which is useful when you have tons of 
+timestamped dirs and want to know which folder was generated by what test
+  * Also, if no folder is given for work, pages and attachment dirs, it tries to place them under `./target/`
+* Applied format & fixes suggested by intellij to another bunch of files
+
 **2020-01-03  Juan Pablo Santos (juanpablo AT apache DOT org)**
 
 * _2.11.0-M7-git-03_
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 1a295a3..dde8024 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/Release.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
@@ -72,7 +72,7 @@ public final class Release {
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "git-03";
+    public static final String     BUILD         = "git-04";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of


[jspwiki] 05/32: apply formats 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 1630b750f3dc0b721d98208e8c7a70cc5a23a3dc
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 21:16:31 2020 +0100

    apply formats and fixes suggested by IntelliJ
---
 .../main/java/org/apache/wiki/pages/PageLock.java  | 19 ++++-------
 .../java/org/apache/wiki/pages/PageManager.java    | 26 +++++++--------
 .../java/org/apache/wiki/pages/PageSorter.java     | 37 ++++++++++------------
 .../org/apache/wiki/pages/PageTimeComparator.java  |  6 ++--
 4 files changed, 39 insertions(+), 49 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageLock.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageLock.java
index ea93112..fcbc3a2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageLock.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageLock.java
@@ -18,11 +18,11 @@
  */
 package org.apache.wiki.pages;
 
+import org.apache.wiki.WikiPage;
+
 import java.io.Serializable;
 import java.util.Date;
 
-import org.apache.wiki.WikiPage;
-
 /**
  *  Describes a lock acquired by an user on a page.  For the most part,
  *  the regular developer does not have to instantiate this class.
@@ -49,11 +49,7 @@ public class PageLock
      *  @param acquired The timestamp when the lock is acquired
      *  @param expiry   The timestamp when the lock expires.
      */
-    public PageLock( WikiPage page, 
-                     String locker,
-                     Date acquired,
-                     Date expiry )
-    {
+    public PageLock( final WikiPage page, final String locker, final Date acquired, final Date expiry ) {
         m_page         = page.getName();
         m_locker       = locker;
         m_lockAcquired = (Date)acquired.clone();
@@ -106,15 +102,14 @@ public class PageLock
      *  
      *  @return Time left in minutes.
      */
-    public long getTimeLeft()
-    {
-        long time = m_lockExpiry.getTime() - new Date().getTime();
+    public long getTimeLeft() {
+        final long time = m_lockExpiry.getTime() - new Date().getTime();
 
-        return (time / (1000L * 60)) + 1;
+        return ( time / ( 1000L * 60 ) ) + 1;
     }
     
     public boolean isExpired() {
-        Date now = new Date();
+        final Date now = new Date();
         return now.after( getExpiryTime() );
     }
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index a78abca..dbdf1db 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -53,7 +53,7 @@ public interface PageManager extends WikiEventListener {
      * @return A Collection of WikiPage objects.
      * @throws ProviderException If the backend has problems.
      */
-    Collection<WikiPage> getAllPages() throws ProviderException;
+    Collection< WikiPage > getAllPages() throws ProviderException;
 
     /**
      * Fetches the page text from the repository.  This method also does some sanity checks,
@@ -65,7 +65,7 @@ public interface PageManager extends WikiEventListener {
      * @return The page content as a raw string
      * @throws ProviderException If the backend has issues.
      */
-    String getPageText(String pageName, int version) throws ProviderException;
+    String getPageText( String pageName, int version ) throws ProviderException;
 
     /**
      * Returns the WikiEngine to which this PageManager belongs to.
@@ -82,7 +82,7 @@ public interface PageManager extends WikiEventListener {
      * @param content Wikimarkup to save
      * @throws ProviderException If something goes wrong in the saving phase
      */
-    void putPageText(WikiPage page, String content) throws ProviderException;
+    void putPageText( WikiPage page, String content ) throws ProviderException;
 
     /**
      * Locks page for editing.  Note, however, that the PageManager will in no way prevent you from actually editing this page;
@@ -92,14 +92,14 @@ public interface PageManager extends WikiEventListener {
      * @param user Username to use for locking
      * @return null, if page could not be locked.
      */
-    PageLock lockPage(WikiPage page, String user);
+    PageLock lockPage( WikiPage page, String user );
 
     /**
      * Marks a page free to be written again.  If there has not been a lock, will fail quietly.
      *
      * @param lock A lock acquired in lockPage().  Safe to be null.
      */
-    void unlockPage(PageLock lock);
+    void unlockPage( PageLock lock );
 
     /**
      * Returns the current lock owner of a page.  If the page is not locked, will return null.
@@ -107,7 +107,7 @@ public interface PageManager extends WikiEventListener {
      * @param page The page to check the lock for
      * @return Current lock, or null, if there is no lock
      */
-    PageLock getCurrentLock(WikiPage page);
+    PageLock getCurrentLock( WikiPage page );
 
     /**
      * Returns a list of currently applicable locks.  Note that by the time you get the list,
@@ -126,7 +126,7 @@ public interface PageManager extends WikiEventListener {
      * @return A WikiPage object, or null, if the page does not exist
      * @throws ProviderException If there is something wrong with the page name or the repository
      */
-    WikiPage getPageInfo(String pageName, int version) throws ProviderException;
+    WikiPage getPageInfo( String pageName, int version ) throws ProviderException;
 
     /**
      * Gets a version history of page.  Each element in the returned List is a WikiPage.
@@ -135,7 +135,7 @@ public interface PageManager extends WikiEventListener {
      * @return If the page does not exist, returns null, otherwise a List of WikiPages.
      * @throws ProviderException If the repository fails.
      */
-    List<WikiPage> getVersionHistory(String pageName) throws ProviderException;
+    List<WikiPage> getVersionHistory( String pageName ) throws ProviderException;
 
     /**
      *  Returns the provider name.
@@ -168,7 +168,7 @@ public interface PageManager extends WikiEventListener {
      * @return A boolean value describing the existence of a page
      * @throws ProviderException If the backend fails or the name is illegal.
      */
-    boolean pageExists(String pageName) throws ProviderException;
+    boolean pageExists( String pageName ) throws ProviderException;
 
     /**
      * Checks for existence of a specific page and version.
@@ -179,7 +179,7 @@ public interface PageManager extends WikiEventListener {
      * @throws ProviderException If backend fails or name is illegal
      * @since 2.3.29
      */
-    boolean pageExists(String pageName, int version) throws ProviderException;
+    boolean pageExists( String pageName, int version ) throws ProviderException;
 
     /**
      * Deletes only a specific version of a WikiPage.
@@ -187,7 +187,7 @@ public interface PageManager extends WikiEventListener {
      * @param page The page to delete.
      * @throws ProviderException if the page fails
      */
-    void deleteVersion(WikiPage page) throws ProviderException;
+    void deleteVersion( WikiPage page ) throws ProviderException;
 
     /**
      *  Deletes a page or an attachment completely, including all versions.  If the page does not exist, does nothing.
@@ -195,7 +195,7 @@ public interface PageManager extends WikiEventListener {
      * @param pageName The name of the page.
      * @throws ProviderException If something goes wrong.
      */
-    void deletePage( final String pageName ) throws ProviderException;
+    void deletePage( String pageName ) throws ProviderException;
 
     /**
      * Deletes an entire page, all versions, all traces.
@@ -203,7 +203,7 @@ public interface PageManager extends WikiEventListener {
      * @param page The WikiPage to delete
      * @throws ProviderException If the repository operation fails
      */
-    void deletePage(WikiPage page) throws ProviderException;
+    void deletePage( WikiPage page ) throws ProviderException;
 
     /**
      * Listens for {@link org.apache.wiki.event.WikiSecurityEvent#PROFILE_NAME_CHANGED}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java
index 7e470bb..42df456 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java
@@ -19,16 +19,15 @@
 
 package org.apache.wiki.pages;
 
+import org.apache.log4j.Logger;
+import org.apache.wiki.util.ClassUtil;
+import org.apache.wiki.util.comparators.JavaNaturalComparator;
+
 import java.util.Arrays;
-import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
 import java.util.Properties;
 
-import org.apache.log4j.Logger;
-import org.apache.wiki.util.ClassUtil;
-import org.apache.wiki.util.comparators.JavaNaturalComparator;
-
 /**
  * Wrapper class for managing and using the PageNameComparator.
  * <p>
@@ -53,7 +52,7 @@ public class PageSorter implements Comparator< String > {
      * 
      * @param comparator the Comparator to use
      */
-    public PageSorter( Comparator<String> comparator ) {
+    public PageSorter( final Comparator<String> comparator ) {
         m_comparator = comparator;
     }
 
@@ -66,16 +65,16 @@ public class PageSorter implements Comparator< String > {
      * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
      */
     @Override
-    public int compare( String pageName1, String pageName2 ) {
+    public int compare( final String pageName1, final String pageName2 ) {
         return m_comparator.compare( pageName1, pageName2 );
     }
 
     @Override
-    public boolean equals( Object o ) {
-        if( !(o instanceof PageSorter) ) {
+    public boolean equals( final Object o ) {
+        if( !( o instanceof PageSorter ) ) {
             return false; // Definitely not equal
         }
-        PageSorter that = (PageSorter) o;
+        final PageSorter that = ( PageSorter )o;
         if( this == that || m_comparator == that.m_comparator ) {
             return true; // Essentially the same object
         }
@@ -91,28 +90,26 @@ public class PageSorter implements Comparator< String > {
      * @param props this WikiEngine's properties.
      */
     @SuppressWarnings( "unchecked" )
-    public void initialize( Properties props ) {
+    public void initialize( final Properties props ) {
         // Default is Java natural order
         m_comparator = JavaNaturalComparator.DEFAULT_JAVA_COMPARATOR;
-        String className = props.getProperty( PROP_PAGE_NAME_COMPARATOR );
+        final String className = props.getProperty( PROP_PAGE_NAME_COMPARATOR );
         if( className != null && className.length() > 0 ) {
             try {
-                m_comparator = (Comparator<String>) ClassUtil.findClass( "org.apache.wiki.util.comparators", className ).newInstance();
-            } catch( Exception e ) {
+                m_comparator = ( Comparator< String > )ClassUtil.findClass( "org.apache.wiki.util.comparators", className ).newInstance();
+            } catch( final Exception e ) {
                 LOG.error( "Falling back to default \"natural\" comparator", e );
             }
         }
     }
 
     /**
-     * Sorts the specified list into ascending order based on the
-     * PageNameComparator. The actual sort is done using
-     * <code>Collections.sort()</code>.
+     * Sorts the specified list into ascending order based on the PageNameComparator. The actual sort is done using {@code List.sort()}.
      * 
      * @param nameList the page names to be sorted
      */
-    public void sort( List< String > nameList ) {
-        Collections.sort( nameList, m_comparator );
+    public void sort( final List< String > nameList ) {
+        nameList.sort( m_comparator );
     }
 
     /**
@@ -122,7 +119,7 @@ public class PageSorter implements Comparator< String > {
      * 
      * @param nameArray the page names to be sorted
      */
-    public void sort( String[] nameArray ) {
+    public void sort( final String[] nameArray ) {
         Arrays.sort( nameArray, m_comparator );
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageTimeComparator.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageTimeComparator.java
index b410bb0..dee1925 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageTimeComparator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageTimeComparator.java
@@ -26,11 +26,9 @@ import java.util.Comparator;
 import java.util.Date;
 
 /**
- *  Compares the lastModified date of its arguments.  Both o1 and o2 MUST
- *  be WikiPage objects, or else you will receive a ClassCastException.
+ *  Compares the lastModified date of its arguments.  Both o1 and o2 MUST be WikiPage objects, or else you will receive a ClassCastException.
  *  <p>
- *  If the lastModified date is the same, then the next key is the page name.
- *  If the page name is also equal, then returns 0 for equality.
+ *  If the lastModified date is the same, then the next key is the page name. If the page name is also equal, then returns 0 for equality.
  */
 public class PageTimeComparator implements Comparator< WikiPage >, Serializable {
 	


[jspwiki] 21/32: fix JSP compilation error

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 7a5fbbddf2a63447eab13b429557a07ae07dab59
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Jan 6 23:57:34 2020 +0100

    fix JSP compilation error
---
 jspwiki-war/src/main/webapp/templates/default/Nav.jsp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jspwiki-war/src/main/webapp/templates/default/Nav.jsp b/jspwiki-war/src/main/webapp/templates/default/Nav.jsp
index 0bf0f36..a064b13 100644
--- a/jspwiki-war/src/main/webapp/templates/default/Nav.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/Nav.jsp
@@ -31,7 +31,7 @@
 <%
   WikiContext c = WikiContext.findContext( pageContext );
 
-  String text = c.getEngine().getPageManager().getText(c, c.getPage());
+  String text = c.getEngine().getPageManager().getText( c.getPage() );
   StringTokenizer tokens = new StringTokenizer( text );
   //avg reading speeds: https://iovs.arvojournals.org/article.aspx?articleid=2166061