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/03 09:03:09 UTC

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

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 528d825  2.11.0-M7-git-02
     new 0b57c00  code format and fixes suggested by IntelliJ
     new 7c9958c  static final logger on WikiVariableManager
     new b6c92b7  fix javadocs
     new c5ef842  intellij format + fixes
     new 1a01c81  JSPWIKI-120: scanWikiLinks(..) and updateReferences(..) methods from WikiEngine moved to ReferenceManager
     new f682550  p can't be null here, as an NPE would've raised on the call to m_engine.getReferenceManager().updateReferences( p );
     new fa2b64d  * Dependency updates
     new e0a20c1  update portable launchers to tomcat 8.5.50
     new ab8d3d4  JSPWIKI-120: move ReferenceManager to its own package, as DefaultReferenceManager; extract there new ReferenceManager interface from it
     new 757ee2b  use ReferenceManager from org.apache.wiki.references
     new 93ecf13  add some missing package.html files
     new d858bd8  Renamed WikiVariableManager to DefaultVariableManager and moved it, along with VariableManager, to their own package under org.apache.wiki.variables
     new a26f8ef  renamed WikiDifferenceManager to DefaultDifferenceManager
     new d35a181  setUp method not really needed on DefaultFilterManagerTest
     new fa2ab40  renamed WikiPageRenamer to DefaultPageRenamer
     new fbd8517  use VariableManager from its new package
     new 8f63318  remove unneeded cast + apply format & fixes from intellij
     new 9e05cc5  2.11.0-M7-git-03

The 18 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                                       |   19 +
 .../java/org/apache/wiki/ReferenceManager.java     | 1122 --------------------
 .../src/main/java/org/apache/wiki/Release.java     |    2 +-
 .../java/org/apache/wiki/WikiBackgroundThread.java |   22 +-
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  210 ++--
 .../apache/wiki/attachment/AttachmentManager.java  |   60 +-
 ...ikiPageRenamer.java => DefaultPageRenamer.java} |   10 +-
 ...eManager.java => DefaultDifferenceManager.java} |    6 +-
 .../apache/wiki/filters/DefaultFilterManager.java  |   33 +-
 .../org/apache/wiki/pages/DefaultPageManager.java  |   69 +-
 .../org/apache/wiki/plugin/PageViewPlugin.java     |    2 +-
 .../apache/wiki/plugin/ReferredPagesPlugin.java    |   14 +-
 .../apache/wiki/plugin/ReferringPagesPlugin.java   |   21 +-
 .../wiki/plugin/ReferringUndefinedPagesPlugin.java |   14 +-
 .../apache/wiki/plugin/UndefinedPagesPlugin.java   |   42 +-
 .../org/apache/wiki/plugin/UnusedPagesPlugin.java  |   10 +-
 .../wiki/references/DefaultReferenceManager.java   |  890 ++++++++++++++++
 .../apache/wiki/references/ReferenceManager.java   |  171 +++
 .../java/org/apache/wiki/references}/package.html  |    4 +-
 .../org/apache/wiki/render/CreoleRenderer.java     |  122 +--
 .../wiki/render/CustomXMLOutputProcessor.java      |    6 +-
 .../org/apache/wiki/render/RenderingManager.java   |  152 ++-
 .../java/org/apache/wiki/render/WikiRenderer.java  |   19 +-
 .../apache/wiki/render/WysiwygEditingRenderer.java |  111 +-
 .../java/org/apache/wiki/render/XHTMLRenderer.java |   34 +-
 .../main/java/org/apache/wiki/render}/package.html |    4 +-
 .../java/org/apache/wiki/rpc/atom}/package.html    |    4 +-
 .../main/java/org/apache/wiki/rss}/package.html    |    4 +-
 .../DefaultVariableManager.java}                   |   13 +-
 .../wiki/{ => variables}/VariableManager.java      |    3 +-
 .../src/main/resources/ini/classmappings.xml       |   20 +-
 .../test/java/org/apache/wiki/WikiEngineTest.java  |   13 +-
 .../wiki/filters/DefaultFilterManagerTest.java     |   20 +-
 .../{ => references}/ReferenceManagerTest.java     |  226 ++--
 .../DefaultVariableManagerTest.java}               |   11 +-
 .../tomcat/woas.app/Contents/Java/bootstrap.jar    |  Bin 35165 -> 35203 bytes
 .../tomcat/woas.app/Contents/Java/tomcat-juli.jar  |  Bin 49901 -> 49903 bytes
 .../src/overlay/launchers/tomcat/woas.exe          |  Bin 3475006 -> 3493354 bytes
 jspwiki-war/src/main/webapp/Comment.jsp            |    1 +
 jspwiki-war/src/main/webapp/UserPreferences.jsp    |    2 +-
 pom.xml                                            |    8 +-
 41 files changed, 1577 insertions(+), 1917 deletions(-)
 delete mode 100644 jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java
 rename jspwiki-main/src/main/java/org/apache/wiki/content/{WikiPageRenamer.java => DefaultPageRenamer.java} (97%)
 rename jspwiki-main/src/main/java/org/apache/wiki/diff/{WikiDifferenceManager.java => DefaultDifferenceManager.java} (95%)
 create mode 100644 jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java
 create mode 100644 jspwiki-main/src/main/java/org/apache/wiki/references/ReferenceManager.java
 copy {jspwiki-it-tests/jspwiki-selenide-tests/src/main/java/org/apache/wiki/its => jspwiki-main/src/main/java/org/apache/wiki/references}/package.html (91%)
 copy {jspwiki-it-tests/jspwiki-selenide-tests/src/main/java/org/apache/wiki/its => jspwiki-main/src/main/java/org/apache/wiki/render}/package.html (92%)
 copy {jspwiki-it-tests/jspwiki-selenide-tests/src/main/java/org/apache/wiki/its => jspwiki-main/src/main/java/org/apache/wiki/rpc/atom}/package.html (92%)
 copy {jspwiki-it-tests/jspwiki-selenide-tests/src/main/java/org/apache/wiki/its => jspwiki-main/src/main/java/org/apache/wiki/rss}/package.html (92%)
 rename jspwiki-main/src/main/java/org/apache/wiki/{WikiVariableManager.java => variables/DefaultVariableManager.java} (97%)
 rename jspwiki-main/src/main/java/org/apache/wiki/{ => variables}/VariableManager.java (98%)
 rename jspwiki-main/src/test/java/org/apache/wiki/{ => references}/ReferenceManagerTest.java (68%)
 rename jspwiki-main/src/test/java/org/apache/wiki/{WikiVariableManagerTest.java => variables/DefaultVariableManagerTest.java} (92%)


[jspwiki] 03/18: fix javadocs

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 b6c92b7c65615a6b92f42c8e0b043ec537166eee
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 1 20:09:53 2020 +0100

    fix javadocs
---
 .../apache/wiki/filters/DefaultFilterManager.java  | 33 +++++++++++-----------
 1 file changed, 16 insertions(+), 17 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
index 64ad3a7..c6695a3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
@@ -64,28 +64,27 @@ import java.util.Properties;
  *  format is really very simple:
  *  <pre>
  *  <?xml version="1.0"?>
+ *  &lt;pagefilters>
  *
- *  <pagefilters>
+ *    &lt;filter>
+ *      &lt;class>org.apache.wiki.filters.ProfanityFilter&lt;/class>
+ *    &lt;filter>
  *
- *    <filter>
- *      <class>org.apache.wiki.filters.ProfanityFilter</class>
- *    </filter>
+ *    &lt;filter>
+ *      &lt;class>org.apache.wiki.filters.TestFilter&lt;/class>
  *
- *    <filter>
- *      <class>org.apache.wiki.filters.TestFilter</class>
+ *      &lt;param>
+ *        &lt;name>foobar&lt;/name>
+ *        &lt;value>Zippadippadai&lt;/value>
+ *      &lt;/param>
  *
- *      <param>
- *        <name>foobar</name>
- *        <value>Zippadippadai</value>
- *      </param>
+ *      &lt;param>
+ *        &lt;name>blatblaa&lt;/name>
+ *        &lt;value>5&lt;/value>
+ *      &lt;/param>
  *
- *      <param>
- *        <name>blatblaa</name>
- *        <value>5</value>
- *      </param>
- *
- *    </filter>
- *  </pagefilters>
+ *    &lt;/filter>
+ *  &lt;/pagefilters>
  *  </pre>
  *
  *  The &lt;filter> -sections define the filters.  For more information, please see


[jspwiki] 10/18: use ReferenceManager from org.apache.wiki.references

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 757ee2ba2102b8f80e8808f4ada62fb72abb27b8
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 2 16:39:22 2020 +0100

    use ReferenceManager from org.apache.wiki.references
---
 .../org/apache/wiki/plugin/PageViewPlugin.java     |  2 +-
 .../apache/wiki/plugin/ReferredPagesPlugin.java    | 14 ++++----
 .../apache/wiki/plugin/ReferringPagesPlugin.java   | 21 ++++++-----
 .../wiki/plugin/ReferringUndefinedPagesPlugin.java | 14 ++++----
 .../apache/wiki/plugin/UndefinedPagesPlugin.java   | 42 +++++++++-------------
 .../org/apache/wiki/plugin/UnusedPagesPlugin.java  | 10 +++---
 6 files changed, 47 insertions(+), 56 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/PageViewPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PageViewPlugin.java
index 6f27c41..266297a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/PageViewPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PageViewPlugin.java
@@ -27,7 +27,6 @@ import org.apache.oro.text.regex.Pattern;
 import org.apache.oro.text.regex.PatternCompiler;
 import org.apache.oro.text.regex.PatternMatcher;
 import org.apache.oro.text.regex.Perl5Matcher;
-import org.apache.wiki.ReferenceManager;
 import org.apache.wiki.WikiBackgroundThread;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -40,6 +39,7 @@ import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.event.WikiPageRenameEvent;
+import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.util.TextUtil;
 
 import java.io.File;
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 f950079..a586057 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
@@ -18,12 +18,6 @@
 */
 package org.apache.wiki.plugin;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-
 import org.apache.log4j.Logger;
 import org.apache.oro.text.regex.MalformedPatternException;
 import org.apache.oro.text.regex.Pattern;
@@ -31,14 +25,20 @@ import org.apache.oro.text.regex.PatternCompiler;
 import org.apache.oro.text.regex.PatternMatcher;
 import org.apache.oro.text.regex.Perl5Compiler;
 import org.apache.oro.text.regex.Perl5Matcher;
-import org.apache.wiki.ReferenceManager;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.WikiPlugin;
+import org.apache.wiki.references.ReferenceManager;
 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;
+
 
 /**
  *  Displays the pages referring to the current page.
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 c25e916..6d1bd72 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
@@ -18,20 +18,20 @@
  */
 package org.apache.wiki.plugin;
 
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Map;
-import java.util.ResourceBundle;
-
 import org.apache.log4j.Logger;
-import org.apache.wiki.ReferenceManager;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.preferences.Preferences;
+import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.util.TextUtil;
 
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Map;
+import java.util.ResourceBundle;
+
 /**
  *  Displays the pages referring to the current page.
  *
@@ -44,8 +44,7 @@ import org.apache.wiki.util.TextUtil;
  *
  *  From AbstractReferralPlugin:
  *  <ul>
- *  <li><b>separator</b> - How to separate generated links; default is a wikitext line break,
- *             producing a vertical list.</li>
+ *  <li><b>separator</b> - How to separate generated links; default is a wikitext line break, producing a vertical list.</li>
  *  <li><b>maxwidth</b> - maximum width, in chars, of generated links.</li>
  *  </ul>
  */
@@ -101,9 +100,9 @@ public class ReferringPagesPlugin
                 extras = rb.getString("referringpagesplugin.more");
             }
 
-            if( log.isDebugEnabled() )
-                log.debug( "Fetching referring pages for "+page.getName()+
-                           " with a max of "+items);
+            if( log.isDebugEnabled() ) {
+                log.debug( "Fetching referring pages for " + page.getName() + " with a max of "+items);
+            }
 
             if( links != null && links.size() > 0 )
             {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringUndefinedPagesPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringUndefinedPagesPlugin.java
index 6632424..93a7916 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringUndefinedPagesPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/ReferringUndefinedPagesPlugin.java
@@ -18,18 +18,18 @@
  */
 package org.apache.wiki.plugin;
 
-import java.text.MessageFormat;
-import java.util.Collection;
-import java.util.Map;
-import java.util.ResourceBundle;
-import java.util.TreeMap;
-
-import org.apache.wiki.ReferenceManager;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.WikiPlugin;
 import org.apache.wiki.preferences.Preferences;
+import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.util.TextUtil;
+
+import java.text.MessageFormat;
+import java.util.Collection;
+import java.util.Map;
+import java.util.ResourceBundle;
+import java.util.TreeMap;
 /**
  *  <p>Lists all pages containing links to Undefined Pages (pages containing dead links).</p>
  *
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java
index b94fa24..d760a20 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/UndefinedPagesPlugin.java
@@ -18,12 +18,13 @@
  */
 package org.apache.wiki.plugin;
 
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.exceptions.PluginException;
+import org.apache.wiki.references.ReferenceManager;
+
 import java.util.Collection;
 import java.util.Map;
 
-import org.apache.wiki.ReferenceManager;
-import org.apache.wiki.WikiContext;
-import org.apache.wiki.api.exceptions.PluginException;
 
 /**
  *  Plugin that enumerates the pages in the wiki that have not yet been defined.
@@ -33,40 +34,31 @@ import org.apache.wiki.api.exceptions.PluginException;
  *  <li><b>separator</b> - how to separate generated links; default is a wikitext line break,  producing a vertical list</li>
  * <li><b> maxwidth</b> - maximum width, in chars, of generated links.</li>
  * </ul>
- *
  */
-public class UndefinedPagesPlugin
-    extends AbstractReferralPlugin
-{
+public class UndefinedPagesPlugin extends AbstractReferralPlugin {
+
     /**
      *  {@inheritDoc}
      */
-    public String execute( WikiContext context, Map<String, String> params )
-        throws PluginException
-    {
-        ReferenceManager refmgr = context.getEngine().getReferenceManager();
-        Collection< String > links = refmgr.findUncreated();
-
+    public String execute( final WikiContext context, final Map< String, String > params ) throws PluginException {
+        final ReferenceManager refmgr = context.getEngine().getReferenceManager();
         super.initialize( context, params );
 
+        Collection< String > links = refmgr.findUncreated();
         links = filterAndSortCollection( links );
-        
-        String wikitext = null;
-        
-        if (m_lastModified)
-        {
-            throw new PluginException("parameter " + PARAM_LASTMODIFIED + " is not valid for the UndefinedPagesPlugin");
+
+        if( m_lastModified ) {
+            throw new PluginException( "parameter " + PARAM_LASTMODIFIED + " is not valid for the UndefinedPagesPlugin" );
         }
-        
-        if (m_show.equals(PARAM_SHOW_VALUE_COUNT))
-        {
+
+        final String wikitext;
+        if( m_show.equals( PARAM_SHOW_VALUE_COUNT ) ) {
             wikitext = "" + links.size();
-        }
-        else
-        {
+        } else {
             wikitext = wikitizeCollection( links, m_separator, ALL_ITEMS );
         }
         
         return makeHTML( context, wikitext );
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/UnusedPagesPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/UnusedPagesPlugin.java
index 47e797b..a979d8d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/UnusedPagesPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/UnusedPagesPlugin.java
@@ -18,15 +18,15 @@
  */
 package org.apache.wiki.plugin;
 
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.apache.wiki.ReferenceManager;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.PluginException;
+import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.util.TextUtil;
 
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Map;
+
 /**
  * Plugin for displaying pages that are not linked to in other pages.
  * Uses the ReferenceManager.


[jspwiki] 05/18: JSPWIKI-120: scanWikiLinks(..) and updateReferences(..) methods from WikiEngine moved to ReferenceManager

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 1a01c8153fd48630d5ca8c190524fde8a6464bad
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 1 21:02:50 2020 +0100

    JSPWIKI-120: scanWikiLinks(..) and updateReferences(..) methods from WikiEngine moved to ReferenceManager
---
 .../java/org/apache/wiki/ReferenceManager.java     |  35 +++-
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  48 +----
 .../apache/wiki/attachment/AttachmentManager.java  |  60 ++----
 .../org/apache/wiki/content/WikiPageRenamer.java   |   6 +-
 .../org/apache/wiki/pages/DefaultPageManager.java  |  35 +---
 .../java/org/apache/wiki/ReferenceManagerTest.java | 216 ++++++++-------------
 .../test/java/org/apache/wiki/WikiEngineTest.java  |  12 --
 7 files changed, 146 insertions(+), 266 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java
index cc46816..ea09f2d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java
@@ -160,7 +160,7 @@ public class ReferenceManager extends BasicPageFilter implements InternalModule,
      */
     private void updatePageReferences( final WikiPage page ) throws ProviderException {
         final String content = m_engine.getPageManager().getPageText( page.getName(), WikiPageProvider.LATEST_VERSION );
-        final Collection< String > links = m_engine.scanWikiLinks( page, content );
+        final Collection< String > links = scanWikiLinks( page, content );
         final TreeSet< String > res = new TreeSet<>( links );
         final List< Attachment > attachments = m_engine.getAttachmentManager().listAttachments( page );
         for( final Attachment att : attachments ) {
@@ -411,11 +411,32 @@ public class ReferenceManager extends BasicPageFilter implements InternalModule,
     @Override
 	public void postSave( final WikiContext context, final String content ) {
         final WikiPage page = context.getPage();
-        updateReferences( page.getName(), context.getEngine().scanWikiLinks( page, content ) );
+        updateReferences( page.getName(), scanWikiLinks( page, content ) );
         serializeAttrsToDisk( page );
     }
 
     /**
+     *  Reads a WikiPageful of data from a String and returns all links internal to this Wiki in a Collection.
+     *
+     *  @param page The WikiPage to scan
+     *  @param pagedata The page contents
+     *  @return a Collection of Strings
+     */
+    public Collection< String > scanWikiLinks( final WikiPage page, final String pagedata ) {
+        final LinkCollector localCollector = new LinkCollector();
+
+        m_engine.textToHTML( new WikiContext( m_engine, page ),
+                pagedata,
+                localCollector,
+                null,
+                localCollector,
+                false,
+                true );
+
+        return localCollector.getLinks();
+    }
+
+    /**
      * Updates the m_referedTo and m_referredBy hashmaps when a page has been deleted.
      * <P>
      * Within the m_refersTo map the pagename is a key. The whole key-value-set has to be removed to keep the map clean.
@@ -471,6 +492,16 @@ public class ReferenceManager extends BasicPageFilter implements InternalModule,
     }
 
     /**
+     *  Updates all references for the given page.
+     *
+     *  @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 );
+        updateReferences( page.getName(), scanWikiLinks( page, pageData ) );
+    }
+
+    /**
      *  Updates the referred pages of a new or edited WikiPage. If a refersTo entry for this page already exists, it is removed
      *  and a new one is built from scratch. Also calls updateReferredBy() for each referenced page.
      *  <P>
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 8d32d26..5d0a7d2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -1380,27 +1380,6 @@ public class WikiEngine  {
     }
 
     /**
-     *  Reads a WikiPageful of data from a String and returns all links internal to this Wiki in a Collection.
-     *
-     *  @param page The WikiPage to scan
-     *  @param pagedata The page contents
-     *  @return a Collection of Strings
-     */
-    public Collection< String > scanWikiLinks( final WikiPage page, final String pagedata ) {
-        final LinkCollector localCollector = new LinkCollector();
-
-        textToHTML( new WikiContext( this, page ),
-                    pagedata,
-                    localCollector,
-                    null,
-                    localCollector,
-                    false,
-                    true );
-
-        return localCollector.getLinks();
-    }
-
-    /**
      *  Just convert WikiText to HTML.
      *
      *  @param context The WikiContext in which to do the conversion
@@ -1448,13 +1427,13 @@ public class WikiEngine  {
      *  @param justParse Just parses the pagedata, does not actually render.  In this case, this methods an empty string.
      *  @return HTML-rendered page text.
      */
-    private String textToHTML( final WikiContext context,
-                               String pagedata,
-                               final StringTransmutator localLinkHook,
-                               final StringTransmutator extLinkHook,
-                               final StringTransmutator attLinkHook,
-                               final boolean            parseAccessRules,
-                               final boolean            justParse ) {
+    public String textToHTML( final WikiContext context,
+                              String pagedata,
+                              final StringTransmutator localLinkHook,
+                              final StringTransmutator extLinkHook,
+                              final StringTransmutator attLinkHook,
+                              final boolean            parseAccessRules,
+                              final boolean            justParse ) {
         String result = "";
 
         if( pagedata == null ) {
@@ -1507,19 +1486,6 @@ public class WikiEngine  {
         return result;
     }
 
-    /**
-     *  Updates all references for the given page.
-     *
-     *  @param page wiki page for which references should be updated
-     */
-    public void updateReferences( WikiPage page )
-    {
-        String pageData = getPureText( page.getName(), WikiProvider.LATEST_VERSION );
-
-        m_referenceManager.updateReferences( page.getName(),
-                                             scanWikiLinks( page, pageData ) );
-    }
-
 
     /**
      *  Writes the WikiText of a page into the page repository. If the <code>jspwiki.properties</code> file contains
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 32036c9..ab819ab 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
@@ -514,9 +514,8 @@ public class AttachmentManager
     }
 
     /**
-     *  Stores an attachment that lives in the given file.
-     *  If the attachment did not exist previously, this method
-     *  will create it.  If it did exist, it stores a new version.
+     *  Stores an attachment that lives in the given file. If the attachment did not exist previously, this method will create it.
+     *  If it did exist, it stores a new version.
      *
      *  @param att Attachment to store this under.
      *  @param source A file to read from.
@@ -524,27 +523,15 @@ public class AttachmentManager
      *  @throws IOException If writing the attachment failed.
      *  @throws ProviderException If something else went wrong.
      */
-    public void storeAttachment( Attachment att, File source )
-        throws IOException,
-               ProviderException
-    {
-        FileInputStream in = null;
-
-        try
-        {
-            in = new FileInputStream( source );
+    public void storeAttachment( final Attachment att, final File source ) throws IOException, ProviderException {
+        try( final FileInputStream in = new FileInputStream( source ) ) {
             storeAttachment( att, in );
         }
-        finally
-        {
-            if( in != null ) in.close();
-        }
     }
 
     /**
-     *  Stores an attachment directly from a stream.
-     *  If the attachment did not exist previously, this method
-     *  will create it.  If it did exist, it stores a new version.
+     *  Stores an attachment directly from a stream. If the attachment did not exist previously, this method will create it.
+     *  If it did exist, it stores a new version.
      *
      *  @param att Attachment to store this under.
      *  @param in  InputStream from which the attachment contents will be read.
@@ -552,32 +539,23 @@ public class AttachmentManager
      *  @throws IOException If writing the attachment failed.
      *  @throws ProviderException If something else went wrong.
      */
-    public void storeAttachment( Attachment att, InputStream in )
-        throws IOException,
-               ProviderException
-    {
-        if( m_provider == null )
-        {
+    public void storeAttachment( final Attachment att, final InputStream in ) throws IOException, ProviderException {
+        if( m_provider == null ) {
             return;
         }
 
-        //
         //  Checks if the actual, real page exists without any modifications
         //  or aliases.  We cannot store an attachment to a non-existent page.
-        //
-        if( !m_engine.getPageManager().pageExists( att.getParentName() ) )
-        {
+        if( !m_engine.getPageManager().pageExists( att.getParentName() ) ) {
             // the caller should catch the exception and use the exception text as an i18n key
-            throw new ProviderException(  "attach.parent.not.exist"  );
+            throw new ProviderException( "attach.parent.not.exist" );
         }
 
         m_provider.putAttachmentData( att, in );
+        m_engine.getReferenceManager().updateReferences( att.getName(), new ArrayList<>() );
 
-        m_engine.getReferenceManager().updateReferences( att.getName(), new ArrayList< String >() );
-
-        WikiPage parent = new WikiPage( m_engine, att.getParentName() );
-        m_engine.updateReferences( parent );
-
+        final WikiPage parent = new WikiPage( m_engine, att.getParentName() );
+        m_engine.getReferenceManager().updateReferences( parent );
         m_engine.getSearchManager().reindexPage( att );
     }
 
@@ -590,18 +568,14 @@ public class AttachmentManager
      *          disabled.
      *  @throws ProviderException If the provider fails for some reason.
      */
-    public List<Attachment> getVersionHistory( String attachmentName )
-        throws ProviderException
-    {
-        if( m_provider == null )
-        {
+    public List< Attachment > getVersionHistory( final String attachmentName ) throws ProviderException {
+        if( m_provider == null ) {
             return null;
         }
 
-        Attachment att = getAttachmentInfo( (WikiContext)null, attachmentName );
+        final Attachment att = getAttachmentInfo( null, attachmentName );
 
-        if( att != null )
-        {
+        if( att != null ) {
             return m_provider.getVersionHistory( att );
         }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/content/WikiPageRenamer.java b/jspwiki-main/src/main/java/org/apache/wiki/content/WikiPageRenamer.java
index f4da6b0..5eed7be 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/content/WikiPageRenamer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/content/WikiPageRenamer.java
@@ -114,7 +114,7 @@ public class WikiPageRenamer implements PageRenamer {
 
         //  Update the references
         engine.getReferenceManager().pageRemoved( fromPage );
-        engine.updateReferences( toPage );
+        engine.getReferenceManager().updateReferences( toPage );
 
         //  Update referrers
         if( changeReferrers ) {
@@ -128,7 +128,7 @@ public class WikiPageRenamer implements PageRenamer {
         for( final Attachment att:attachmentsNewName ) {
             final WikiPage toAttPage = engine.getPage( att.getName() );
             // add reference to attachment under new page name
-            engine.updateReferences( toAttPage );
+            engine.getReferenceManager().updateReferences( toAttPage );
             engine.getSearchManager().reindexPage( att );
         }
 
@@ -187,7 +187,7 @@ public class WikiPageRenamer implements PageRenamer {
          
                 try {
                     engine.getPageManager().putPageText( p, newText );
-                    engine.updateReferences( p );
+                    engine.getReferenceManager().updateReferences( p );
                 } catch( final ProviderException e ) {
                     //  We fail with an error, but we will try to continue to rename other referrers as well.
                     log.error("Unable to perform rename.",e);
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 0f508c5..3d5245a 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
@@ -160,7 +160,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * @see org.apache.wiki.pages.PageManager#getPageText(java.lang.String, int)
      */
     @Override
-    public String getPageText(String pageName, 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");
         }
@@ -168,19 +168,14 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
 
         try {
             text = m_provider.getPageText(pageName, version);
-        } catch (RepositoryModifiedException e) {
-            //
+        } catch (final RepositoryModifiedException e) {
             //  This only occurs with the latest version.
-            //
             LOG.info("Repository has been modified externally while fetching page " + pageName);
 
-            //
             //  Empty the references and yay, it shall be recalculated
-            //
-            //WikiPage p = new WikiPage( pageName );
-            WikiPage p = m_provider.getPageInfo(pageName, version);
+            final WikiPage p = m_provider.getPageInfo(pageName, version);
 
-            m_engine.updateReferences(p);
+            m_engine.getReferenceManager().updateReferences( p );
 
             if (p != null) {
                 m_engine.getSearchManager().reindexPage(p);
@@ -189,7 +184,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
                 //
                 //  Make sure that it no longer exists in internal data structures either.
                 //
-                WikiPage dummy = new WikiPage(m_engine, pageName);
+                final WikiPage dummy = new WikiPage(m_engine, pageName);
                 m_engine.getSearchManager().pageRemoved(dummy);
                 m_engine.getReferenceManager().pageRemoved(dummy);
             }
@@ -294,38 +289,26 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * @see org.apache.wiki.pages.PageManager#getPageInfo(java.lang.String, int)
      */
     @Override
-    public WikiPage getPageInfo(String pageName, int version) throws ProviderException {
+    public WikiPage getPageInfo( final String pageName, final int version) throws ProviderException {
         if (pageName == null || pageName.length() == 0) {
             throw new ProviderException("Illegal page name '" + pageName + "'");
         }
 
-        WikiPage page = null;
+        WikiPage page;
 
         try {
             page = m_provider.getPageInfo(pageName, version);
-        } catch (RepositoryModifiedException e) {
-            //
+        } catch ( final RepositoryModifiedException e) {
             //  This only occurs with the latest version.
-            //
             LOG.info("Repository has been modified externally while fetching info for " + pageName);
             page = m_provider.getPageInfo(pageName, version);
             if (page != null) {
-                m_engine.updateReferences(page);
+                m_engine.getReferenceManager().updateReferences(page);
             } else {
                 m_engine.getReferenceManager().pageRemoved(new WikiPage(m_engine, pageName));
             }
         }
 
-        //
-        //  Should update the metadata.
-        //
-        /*
-        if( page != null && !page.hasMetadata() )
-        {
-            WikiContext ctx = new WikiContext(m_engine,page);
-            m_engine.textToHTML( ctx, getPageText(pageName,version) );
-        }
-        */
         return page;
     }
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ReferenceManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ReferenceManagerTest.java
index 71afe02..80d7e6a 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/ReferenceManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/ReferenceManagerTest.java
@@ -12,37 +12,31 @@
  * limitations under the License.
  */
 package org.apache.wiki;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Set;
-
+import net.sf.ehcache.CacheManager;
 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 net.sf.ehcache.CacheManager;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Set;
 
 /**
  * The ReferenceManager maintains all hyperlinks between wiki pages.
  */
-public class ReferenceManagerTest
-{
+public class ReferenceManagerTest  {
+
     Properties props = TestEngine.getTestProperties();
     TestEngine engine;
     ReferenceManager mgr;
 
     @BeforeEach
-    public void setUp()
-        throws Exception
-    {
+    public void setUp() throws Exception {
         props.setProperty( "jspwiki.translatorReader.matchEnglishPlurals", "true");
 
-        // make sure that the reference manager cache is cleaned first
-        TestEngine.emptyWorkDir(null);
-
         engine = new TestEngine(props);
 
         // create two handy wiki pages used in most test cases
@@ -54,53 +48,42 @@ public class ReferenceManagerTest
     }
 
     @AfterEach
-    public void tearDown()
-        throws Exception
-    {
+    public void tearDown() {
         // any wiki page that was created must be deleted!
         TestEngine.emptyWikiDir();
 
-        // jspwiki always uses a singleton CacheManager, so
-        // clear the cache at the end of every test case to avoid
-        // polluting another test case
+        // jspwiki always uses a singleton CacheManager, so 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
+        TestEngine.emptyWorkDir(null);
     }
 
     @Test
-    public void testNonExistant1()
-        throws Exception
-    {
-        Collection< String > c = mgr.findReferrers("Foobar2");
+    public void testNonExistant1() {
+        final Collection< String > c = mgr.findReferrers("Foobar2");
 
         Assertions.assertNotNull( c, "referrers expected" );
         Assertions.assertTrue( c.size() == 1 && c.contains("Foobar") );
     }
 
     @Test
-    public void testNonExistant2()
-    {
-        Collection< String > c = mgr.findReferrers("TestBug");
-
+    public void testNonExistant2() {
+        final Collection< String > c = mgr.findReferrers("TestBug");
         Assertions.assertNull( c );
     }
 
     @Test
-    public void testRemove()
-        throws Exception
-    {
+    public void testRemove() throws Exception {
         Collection< String > c = mgr.findReferrers("Foobar2");
-
         Assertions.assertNotNull( c, "referrers expected" );
         Assertions.assertTrue( c.size() == 1 && c.contains("Foobar") );
 
         engine.deletePage( "Foobar" );
-
         c = mgr.findReferrers("Foobar2");
-
         Assertions.assertNull( c );
 
         engine.saveText( "Foobar", "[Foobar2]");
-
         c = mgr.findReferrers("Foobar2");
 
         Assertions.assertNotNull( c, "referrers expected" );
@@ -108,18 +91,14 @@ public class ReferenceManagerTest
     }
 
     @Test
-    public void testUnreferenced()
-        throws Exception
-    {
-        Collection< String > c = mgr.findUnreferenced();
+    public void testUnreferenced() {
+        final Collection< String > c = mgr.findUnreferenced();
         Assertions.assertTrue( Util.collectionContains( c, "TestPage" ), "Unreferenced page not found by ReferenceManager" );
     }
 
 
     @Test
-    public void testBecomesUnreferenced()
-        throws Exception
-    {
+    public void testBecomesUnreferenced() throws Exception {
         engine.saveText( "Foobar2", "[TestPage]" );
 
         Collection< String > c = mgr.findUnreferenced();
@@ -129,65 +108,52 @@ public class ReferenceManagerTest
         c = mgr.findUnreferenced();
         Assertions.assertEquals( 1, c.size(), "Wrong # of orphan pages" );
 
-        Iterator< String > i = c.iterator();
-        String first = i.next();
+        final Iterator< String > i = c.iterator();
+        final String first = i.next();
         Assertions.assertEquals( "TestPage", first, "Not correct referrers" );
     }
 
     @Test
-    public void testUncreated()
-        throws Exception
-    {
-        Collection< String > c = mgr.findUncreated();
-
-        Assertions.assertTrue( c.size()==1 && ((String) c.iterator().next()).equals("Foobar2") );
+    public void testUncreated() {
+        final Collection< String > c = mgr.findUncreated();
+        Assertions.assertTrue( c.size()==1 && ( c.iterator().next() ).equals("Foobar2") );
     }
 
     @Test
-    public void testReferrers()
-        throws Exception
-    {
+    public void testReferrers() {
         Collection< String > c = mgr.findReferrers( "TestPage" );
         Assertions.assertNull( c, "TestPage referrers" );
 
         c = mgr.findReferrers( "Foobar" );
         Assertions.assertNotNull( c, "referrers expected" );
-        Assertions.assertTrue( c.size()==2, "Foobar referrers" );
+        Assertions.assertEquals( 2, c.size(), "Foobar referrers" );
 
         c = mgr.findReferrers( "Foobar2" );
         Assertions.assertNotNull( c, "referrers expected" );
-        Assertions.assertTrue( c.size()==1 && ((String) c.iterator().next()).equals("Foobar"), "Foobar2 referrers" );
+        Assertions.assertTrue( c.size() == 1 && ( c.iterator().next() ).equals("Foobar"), "Foobar2 referrers" );
 
         c = mgr.findReferrers( "Foobars" );
         Assertions.assertNotNull( c, "referrers expected" );
         Assertions.assertEquals( 2, c.size(), "Foobars referrers" );
-        //Assertions.assertEquals( "Foobars referrer 'TestPage'", "TestPage", (String) c.iterator().next() );
     }
 
     @Test
-    public void testRefersTo()
-        throws Exception
-    {
-        Collection< String > s = mgr.findRefersTo( "Foobar" );
+    public void testRefersTo() {
+        final Collection< String > s = mgr.findRefersTo( "Foobar" );
 
         Assertions.assertTrue( s.contains("Foobar"), "does not have Foobar" );
-        // Assertions.assertTrue( "does not have Foobars", s.contains("Foobars") );
         Assertions.assertTrue( s.contains("Foobar2"), "does not have Foobar2" );
     }
 
     /**
      *  Should Assertions.fail in 2.2.14-beta
-     * @throws Exception
      */
     @Test
-    public void testSingularReferences()
-    throws Exception
-    {
+    public void testSingularReferences() throws Exception {
         engine.saveText( "RandomPage", "FatalBugs" );
         engine.saveText( "FatalBugs", "<foo>" );
         engine.saveText( "BugCommentPreviewDeletesAllComments", "FatalBug" );
-
-        Collection< String > c = mgr.findReferrers( "FatalBugs" );
+        final Collection< String > c = mgr.findReferrers( "FatalBugs" );
 
         Assertions.assertNotNull( c, "referrers expected" );
         Assertions.assertEquals( 2, c.size(), "FatalBugs referrers number" );
@@ -201,42 +167,34 @@ public class ReferenceManagerTest
     //     a plural and a singular form of the page becomes nigh impossible, so we
     //     just don't do it.
     @Test
-    public void testUpdatePluralOnlyRef()
-        throws Exception
-    {
+    public void testUpdatePluralOnlyRef() throws Exception {
         engine.saveText( "TestPage", "Reference to [Foobars]." );
         Collection< String > c = mgr.findUnreferenced();
-        Assertions.assertTrue( c.size()==1 && ((String) c.iterator().next()).equals("TestPage"), "Foobar unreferenced" );
+        Assertions.assertTrue( c.size()==1 && ( c.iterator().next() ).equals("TestPage"), "Foobar unreferenced" );
 
         c = mgr.findReferrers( "Foobar" );
         Assertions.assertNotNull( c, "referrers expected" );
-        Assertions.assertTrue( c.size()==2, "Foobar referrers" );
+        Assertions.assertEquals( 2, c.size(), "Foobar referrers" );
     }
 
 
     /**
-     *  Opposite to testUpdatePluralOnlyRef(). Is a page with plural form recognized as
-     *  the page referenced by a singular link.
+     *  Opposite to testUpdatePluralOnlyRef(). Is a page with plural form recognized as the page referenced by a singular link.
      */
-
     @Test
-    public void testUpdateFoobar2s()
-        throws Exception
-    {
+    public void testUpdateFoobar2s() throws Exception {
         engine.saveText( "Foobar2s", "qwertz" );
-        Assertions.assertTrue( mgr.findUncreated().size()==0, "no uncreated" );
+        Assertions.assertEquals( 0, mgr.findUncreated().size(), "no uncreated" );
 
-        Collection< String > c = mgr.findReferrers( "Foobar2s" );
+        final Collection< String > c = mgr.findReferrers( "Foobar2s" );
         Assertions.assertNotNull( c, "referrers expected" );
-        Assertions.assertTrue( c!=null && c.size()==1 && ((String) c.iterator().next()).equals("Foobar"), "referrers" );
+        Assertions.assertTrue( c.size()==1 && ( c.iterator().next() ).equals("Foobar"), "referrers" );
     }
 
     @Test
-    public void testUpdateBothExist()
-        throws Exception
-    {
+    public void testUpdateBothExist() throws Exception {
         engine.saveText( "Foobars", "qwertz" );
-        Collection< String > c = mgr.findReferrers( "Foobars" );
+        final Collection< String > c = mgr.findReferrers( "Foobars" );
         Assertions.assertNotNull( c, "referrers expected" );
         Assertions.assertEquals( 2, c.size(), "Foobars referrers" );
         Assertions.assertTrue( c.contains( "TestPage" ) && c.contains("Foobar"), "Foobars referrer is not TestPage" );
@@ -249,30 +207,25 @@ public class ReferenceManagerTest
         engine.saveText( "Foobars", "qwertz" );
         engine.saveText( "TestPage", "Reference to [Foobar], [Foobars]." );
 
-        Collection< String > c = mgr.findReferrers( "Foobars" );
+        final Collection< String > c = mgr.findReferrers( "Foobars" );
         Assertions.assertNotNull( c, "referrers expected" );
         Assertions.assertEquals( 2, c.size(), "Foobars referrers count" );
         Assertions.assertTrue( c.contains("TestPage") && c.contains("Foobar"), "Foobars referrers" );
     }
 
     @Test
-    public void testCircularRefs()
-        throws Exception
-    {
+    public void testCircularRefs() throws Exception {
         engine.saveText( "Foobar2", "ref to [TestPage]" );
 
-        Assertions.assertTrue( mgr.findUncreated().size()==0, "no uncreated" );
-        Assertions.assertTrue( mgr.findUnreferenced().size()==0, "no unreferenced" );
+        Assertions.assertEquals( 0, mgr.findUncreated().size(), "no uncreated" );
+        Assertions.assertEquals( 0, mgr.findUnreferenced().size(), "no unreferenced" );
     }
 
     @Test
-    public void testPluralSingularUpdate1()
-        throws Exception
-    {
+    public void testPluralSingularUpdate1() throws Exception {
         engine.saveText( "BugOne", "NewBug" );
         engine.saveText( "NewBugs", "foo" );
         engine.saveText( "OpenBugs", "bar" );
-
         engine.saveText( "BugOne", "OpenBug" );
 
         Collection< String > ref = mgr.findReferrers( "NewBugs" );
@@ -294,9 +247,7 @@ public class ReferenceManagerTest
     }
 
     @Test
-    public void testPluralSingularUpdate2()
-        throws Exception
-    {
+    public void testPluralSingularUpdate2() throws Exception {
         engine.saveText( "BugOne", "NewBug" );
         engine.saveText( "NewBug", "foo" );
         engine.saveText( "OpenBug", "bar" );
@@ -322,14 +273,11 @@ public class ReferenceManagerTest
     }
 
     @Test
-    public void testPluralSingularUpdate3()
-        throws Exception
-    {
+    public void testPluralSingularUpdate3() throws Exception {
         engine.saveText( "BugOne", "NewBug" );
         engine.saveText( "BugTwo", "NewBug" );
         engine.saveText( "NewBugs", "foo" );
         engine.saveText( "OpenBugs", "bar" );
-
         engine.saveText( "BugOne", "OpenBug" );
 
         Collection< String > ref = mgr.findReferrers( "NewBugs" );
@@ -351,43 +299,42 @@ public class ReferenceManagerTest
         Assertions.assertNotNull( ref, "referrers expected" );
         Assertions.assertEquals( 1,ref.size(), "openbug" );
         Assertions.assertEquals( "BugOne",ref.iterator().next(), "openbug2" );
-
     }
 
     @Test
-    public void testSelf() throws WikiException
-    {
+    public void testSelf() throws WikiException {
         engine.saveText( "BugOne", "BugOne" );
-        Collection< String > ref = mgr.findReferrers( "BugOne" );
+        final Collection< String > ref = mgr.findReferrers( "BugOne" );
         Assertions.assertNotNull( ref, "referrers expected" );
         Assertions.assertEquals( 1, ref.size(), "wrong size" );
         Assertions.assertEquals( "BugOne", ref.iterator().next(), "ref");
     }
 
+    @Test
+    public void testReadLinks() {
+        final String src="Foobar. [Foobar].  Frobozz.  [This is a link].";
+        final Object[] result = mgr.scanWikiLinks( new WikiPage( engine, "Test"), src ).toArray();
+
+        Assertions.assertEquals( "Foobar", result[0], "item 0" );
+        Assertions.assertEquals( "This is a link", result[1], "item 1" );
+    }
+
     /**
      * Test method: dumps the contents of  ReferenceManager link lists to stdout.
      * This method is NOT synchronized, and should be used in testing
      * with one user, one WikiEngine only.
      */
-    public static String dumpReferenceManager( ReferenceManager rm )
-    {
-    	StringBuilder buf = new StringBuilder();
-        try
-        {
+    public static String dumpReferenceManager( final ReferenceManager rm ) {
+    	final StringBuilder buf = new StringBuilder();
+        try {
             buf.append( "================================================================\n" );
             buf.append( "Referred By list:\n" );
             Set< String > keys = rm.getReferredBy().keySet();
-            Iterator< String > it = keys.iterator();
-            while( it.hasNext() )
-            {
-                String key = it.next();
-                buf.append( key + " referred by: " );
-                Set< String > refs = rm.getReferredBy().get( key );
-                Iterator< String > rit = refs.iterator();
-                while( rit.hasNext() )
-                {
-                    String aRef = rit.next();
-                    buf.append( aRef + " " );
+            for( final String key : keys ) {
+                buf.append( key ).append( " referred by: " );
+                final Set< String > refs = rm.getReferredBy().get( key );
+                for( final String aRef : refs ) {
+                    buf.append( aRef ).append( " " );
                 }
                 buf.append( "\n" );
             }
@@ -396,19 +343,12 @@ public class ReferenceManagerTest
             buf.append( "----------------------------------------------------------------\n" );
             buf.append( "Refers To list:\n" );
             keys = rm.getRefersTo().keySet();
-            it = keys.iterator();
-            while( it.hasNext() )
-            {
-                String key = (String) it.next();
-                buf.append( key + " refers to: " );
-                Collection< String > refs = rm.getRefersTo().get( key );
-                if(refs != null)
-                {
-                    Iterator< String > rit = refs.iterator();
-                    while( rit.hasNext() )
-                    {
-                        String aRef = rit.next();
-                        buf.append( aRef + " " );
+            for( final String key : keys ) {
+                buf.append( key ).append( " refers to: " );
+                final Collection< String > refs = rm.getRefersTo().get( key );
+                if(refs != null) {
+                    for( final String aRef : refs ) {
+                        buf.append( aRef ).append( " " );
                     }
                     buf.append( "\n" );
                 } else {
@@ -416,10 +356,8 @@ public class ReferenceManagerTest
                 }
             }
             buf.append( "================================================================\n" );
-        }
-        catch(Exception e)
-        {
-            buf.append("Problem in dump(): " + e + "\n" );
+        } catch( final Exception e ) {
+            buf.append("Problem in dump(): " ).append( e ).append( "\n" );
         }
 
         return( buf.toString() );
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 aa6ab6b..6f7f9c8 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -226,18 +226,6 @@ public class WikiEngineTest
     }
 
     @Test
-    public void testReadLinks()
-        throws Exception
-    {
-        String src="Foobar. [Foobar].  Frobozz.  [This is a link].";
-
-        Object[] result = m_engine.scanWikiLinks( new WikiPage(m_engine, "Test"), src ).toArray();
-
-        Assertions.assertEquals( "Foobar", result[0], "item 0" );
-        Assertions.assertEquals( "This is a link", result[1], "item 1" );
-    }
-
-    @Test
     public void testBeautifyTitle()
     {
         String src = "WikiNameThingy";


[jspwiki] 12/18: Renamed WikiVariableManager to DefaultVariableManager and moved it, along with VariableManager, to their own package under org.apache.wiki.variables

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 d858bd8e69af32e2852a916657c8dfcda288d334
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 2 23:56:07 2020 +0100

    Renamed WikiVariableManager to DefaultVariableManager and moved it, along with VariableManager, to their own package under org.apache.wiki.variables
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java  |  3 ++-
 .../DefaultVariableManager.java}                            | 13 +++++++++----
 .../org/apache/wiki/{ => variables}/VariableManager.java    |  3 ++-
 jspwiki-main/src/main/resources/ini/classmappings.xml       |  8 ++++----
 .../DefaultVariableManagerTest.java}                        | 11 +++++++----
 5 files changed, 24 insertions(+), 14 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 227ec74..e8a322c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -62,6 +62,7 @@ import org.apache.wiki.url.URLConstructor;
 import org.apache.wiki.util.ClassUtil;
 import org.apache.wiki.util.PropertyReader;
 import org.apache.wiki.util.TextUtil;
+import org.apache.wiki.variables.VariableManager;
 import org.apache.wiki.workflow.Decision;
 import org.apache.wiki.workflow.DecisionRequiredException;
 import org.apache.wiki.workflow.Fact;
@@ -202,7 +203,7 @@ public class WikiEngine  {
     private PluginManager    m_pluginManager;
 
     /** Stores the Variable manager */
-    private VariableManager  m_variableManager;
+    private VariableManager m_variableManager;
 
     /** Stores the Attachment manager */
     private AttachmentManager m_attachmentManager = null;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiVariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
similarity index 97%
rename from jspwiki-main/src/main/java/org/apache/wiki/WikiVariableManager.java
rename to jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
index fad2226..171760d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiVariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/variables/DefaultVariableManager.java
@@ -16,9 +16,14 @@
     specific language governing permissions and limitations
     under the License.
  */
-package org.apache.wiki;
+package org.apache.wiki.variables;
 
 import org.apache.log4j.Logger;
+import org.apache.wiki.Release;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.WikiProvider;
+import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.NoSuchVariableException;
 import org.apache.wiki.api.filters.PageFilter;
@@ -42,9 +47,9 @@ import java.util.ResourceBundle;
  *
  *  @since 1.9.20.
  */
-public class WikiVariableManager implements VariableManager {
+public class DefaultVariableManager implements VariableManager {
 
-    private static final Logger log = Logger.getLogger( WikiVariableManager.class );
+    private static final Logger log = Logger.getLogger( DefaultVariableManager.class );
 
     /**
      *  Contains a list of those properties that shall never be shown. Put names here in lower case.
@@ -57,7 +62,7 @@ public class WikiVariableManager implements VariableManager {
      *  Creates a VariableManager object using the property list given.
      *  @param props The properties.
      */
-    public WikiVariableManager( final Properties props ) {
+    public DefaultVariableManager( final Properties props ) {
     }
 
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/VariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/variables/VariableManager.java
similarity index 98%
rename from jspwiki-main/src/main/java/org/apache/wiki/VariableManager.java
rename to jspwiki-main/src/main/java/org/apache/wiki/variables/VariableManager.java
index dda06a6..043c395 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/VariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/variables/VariableManager.java
@@ -16,8 +16,9 @@
     specific language governing permissions and limitations
     under the License.
  */
-package org.apache.wiki;
+package org.apache.wiki.variables;
 
+import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.exceptions.NoSuchVariableException;
 import org.apache.wiki.parser.LinkParsingOperations;
 
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index dbd3cdb..c2fbecf 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -52,10 +52,6 @@
     <mappedClass>org.apache.wiki.pages.DefaultPageManager</mappedClass>
   </mapping>
   <mapping>
-    <requestedClass>org.apache.wiki.VariableManager</requestedClass>
-    <mappedClass>org.apache.wiki.WikiVariableManager</mappedClass>
-  </mapping>
-  <mapping>
     <requestedClass>org.apache.wiki.api.engine.FilterManager</requestedClass>
     <mappedClass>org.apache.wiki.filters.DefaultFilterManager</mappedClass>
   </mapping>
@@ -128,6 +124,10 @@
     <mappedClass>org.apache.wiki.ui.TemplateManager</mappedClass>
   </mapping>
   <mapping>
+    <requestedClass>org.apache.wiki.variables.VariableManager</requestedClass>
+    <mappedClass>org.apache.wiki.variables.DefaultVariableManager</mappedClass>
+  </mapping>
+  <mapping>
     <requestedClass>org.apache.wiki.workflow.WorkflowManager</requestedClass>
     <mappedClass>org.apache.wiki.workflow.WorkflowManager</mappedClass>
   </mapping>
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/WikiVariableManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/variables/DefaultVariableManagerTest.java
similarity index 92%
rename from jspwiki-main/src/test/java/org/apache/wiki/WikiVariableManagerTest.java
rename to jspwiki-main/src/test/java/org/apache/wiki/variables/DefaultVariableManagerTest.java
index 86f8259..63a4826 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiVariableManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/variables/DefaultVariableManagerTest.java
@@ -17,25 +17,28 @@
     under the License.
  */
 
-package org.apache.wiki;
+package org.apache.wiki.variables;
 
+import org.apache.wiki.TestEngine;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.NoSuchVariableException;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
 
 
-public class WikiVariableManagerTest  {
+public class DefaultVariableManagerTest {
 
     static VariableManager m_variableManager;
-    static WikiContext     m_context;
+    static WikiContext m_context;
 
     static final String PAGE_NAME = "TestPage";
 
     @BeforeAll
     public static void setUp() {
         final TestEngine testEngine = TestEngine.build();
-        m_variableManager = new WikiVariableManager( TestEngine.getTestProperties() );
+        m_variableManager = new DefaultVariableManager( TestEngine.getTestProperties() );
         m_context = new WikiContext( testEngine, new WikiPage( testEngine, PAGE_NAME ) );
     }
 


[jspwiki] 01/18: code 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 0b57c00950c20e00864268c9ac0e546604990caa
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Dec 30 20:09:01 2019 +0100

    code format and fixes suggested by IntelliJ
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 154 +++++++++------------
 .../org/apache/wiki/render/CreoleRenderer.java     | 122 ++++++----------
 .../wiki/render/CustomXMLOutputProcessor.java      |   6 +-
 .../org/apache/wiki/render/RenderingManager.java   | 152 +++++++++-----------
 .../java/org/apache/wiki/render/WikiRenderer.java  |  19 ++-
 .../apache/wiki/render/WysiwygEditingRenderer.java | 111 ++++++---------
 .../java/org/apache/wiki/render/XHTMLRenderer.java |  34 ++---
 7 files changed, 236 insertions(+), 362 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 9db2f4e..8d32d26 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -26,7 +26,6 @@ import org.apache.wiki.api.engine.AdminBeanManager;
 import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.api.exceptions.FilterException;
-import org.apache.wiki.api.exceptions.NoSuchVariableException;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.Attachment;
@@ -1290,7 +1289,7 @@ public class WikiEngine  {
      *  @return String of WikiText.
      *  @since 2.1.13.
      */
-    public String getPureText( WikiPage page )
+    public String getPureText( final WikiPage page )
     {
         return getPureText( page.getName(), page.getVersion() );
     }
@@ -1303,16 +1302,9 @@ public class WikiEngine  {
      *  @param  page WikiPage reference.
      *  @return HTML-rendered version of the page.
      */
-
-    public String getHTML( WikiContext context, WikiPage page )
-    {
-        String pagedata = null;
-
-        pagedata = getPureText( page.getName(), page.getVersion() );
-
-        String res = textToHTML( context, pagedata );
-
-        return res;
+    public String getHTML( final WikiContext context, final WikiPage page ) {
+        final String pagedata = getPureText( page.getName(), page.getVersion() );
+        return textToHTML( context, pagedata );
     }
 
     /**
@@ -1321,7 +1313,7 @@ public class WikiEngine  {
      *  @param page WikiName of the page to convert.
      *  @return HTML-rendered version of the page.
      */
-    public String getHTML( String page )
+    public String getHTML( final String page )
     {
         return getHTML( page, WikiPageProvider.LATEST_VERSION );
     }
@@ -1335,17 +1327,11 @@ public class WikiEngine  {
      *  @param version Version number to fetch
      *  @return HTML-rendered page text.
      */
-    public String getHTML( String pagename, int version )
-    {
-        WikiPage page = getPage( pagename, version );
-
-        WikiContext context = new WikiContext( this,
-                                               page );
+    public String getHTML( final String pagename, final int version ) {
+        final WikiPage page = getPage( pagename, version );
+        final WikiContext context = new WikiContext( this, page );
         context.setRequestContext( WikiContext.NONE );
-
-        String res = getHTML( context, page );
-
-        return res;
+        return getHTML( context, page );
     }
 
     /**
@@ -1355,58 +1341,53 @@ public class WikiEngine  {
      *  @param context  The WikiContext in which the page is to be rendered
      *  @return Rendered page text
      */
-    public String textToHTML( WikiContext context, String pagedata )
-    {
+    public String textToHTML( final WikiContext context, String pagedata ) {
         String result = "";
 
-        boolean runFilters = "true".equals(m_variableManager.getValue(context,PROP_RUNFILTERS,"true"));
+        final boolean runFilters = "true".equals(m_variableManager.getValue(context,PROP_RUNFILTERS,"true"));
 
-        StopWatch sw = new StopWatch();
+        final StopWatch sw = new StopWatch();
         sw.start();
-        try
-        {
-            if( runFilters )
+        try {
+            if( runFilters ) {
                 pagedata = m_filterManager.doPreTranslateFiltering( context, pagedata );
+            }
 
             result = m_renderingManager.getHTML( context, pagedata );
 
-            if( runFilters )
+            if( runFilters ) {
                 result = m_filterManager.doPostTranslateFiltering( context, result );
-        }
-        catch( FilterException e )
-        {
+            }
+        } catch( final FilterException e ) {
+            log.error( "page filter threw exception: ", e );
             // FIXME: Don't yet know what to do
         }
         sw.stop();
-        if( log.isDebugEnabled() )
-            log.debug("Page "+context.getRealPage().getName()+" rendered, took "+sw );
+        if( log.isDebugEnabled() ) {
+            log.debug( "Page " + context.getRealPage().getName() + " rendered, took " + sw );
+        }
 
         return result;
     }
 
     /**
-     * Protected method that signals that the WikiEngine will be
-     * shut down by the servlet container. It is called by
-     * {@link WikiServlet#destroy()}. When this method is called,
-     * it fires a "shutdown" WikiEngineEvent to all registered
-     * listeners.
+     * Protected method that signals that the WikiEngine will be shut down by the servlet container. It is called by
+     * {@link WikiServlet#destroy()}. When this method is called, it fires a "shutdown" WikiEngineEvent to all registered listeners.
      */
-    protected void shutdown()
-    {
+    protected void shutdown() {
         fireEvent( WikiEngineEvent.SHUTDOWN );
         m_filterManager.destroy();
     }
 
     /**
-     *  Reads a WikiPageful of data from a String and returns all links
-     *  internal to this Wiki in a Collection.
+     *  Reads a WikiPageful of data from a String and returns all links internal to this Wiki in a Collection.
      *
      *  @param page The WikiPage to scan
      *  @param pagedata The page contents
      *  @return a Collection of Strings
      */
-    public Collection< String > scanWikiLinks( WikiPage page, String pagedata ) {
-        LinkCollector localCollector = new LinkCollector();
+    public Collection< String > scanWikiLinks( final WikiPage page, final String pagedata ) {
+        final LinkCollector localCollector = new LinkCollector();
 
         textToHTML( new WikiContext( this, page ),
                     pagedata,
@@ -1430,11 +1411,10 @@ public class WikiEngine  {
      *  @return HTML-rendered page text.
      */
 
-    public String textToHTML( WikiContext context,
-                              String pagedata,
-                              StringTransmutator localLinkHook,
-                              StringTransmutator extLinkHook )
-    {
+    public String textToHTML( final WikiContext context,
+                              final String pagedata,
+                              final StringTransmutator localLinkHook,
+                              final StringTransmutator extLinkHook ) {
         return textToHTML( context, pagedata, localLinkHook, extLinkHook, null, true, false );
     }
 
@@ -1449,12 +1429,11 @@ public class WikiEngine  {
      *  @return HTML-rendered page text.
      */
 
-    public String textToHTML( WikiContext context,
-                              String pagedata,
-                              StringTransmutator localLinkHook,
-                              StringTransmutator extLinkHook,
-                              StringTransmutator attLinkHook )
-    {
+    public String textToHTML( final WikiContext context,
+                              final String pagedata,
+                              final StringTransmutator localLinkHook,
+                              final StringTransmutator extLinkHook,
+                              final StringTransmutator attLinkHook ) {
         return textToHTML( context, pagedata, localLinkHook, extLinkHook, attLinkHook, true, false );
     }
 
@@ -1466,68 +1445,61 @@ public class WikiEngine  {
      *  @param localLinkHook Is called whenever a wiki link is found
      *  @param extLinkHook   Is called whenever an external link is found
      *  @param parseAccessRules Parse the access rules if we encounter them
-     *  @param justParse Just parses the pagedata, does not actually render.  In this case,
-     *                   this methods an empty string.
+     *  @param justParse Just parses the pagedata, does not actually render.  In this case, this methods an empty string.
      *  @return HTML-rendered page text.
-
      */
-    private String textToHTML( WikiContext context,
+    private String textToHTML( final WikiContext context,
                                String pagedata,
-                               StringTransmutator localLinkHook,
-                               StringTransmutator extLinkHook,
-                               StringTransmutator attLinkHook,
-                               boolean            parseAccessRules,
-                               boolean            justParse )
-    {
+                               final StringTransmutator localLinkHook,
+                               final StringTransmutator extLinkHook,
+                               final StringTransmutator attLinkHook,
+                               final boolean            parseAccessRules,
+                               final boolean            justParse ) {
         String result = "";
 
-        if( pagedata == null )
-        {
+        if( pagedata == null ) {
             log.error("NULL pagedata to textToHTML()");
             return null;
         }
 
-        boolean runFilters = "true".equals(m_variableManager.getValue(context,PROP_RUNFILTERS,"true"));
+        final boolean runFilters = "true".equals(m_variableManager.getValue(context,PROP_RUNFILTERS,"true"));
 
-        try
-        {
-            StopWatch sw = new StopWatch();
+        try {
+            final StopWatch sw = new StopWatch();
             sw.start();
 
-            if( runFilters && m_filterManager != null )
+            if( runFilters && m_filterManager != null ) {
                 pagedata = m_filterManager.doPreTranslateFiltering( context, pagedata );
+            }
 
-            MarkupParser mp = m_renderingManager.getParser( context, pagedata );
+            final MarkupParser mp = m_renderingManager.getParser( context, pagedata );
             mp.addLocalLinkHook( localLinkHook );
             mp.addExternalLinkHook( extLinkHook );
             mp.addAttachmentLinkHook( attLinkHook );
 
-            if( !parseAccessRules ) mp.disableAccessRules();
+            if( !parseAccessRules ) {
+                mp.disableAccessRules();
+            }
 
-            WikiDocument doc = mp.parse();
+            final WikiDocument doc = mp.parse();
 
-            //
             //  In some cases it's better just to parse, not to render
-            //
-            if( !justParse )
-            {
+            if( !justParse ) {
                 result = m_renderingManager.getHTML( context, doc );
 
-                if( runFilters && m_filterManager != null )
+                if( runFilters && m_filterManager != null ) {
                     result = m_filterManager.doPostTranslateFiltering( context, result );
+                }
             }
 
             sw.stop();
 
-            if( log.isDebugEnabled() )
-                log.debug("Page "+context.getRealPage().getName()+" rendered, took "+sw );
-        }
-        catch( IOException e )
-        {
+            if( log.isDebugEnabled() ) {
+                log.debug( "Page " + context.getRealPage().getName() + " rendered, took " + sw );
+            }
+        } catch( final IOException e ) {
             log.error( "Failed to scan page data: ", e );
-        }
-        catch( FilterException e )
-        {
+        } catch( final FilterException e ) {
         	log.error( "page filter threw exception: ", e );
             // FIXME: Don't yet know what to do
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/CreoleRenderer.java b/jspwiki-main/src/main/java/org/apache/wiki/render/CreoleRenderer.java
index 9700228..93f8255 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/CreoleRenderer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/CreoleRenderer.java
@@ -18,11 +18,6 @@
  */
 package org.apache.wiki.render;
 
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.parser.PluginContent;
 import org.apache.wiki.parser.WikiDocument;
@@ -30,14 +25,17 @@ import org.jdom2.Content;
 import org.jdom2.Element;
 import org.jdom2.Text;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  *  Implements DOM-to-Creole rendering.
  *  <p>
  *  FIXME: This class is not yet completely done.
  *
  */
-public class CreoleRenderer extends WikiRenderer
-{
+public class CreoleRenderer extends WikiRenderer {
+
     private static final String IMG_START = "{{";
     private static final String IMG_END = "}}";
     private static final String PLUGIN_START = "<<";
@@ -76,67 +74,51 @@ public class CreoleRenderer extends WikiRenderer
     private int m_listCount = 0;
     private char m_listChar = 'x';
 
-    private List<PluginContent> m_plugins = new ArrayList<PluginContent>();
+    private final List< PluginContent > m_plugins = new ArrayList<>();
 
     /**
      *  Creates a new Creole Renderer.
-     *
      */
-    public CreoleRenderer( WikiContext ctx, WikiDocument doc )
+    public CreoleRenderer( final WikiContext ctx, final WikiDocument doc )
     {
         super( ctx, doc );
     }
 
     /**
      * Renders an element into the StringBuilder given
-     * @param ce
-     * @param sb
+     * @param ce element to render
+     * @param sb stringbuilder holding the element render
      */
-    private void renderElement( Element ce, StringBuilder sb )
-    {
+    private void renderElement( final Element ce, final StringBuilder sb ) {
         String endEl = EMPTY_STRING;
-        for( int i = 0; i < ELEMENTS.length; i+=3 )
-        {
-            if( ELEMENTS[i].equals(ce.getName()) )
-            {
+        for( int i = 0; i < ELEMENTS.length; i+=3 ) {
+            if( ELEMENTS[i].equals(ce.getName()) ) {
                 sb.append( ELEMENTS[i+1] );
                 endEl = ELEMENTS[i+2];
             }
         }
 
-        if( UL.equals(ce.getName()) )
-        {
+        if( UL.equals(ce.getName()) ) {
             m_listCount++;
             m_listChar = '*';
-        }
-        else if( OL.equals(ce.getName()) )
-        {
+        } else if( OL.equals(ce.getName()) ) {
             m_listCount++;
             m_listChar = '#';
-        }
-        else if( LI.equals(ce.getName()) )
-        {
+        } else if( LI.equals(ce.getName()) ) {
             for(int i = 0; i < m_listCount; i++ ) sb.append( m_listChar );
             sb.append( ONE_SPACE );
-        }
-        else if( A.equals(ce.getName()) )
-        {
-            String href = ce.getAttributeValue( HREF_ATTRIBUTE );
-            String text = ce.getText();
-
-            if( href.equals(text) )
-            {
-                sb.append( HREF_START + href + HREF_END );
-            }
-            else
-            {
-                sb.append( HREF_START + href+ HREF_DELIMITER + text +HREF_END);
+        } else if( A.equals( ce.getName() ) ) {
+            final String href = ce.getAttributeValue( HREF_ATTRIBUTE );
+            final String text = ce.getText();
+
+            if( href.equals( text ) ) {
+                sb.append( HREF_START ).append( href ).append( HREF_END );
+            } else {
+                sb.append( HREF_START ).append( href ).append( HREF_DELIMITER ).append( text ).append( HREF_END);
             }
             // Do not render anything else
             return;
-        }
-        else if( PRE.equals(ce.getName()) )
-        {
+        } else if( PRE.equals( ce.getName() ) ) {
             sb.append( PRE_START );
             sb.append( ce.getText() );
             sb.append( PRE_END );
@@ -144,43 +126,27 @@ public class CreoleRenderer extends WikiRenderer
             return;
         }
 
-        //
         //  Go through the children
-        //
-        for( Iterator< Content > i = ce.getContent().iterator(); i.hasNext(); )
-        {
-            Content c = i.next();
-
-            if( c instanceof PluginContent )
-            {
-                PluginContent pc = (PluginContent)c;
-
-                if( pc.getPluginName().equals( PLUGIN_IMAGE ) )
-                {
-                    sb.append( IMG_START + pc.getParameter( PARAM_SRC ) + IMG_END );
-                }
-                else
-                {
+        for( final Content c : ce.getContent() ) {
+            if( c instanceof PluginContent ) {
+                final PluginContent pc = ( PluginContent )c;
+
+                if( pc.getPluginName().equals( PLUGIN_IMAGE ) ) {
+                    sb.append( IMG_START ).append( pc.getParameter( PARAM_SRC ) ).append( IMG_END );
+                } else {
                     m_plugins.add(pc);
-                    sb.append( PLUGIN_START + pc.getPluginName() + ONE_SPACE + m_plugins.size() + PLUGIN_END );
+                    sb.append( PLUGIN_START ).append( pc.getPluginName() ).append( ONE_SPACE ).append( m_plugins.size() ).append( PLUGIN_END );
                 }
-            }
-            else if( c instanceof Text )
-            {
-                sb.append( ((Text)c).getText() );
-            }
-            else if( c instanceof Element )
-            {
-                renderElement( (Element)c, sb );
+            } else if( c instanceof Text ) {
+                sb.append( ( ( Text )c ).getText() );
+            } else if( c instanceof Element ) {
+                renderElement( ( Element )c, sb );
             }
         }
 
-        if( UL.equals( ce.getName() ) || OL.equals( ce.getName() ) )
-        {
+        if( UL.equals( ce.getName() ) || OL.equals( ce.getName() ) ) {
             m_listCount--;
-        }
-        else if( P.equals( ce.getName() ) )
-        {
+        } else if( P.equals( ce.getName() ) ) {
             sb.append( LINEBREAK );
         }
 
@@ -190,18 +156,12 @@ public class CreoleRenderer extends WikiRenderer
     /**
      *  {@inheritDoc}
      */
-    public String getString() throws IOException
-    {
-    	StringBuilder sb = new StringBuilder(1000);
-
-        Element ce = m_document.getRootElement();
+    public String getString() {
+    	final StringBuilder sb = new StringBuilder(1000);
+        final Element ce = m_document.getRootElement();
 
-        //
         //  Traverse through the entire tree of everything.
-        //
-
         renderElement( ce, sb );
-
         return sb.toString();
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/CustomXMLOutputProcessor.java b/jspwiki-main/src/main/java/org/apache/wiki/render/CustomXMLOutputProcessor.java
index 9a52483..da68a9d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/CustomXMLOutputProcessor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/CustomXMLOutputProcessor.java
@@ -33,10 +33,10 @@ import java.io.Writer;
  */
 public class CustomXMLOutputProcessor extends AbstractXMLOutputProcessor {
 
-    protected void attributeEscapedEntitiesFilter(final Writer out,
-                                                  final FormatStack fstack, final String value) throws IOException {
+    protected void attributeEscapedEntitiesFilter( final Writer out,
+                                                   final FormatStack fstack, final String value ) throws IOException {
 
-        write(out, Format.escapeAttribute(fstack.getEscapeStrategy(), value));
+        write( out, Format.escapeAttribute( fstack.getEscapeStrategy(), value ) );
 
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java b/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
index e11d190..8a59271 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
@@ -18,12 +18,9 @@
  */
 package org.apache.wiki.render;
 
-import java.io.IOException;
-import java.io.StringReader;
-import java.lang.reflect.Constructor;
-import java.util.Collection;
-import java.util.Properties;
-
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Element;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -40,34 +37,33 @@ import org.apache.wiki.parser.WikiDocument;
 import org.apache.wiki.providers.WikiPageProvider;
 import org.apache.wiki.util.ClassUtil;
 
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Element;
+import java.io.IOException;
+import java.io.StringReader;
+import java.lang.reflect.Constructor;
+import java.util.Collection;
+import java.util.Properties;
 
 
 /**
- *  This class provides a facade towards the differing rendering routines.  You should
- *  use the routines in this manager instead of the ones in WikiEngine, if you don't
- *  want the different side effects to occur - such as WikiFilters.
+ *  This class provides a facade towards the differing rendering routines.  You should use the routines in this manager
+ *  instead of the ones in WikiEngine, if you don't want the different side effects to occur - such as WikiFilters.
  *  <p>
- *  This class also manages a rendering cache, i.e. documents are stored between calls.
- *  You may control the cache by tweaking the ehcache.xml file.
+ *  This class also manages a rendering cache, i.e. documents are stored between calls. You may control the cache by
+ *  tweaking the ehcache.xml file.
  *  <p>
  *
  *  @since  2.4
  */
-public class RenderingManager implements WikiEventListener, InternalModule
-{
-    private static Logger log = Logger.getLogger( RenderingManager.class );
+public class RenderingManager implements WikiEventListener, InternalModule {
 
-    private int        m_cacheExpiryPeriod = 24*60*60; // This can be relatively long
+    private static final Logger log = Logger.getLogger( RenderingManager.class );
 
-    private WikiEngine m_engine;
+    private final int m_cacheExpiryPeriod = 24*60*60; // This can be relatively long
+    private final CacheManager m_cacheManager = CacheManager.getInstance();
 
+    private WikiEngine m_engine;
     private boolean m_useCache = true;
 
-    private CacheManager m_cacheManager = CacheManager.getInstance();
-
     /** The capacity of the caches, if you want something else, tweak ehcache.xml. */
     private static final int    DEFAULT_CACHESIZE     = 1000;
     private static final String VERSION_DELIMITER     = "::";
@@ -79,10 +75,10 @@ public class RenderingManager implements WikiEventListener, InternalModule
     public static final String DEFAULT_PARSER = JSPWikiMarkupParser.class.getName();
 
     /** The name of the default renderer. */
-    public  static final String DEFAULT_RENDERER  = XHTMLRenderer.class.getName();
+    public  static final String DEFAULT_RENDERER = XHTMLRenderer.class.getName();
 
     /** The name of the default WYSIWYG renderer. */
-    public  static final String DEFAULT_WYSIWYG_RENDERER  = WysiwygEditingRenderer.class.getName();
+    public  static final String DEFAULT_WYSIWYG_RENDERER = WysiwygEditingRenderer.class.getName();
 
     /** Stores the WikiDocuments that have been cached. */
     private Cache m_documentCache;
@@ -116,11 +112,8 @@ public class RenderingManager implements WikiEventListener, InternalModule
      *  @param properties A list of properties to get parameters from.
      *  @throws WikiException If the manager could not be initialized.
      */
-    public void initialize( WikiEngine engine, Properties properties )
-        throws WikiException
-    {
+    public void initialize( final WikiEngine engine, final Properties properties ) throws WikiException {
         m_engine = engine;
-
         m_markupParserClass = properties.getProperty( PROP_PARSER, DEFAULT_PARSER );
         if( !ClassUtil.assignable( m_markupParserClass, MarkupParser.class.getName() ) ) {
         	log.warn( m_markupParserClass + " does not subclass " + MarkupParser.class.getName() + " reverting to default markup parser." );
@@ -128,17 +121,16 @@ public class RenderingManager implements WikiEventListener, InternalModule
         }
         log.info( "Using " + m_markupParserClass + " as markup parser." );
 
-        m_useCache = "true".equals(properties.getProperty(PageManager.PROP_USECACHE));
-
-        if (m_useCache) {
-            String documentCacheName = engine.getApplicationName() + "." + DOCUMENTCACHE_NAME;
+        m_useCache = "true".equals( properties.getProperty( PageManager.PROP_USECACHE ) );
 
+        if( m_useCache ) {
+            final String documentCacheName = engine.getApplicationName() + "." + DOCUMENTCACHE_NAME;
             if (m_cacheManager.cacheExists(documentCacheName)) {
                 m_documentCache = m_cacheManager.getCache(documentCacheName);
             } else {
-                log.info("cache with name " + documentCacheName + " not found in ehcache.xml, creating it with defaults.");
-                m_documentCache = new Cache(documentCacheName, DEFAULT_CACHESIZE, false, false, m_cacheExpiryPeriod, m_cacheExpiryPeriod);
-                m_cacheManager.addCache(m_documentCache);
+                log.info( "cache with name " + documentCacheName + " not found in ehcache.xml, creating it with defaults." );
+                m_documentCache = new Cache( documentCacheName, DEFAULT_CACHESIZE, false, false, m_cacheExpiryPeriod, m_cacheExpiryPeriod );
+                m_cacheManager.addCache( m_documentCache );
             }
         }
 
@@ -177,10 +169,10 @@ public class RenderingManager implements WikiEventListener, InternalModule
      *  @param pagedata the page data
      *  @return A MarkupParser instance.
      */
-    public MarkupParser getParser( WikiContext context, String pagedata ) {
+    public MarkupParser getParser( final WikiContext context, final String pagedata ) {
     	try {
 			return ClassUtil.getMappedObject( m_markupParserClass, context, new StringReader( pagedata ) );
-		} catch( ReflectiveOperationException | IllegalArgumentException e ) {
+		} catch( final ReflectiveOperationException | IllegalArgumentException e ) {
 			log.error( "unable to get an instance of " + m_markupParserClass + " (" + e.getMessage() + "), returning default markup parser.", e );
 			return new JSPWikiMarkupParser( context, new StringReader( pagedata ) );
 		}
@@ -192,18 +184,17 @@ public class RenderingManager implements WikiEventListener, InternalModule
      * @param context the wiki context
      * @param pagedata the page data
      * @return the rendered wiki document
-     * @throws IOException If rendering cannot be accomplished
      */
     // FIXME: The cache management policy is not very good: deleted/changed pages should be detected better.
-    protected WikiDocument getRenderedDocument( WikiContext context, String pagedata ) throws IOException {
-        String pageid = context.getRealPage().getName() + VERSION_DELIMITER +
-                        context.getRealPage().getVersion() + VERSION_DELIMITER +
-                        context.getVariable( RenderingManager.VAR_EXECUTE_PLUGINS );
+    protected WikiDocument getRenderedDocument( final WikiContext context, final String pagedata ) {
+        final String pageid = context.getRealPage().getName() + VERSION_DELIMITER +
+                              context.getRealPage().getVersion() + VERSION_DELIMITER +
+                              context.getVariable( RenderingManager.VAR_EXECUTE_PLUGINS );
 
         if( useCache( context ) ) {
-            Element element = m_documentCache.get( pageid );
+            final Element element = m_documentCache.get( pageid );
             if ( element != null ) {
-                WikiDocument doc = (WikiDocument) element.getObjectValue();
+                final WikiDocument doc = ( WikiDocument )element.getObjectValue();
 
                 //
                 //  This check is needed in case the different filters have actually changed the page data.
@@ -220,48 +211,45 @@ public class RenderingManager implements WikiEventListener, InternalModule
         }
 
         //  Refresh the data content
-        //
         try {
-            MarkupParser parser = getParser( context, pagedata );
-            WikiDocument doc = parser.parse();
+            final MarkupParser parser = getParser( context, pagedata );
+            final WikiDocument doc = parser.parse();
             doc.setPageData( pagedata );
             if( useCache( context ) ) {
                 m_documentCache.put( new Element( pageid, doc ) );
             }
             return doc;
-        } catch( IOException ex ) {
+        } catch( final IOException ex ) {
             log.error( "Unable to parse", ex );
         }
 
         return null;
     }
 
-    boolean useCache( WikiContext context ) {
+    boolean useCache( final WikiContext context ) {
         return m_useCache && WikiContext.VIEW.equals( context.getRequestContext() );
     }
 
     /**
-     *  Simply renders a WikiDocument to a String.  This version does not get the document
-     *  from the cache - in fact, it does not cache the document at all.  This is
-     *  very useful, if you have something that you want to render outside the caching
-     *  routines.  Because the cache is based on full pages, and the cache keys are
-     *  based on names, use this routine if you're rendering anything for yourself.
+     *  Simply renders a WikiDocument to a String.  This version does not get the document from the cache - in fact, it does
+     *  not cache the document at all.  This is very useful, if you have something that you want to render outside the caching
+     *  routines.  Because the cache is based on full pages, and the cache keys are based on names, use this routine if you're
+     *  rendering anything for yourself.
      *
      *  @param context The WikiContext to render in
      *  @param doc A proper WikiDocument
      *  @return Rendered HTML.
      *  @throws IOException If the WikiDocument is poorly formed.
      */
-    public String getHTML( WikiContext context, WikiDocument doc ) throws IOException
-    {
+    public String getHTML( final WikiContext context, final WikiDocument doc ) throws IOException {
         final Boolean wysiwygVariable = ( Boolean )context.getVariable( WYSIWYG_EDITOR_MODE );
         final boolean wysiwygEditorMode;
         if( wysiwygVariable != null ) {
-            wysiwygEditorMode = wysiwygVariable.booleanValue();
+            wysiwygEditorMode = wysiwygVariable;
         } else {
             wysiwygEditorMode = false;
         }
-        WikiRenderer rend;
+        final WikiRenderer rend;
         if( wysiwygEditorMode ) {
             rend = getWysiwygRenderer( context, doc );
         } else {
@@ -272,15 +260,14 @@ public class RenderingManager implements WikiEventListener, InternalModule
     }
 
     /**
-     * Returns a WikiRenderer instance, initialized with the given
-     * context and doc. The object is an XHTMLRenderer, unless overridden
-     * in jspwiki.properties with PROP_RENDERER.
+     * Returns a WikiRenderer instance, initialized with the given context and doc. The object is an XHTMLRenderer,
+     * unless overridden in jspwiki.properties with PROP_RENDERER.
      *
      * @param context The WikiContext
      * @param doc The document to render
      * @return A WikiRenderer for this document, or null, if no such renderer could be instantiated.
      */
-    public WikiRenderer getRenderer( WikiContext context, WikiDocument doc ) {
+    public WikiRenderer getRenderer( final WikiContext context, final WikiDocument doc ) {
         final Object[] params = { context, doc };
         return getRenderer( params, m_rendererConstructor );
     }
@@ -292,47 +279,38 @@ public class RenderingManager implements WikiEventListener, InternalModule
      *
      * @param context The WikiContext
      * @param doc The document to render
-     * @return A WikiRenderer instance meant for WYSIWYG editing, for this document, or null, if
-     *         no such renderer could be instantiated.
+     * @return A WikiRenderer instance meant for WYSIWYG editing, for this document, or null, if no such renderer could be instantiated.
      */
-    public WikiRenderer getWysiwygRenderer( WikiContext context, WikiDocument doc ) {
+    public WikiRenderer getWysiwygRenderer( final WikiContext context, final WikiDocument doc ) {
         final Object[] params = { context, doc };
         return getRenderer( params, m_rendererWysiwygConstructor );
     }
 
     @SuppressWarnings("unchecked")
-    private < T extends WikiRenderer > T getRenderer( Object[] params, Constructor<?> rendererConstructor ) {
-        T rval = null;
-
+    private < T extends WikiRenderer > T getRenderer( final Object[] params, final Constructor<?> rendererConstructor ) {
         try {
-            rval = (T)rendererConstructor.newInstance( params );
+            return ( T )rendererConstructor.newInstance( params );
         } catch( final Exception e ) {
             log.error( "Unable to create WikiRenderer", e );
         }
-        return rval;
+        return null;
     }
 
     /**
-     *   Convenience method for rendering, using the default parser and renderer.  Note that
-     *   you can't use this method to do any arbitrary rendering, as the pagedata MUST
-     *   be the data from the that the WikiContext refers to - this method caches the HTML
-     *   internally, and will return the cached version.  If the pagedata is different
-     *   from what was cached, will re-render and store the pagedata into the internal cache.
+     *   Convenience method for rendering, using the default parser and renderer.  Note that you can't use this method
+     *   to do any arbitrary rendering, as the pagedata MUST be the data from the that the WikiContext refers to - this
+     *   method caches the HTML internally, and will return the cached version.  If the pagedata is different from what
+     *   was cached, will re-render and store the pagedata into the internal cache.
      *
      *   @param context the wiki context
      *   @param pagedata the page data
      *   @return XHTML data.
      */
-    public String getHTML( WikiContext context, String pagedata )
-    {
-        try
-        {
-            WikiDocument doc = getRenderedDocument( context, pagedata );
-
+    public String getHTML( final WikiContext context, final String pagedata ) {
+        try {
+            final WikiDocument doc = getRenderedDocument( context, pagedata );
             return getHTML( context, doc );
-        }
-        catch( IOException e )
-        {
+        } catch( final IOException e ) {
             log.error("Unable to parse",e);
         }
 
@@ -347,21 +325,21 @@ public class RenderingManager implements WikiEventListener, InternalModule
      * @see org.apache.wiki.event.WikiEventListener#actionPerformed(org.apache.wiki.event.WikiEvent)
      */
     @Override
-    public void actionPerformed( WikiEvent event ) {
+    public void actionPerformed( final WikiEvent event ) {
         log.debug( "event received: " + event.toString() );
         if( m_useCache ) {
             if( ( event instanceof WikiPageEvent ) && ( event.getType() == WikiPageEvent.POST_SAVE_BEGIN ) ) {
                 if( m_documentCache != null ) {
-                    String pageName = ( ( WikiPageEvent ) event ).getPageName();
+                    final String pageName = ( ( WikiPageEvent ) event ).getPageName();
                     m_documentCache.remove( pageName );
-                    Collection< String > referringPages = m_engine.getReferenceManager().findReferrers( pageName );
+                    final Collection< String > referringPages = m_engine.getReferenceManager().findReferrers( pageName );
 
                     //
                     //  Flush also those pages that refer to this page (if an nonexistent page
                     //  appears, we need to flush the HTML that refers to the now-existent page)
                     //
                     if( referringPages != null ) {
-                        for( String page : referringPages ) {
+                        for( final String page : referringPages ) {
                             if( log.isDebugEnabled() ) {
                                 log.debug( "Flushing latest version of " + page );
                             }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/WikiRenderer.java b/jspwiki-main/src/main/java/org/apache/wiki/render/WikiRenderer.java
index 209266b..0dae868 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/WikiRenderer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/WikiRenderer.java
@@ -18,22 +18,20 @@
  */
 package org.apache.wiki.render;
 
-import java.io.IOException;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.parser.WikiDocument;
 
+import java.io.IOException;
+
 /**
- *  Provides an interface to the basic rendering engine.
- *  This class is an abstract class instead of an interface because
- *  it is expected that rendering capabilities are increased at some
- *  point, and I would hate if renderers broke.  This class allows
- *  some sane defaults to be implemented.
+ *  Provides an interface to the basic rendering engine. This class is an abstract class instead of an interface because
+ *  it is expected that rendering capabilities are increased at some point, and I would hate if renderers broke.
+ *  This class allows some sane defaults to be implemented.
  *
  *  @since  2.4
  */
-public abstract class WikiRenderer
-{
+public abstract class WikiRenderer {
+
     protected WikiContext     m_context;
     protected WikiDocument    m_document;
 
@@ -46,8 +44,7 @@ public abstract class WikiRenderer
      *  @param context A WikiContext in which the rendering will take place.
      *  @param doc The WikiDocument which shall be rendered.
      */
-    protected WikiRenderer( WikiContext context, WikiDocument doc )
-    {
+    protected WikiRenderer( final WikiContext context, final WikiDocument doc ) {
         m_context = context;
         m_document = doc;
         doc.setContext( context ); // Make sure it is set
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/WysiwygEditingRenderer.java b/jspwiki-main/src/main/java/org/apache/wiki/render/WysiwygEditingRenderer.java
index cb915a7..bb65bc2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/WysiwygEditingRenderer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/WysiwygEditingRenderer.java
@@ -18,10 +18,6 @@
  */
 package org.apache.wiki.render;
 
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.Iterator;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.htmltowiki.XHtmlToWikiConfig;
 import org.apache.wiki.parser.MarkupParser;
@@ -31,19 +27,20 @@ import org.jdom2.Element;
 import org.jdom2.output.Format;
 import org.jdom2.output.XMLOutputter;
 
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Iterator;
+
 /**
- *  Implements a WikiRendered that outputs XHTML in a format that is suitable
- *  for use by a WYSIWYG XHTML editor.
+ *  Implements a WikiRenderer that outputs XHTML in a format that is suitable for use by a WYSIWYG XHTML editor.
  *
  *  @since  2.5
  */
-public class WysiwygEditingRenderer
-    extends WikiRenderer
-{
+public class WysiwygEditingRenderer extends WikiRenderer {
 
     private static final String A_ELEMENT = "a";
     private static final String IMG_ELEMENT = "img";
-//    private static final String PRE_ELEMENT = "pre";
+    // private static final String PRE_ELEMENT = "pre";
     private static final String CLASS_ATTRIBUTE = "class";
     private static final String HREF_ATTRIBUTE = "href";
     private static final String TITLE_ATTRIBUTE = "title";
@@ -55,7 +52,7 @@ public class WysiwygEditingRenderer
      *  @param context A WikiContext in which the rendering will take place.
      *  @param doc The WikiDocument which shall be rendered.
      */
-    public WysiwygEditingRenderer( WikiContext context, WikiDocument doc )
+    public WysiwygEditingRenderer( final WikiContext context, final WikiDocument doc )
     {
         super( context, doc );
     }
@@ -64,34 +61,27 @@ public class WysiwygEditingRenderer
      * Recursively walk the XHTML DOM tree and manipulate specific elements to
      * make them better for WYSIWYG editing.
      */
-    private void processChildren(Element baseElement)
-    {
-        for( Iterator< Element > itr = baseElement.getChildren().iterator(); itr.hasNext(); )
-        {
-            Element element = itr.next();
-            String elementName = element.getName().toLowerCase();
-            Attribute classAttr = element.getAttribute( CLASS_ATTRIBUTE );
-
-            if( elementName.equals( A_ELEMENT ) )
-            {
-                if( classAttr != null )
-                {
-                    String classValue = classAttr.getValue();
-                    Attribute hrefAttr = element.getAttribute( HREF_ATTRIBUTE );
-
-                    XHtmlToWikiConfig wikiConfig = new XHtmlToWikiConfig( m_context );
+    private void processChildren( final Element baseElement ) {
+        for( final Iterator< Element > itr = baseElement.getChildren().iterator(); itr.hasNext(); ) {
+            final Element element = itr.next();
+            final String elementName = element.getName().toLowerCase();
+            final Attribute classAttr = element.getAttribute( CLASS_ATTRIBUTE );
+
+            if( elementName.equals( A_ELEMENT ) ) {
+                if( classAttr != null ) {
+                    final String classValue = classAttr.getValue();
+                    final Attribute hrefAttr = element.getAttribute( HREF_ATTRIBUTE );
+                    final XHtmlToWikiConfig wikiConfig = new XHtmlToWikiConfig( m_context );
 
                     // Get the url for wiki page link - it's typically "Wiki.jsp?page=MyPage"
                     // or when using the ShortURLConstructor option, it's "wiki/MyPage" .
-                    String wikiPageLinkUrl = wikiConfig.getWikiJspPage();
-                    String editPageLinkUrl = wikiConfig.getEditJspPage();
+                    final String wikiPageLinkUrl = wikiConfig.getWikiJspPage();
+                    final String editPageLinkUrl = wikiConfig.getEditJspPage();
 
                     //if( classValue.equals( WIKIPAGE )
                     //    || ( hrefAttr != null && hrefAttr.getValue().startsWith( wikiPageLinkUrl ) ) )
                     if( //classValue.equals( WIKIPAGE ) &&
-                        ( hrefAttr != null )
-                    &&  ( hrefAttr.getValue().startsWith( wikiPageLinkUrl ) ) )
-                    {
+                        ( hrefAttr != null ) &&  ( hrefAttr.getValue().startsWith( wikiPageLinkUrl ) ) ) {
                         // Remove the leading url string so that users will only see the
                         // wikipage's name when editing an existing wiki link.
                         // For example, change "Wiki.jsp?page=MyPage" to just "MyPage".
@@ -106,15 +96,11 @@ public class WysiwygEditingRenderer
                         // to this wiki string: "TargetPage#Heading2".
                         hrefAttr.setValue( newHref.replaceFirst( LINKS_SOURCE, LINKS_TRANSLATION ) );
 
-                    }
-                    else if( //classValue.equals( EDITPAGE ) &&
-                            ( hrefAttr != null )
-                         && ( hrefAttr.getValue().startsWith( editPageLinkUrl ) ) )
-                    {
-
-                        Attribute titleAttr = element.getAttribute( TITLE_ATTRIBUTE );
-                        if( titleAttr != null )
-                        {
+                    } else if( //classValue.equals( EDITPAGE ) &&
+                            ( hrefAttr != null ) && ( hrefAttr.getValue().startsWith( editPageLinkUrl ) ) ) {
+
+                        final Attribute titleAttr = element.getAttribute( TITLE_ATTRIBUTE );
+                        if( titleAttr != null ) {
                                 // remove the title since we don't want to eventually save the default undefined page title.
                                 titleAttr.detach();
                         }
@@ -123,30 +109,20 @@ public class WysiwygEditingRenderer
                         newHref = m_context.getEngine().decodeName( newHref );
 
                         hrefAttr.setValue( newHref );
-                    }
-
-                    else if( classValue.equals( MarkupParser.HASHLINK ) )
-                    {
+                    } else if( classValue.equals( MarkupParser.HASHLINK ) ) {
                         itr.remove(); //remove element without disturbing the ongoing iteration
                         continue;  //take next iteration of the for loop
                     }
                 }
-            } // end of check for "a" element
-
-            else if ( elementName.equals( IMG_ELEMENT ) )
-            {
-                if( classAttr != null )
-                {
-                    String classValue = classAttr.getValue();
-
-                    if( classValue.equals( MarkupParser.OUTLINK ) )
-                    {
-                        itr.remove(); //remove element without disturbing the ongoing iteration
-                        continue; //take next iteration of the for loop
+            // end of check for "a" element
+            } else if ( elementName.equals( IMG_ELEMENT ) ) {
+                if( classAttr != null ) {
+                    final String classValue = classAttr.getValue();
+                    if( classValue.equals( MarkupParser.OUTLINK ) ) {
+                        itr.remove(); // remove element without disturbing the ongoing iteration
+                        continue; // take next iteration of the for loop
                     }
-
                 }
-
             }
 
             processChildren( element );
@@ -156,20 +132,16 @@ public class WysiwygEditingRenderer
     /**
      *  {@inheritDoc}
      */
-    public String getString()
-        throws IOException
-    {
-        Element rootElement = m_document.getRootElement();
+    public String getString() throws IOException {
+        final Element rootElement = m_document.getRootElement();
         processChildren( rootElement );
 
         m_document.setContext( m_context );
 
-        CustomXMLOutputProcessor processor = new CustomXMLOutputProcessor();
-        XMLOutputter output = new XMLOutputter(processor);
-
-        StringWriter out = new StringWriter();
-
-        Format fmt = Format.getRawFormat();
+        final CustomXMLOutputProcessor processor = new CustomXMLOutputProcessor();
+        final XMLOutputter output = new XMLOutputter(processor);
+        final StringWriter out = new StringWriter();
+        final Format fmt = Format.getRawFormat();
         fmt.setExpandEmptyElements( false );
         fmt.setLineSeparator( LINEBREAK );
 
@@ -178,4 +150,5 @@ public class WysiwygEditingRenderer
 
         return out.toString();
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/XHTMLRenderer.java b/jspwiki-main/src/main/java/org/apache/wiki/render/XHTMLRenderer.java
index b54fe02..49e6a4d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/XHTMLRenderer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/XHTMLRenderer.java
@@ -18,14 +18,13 @@
  */
 package org.apache.wiki.render;
 
-import java.io.IOException;
-import java.io.StringWriter;
-
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.parser.WikiDocument;
 import org.jdom2.output.Format;
 import org.jdom2.output.XMLOutputter;
 
-import org.apache.wiki.WikiContext;
-import org.apache.wiki.parser.WikiDocument;
+import java.io.IOException;
+import java.io.StringWriter;
 
 /**
  *  Implements a WikiRendered that outputs XHTML.  Because the internal DOM
@@ -34,9 +33,8 @@ import org.apache.wiki.parser.WikiDocument;
  *
  *  @since  2.4
  */
-public class XHTMLRenderer
-    extends WikiRenderer
-{
+public class XHTMLRenderer extends WikiRenderer {
+
     private static final String LINEBREAK = "\n";
 
     /**
@@ -45,7 +43,7 @@ public class XHTMLRenderer
      *  @param context A WikiContext in which the rendering will take place.
      *  @param doc The WikiDocument which shall be rendered.
      */
-    public XHTMLRenderer( WikiContext context, WikiDocument doc )
+    public XHTMLRenderer( final WikiContext context, final WikiDocument doc )
     {
         super( context, doc );
     }
@@ -53,24 +51,20 @@ public class XHTMLRenderer
     /**
      *  {@inheritDoc}
      */
-    public String getString()
-        throws IOException
-    {
+    public String getString() throws IOException {
         m_document.setContext( m_context );
 
-        CustomXMLOutputProcessor processor = new CustomXMLOutputProcessor();
-        XMLOutputter output = new XMLOutputter(processor);
-
-        StringWriter out = new StringWriter();
-
-        Format fmt = Format.getRawFormat();
+        final CustomXMLOutputProcessor processor = new CustomXMLOutputProcessor();
+        final XMLOutputter output = new XMLOutputter(processor);
+        final StringWriter out = new StringWriter();
+        final Format fmt = Format.getRawFormat();
         fmt.setExpandEmptyElements( false );
         fmt.setLineSeparator( LINEBREAK );
 
         output.setFormat( fmt );
         output.outputElementContent( m_document.getRootElement(), out );
 
-        String result = out.toString();
-        return result;
+        return out.toString();
     }
+
 }


[jspwiki] 18/18: 2.11.0-M7-git-03

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 9e05cc521a812ed781ac835307e45f34923119c4
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 00:29:43 2020 +0100

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

diff --git a/ChangeLog.md b/ChangeLog.md
index a8ee2dc..7f4dc83 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -17,6 +17,25 @@ specific language governing permissions and limitations
 under the License.
 -->
 
+**2020-01-03  Juan Pablo Santos (juanpablo AT apache DOT org)**
+
+* _2.11.0-M7-git-03_
+
+* [JSPWIKI-120](https://issues.apache.org/jira/browse/JSPWIKI-120): Separate rendering engine from core
+    * `ReferenceManager` renamed + moved to `org.apache.wiki.references.DefaultReferenceManager`, with new 
+    `org.apache.wiki.references.ReferenceManager` extracted as interface of the latter
+    * `scanWikiLinks(..)` and `updateReferences(..)` methods from `WikiEngine` moved to `ReferenceManager`
+* `WikiDifferenceManager`, `WikiVariableManager` and `WikiPageRenamer` renamed to `DefaultDifferenceManager`, `DefaultVariableManager` 
+  and `DefaultPageRenamer` respectively; it's a better suited prefix for default implementations and also follows the existing naming
+  with the existing bunch of `Default[XYZ]Manager` that currently exist
+* Moved `[Default]VariableManager` to their own package under `org.apache.wiki.variables`
+* Dependency updates
+    * Flexmark to 0.50.46
+    * Lucene to 8.4.0
+    * Selenide to 5.6.0
+    * Tomcat to 8.5.50
+* Applied format & fixes suggested by intellij to a big bunch of files
+
 **2019-12-20  Juan Pablo Santos (juanpablo AT apache DOT org)**
 
 * _2.11.0-M7-git-02_
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 8aaa884..1a295a3 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-02";
+    public static final String     BUILD         = "git-03";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of


[jspwiki] 02/18: static final logger on WikiVariableManager

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 7c9958c3fcbcece3a45a78d2ba44bf65a2c1001c
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 1 20:09:02 2020 +0100

    static final logger on WikiVariableManager
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiVariableManager.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiVariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiVariableManager.java
index 5408e9b..fad2226 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiVariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiVariableManager.java
@@ -44,7 +44,7 @@ import java.util.ResourceBundle;
  */
 public class WikiVariableManager implements VariableManager {
 
-    private static Logger log = Logger.getLogger( WikiVariableManager.class );
+    private static final Logger log = Logger.getLogger( WikiVariableManager.class );
 
     /**
      *  Contains a list of those properties that shall never be shown. Put names here in lower case.


[jspwiki] 14/18: setUp method not really needed on DefaultFilterManagerTest

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 d35a181ae9404b02f71d1dd46186d9d3a5dfc5e1
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 00:04:39 2020 +0100

    setUp method not really needed on DefaultFilterManagerTest
---
 .../wiki/filters/DefaultFilterManagerTest.java       | 20 ++++++--------------
 1 file changed, 6 insertions(+), 14 deletions(-)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/filters/DefaultFilterManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/filters/DefaultFilterManagerTest.java
index ff3d72e..91b665b 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/filters/DefaultFilterManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/filters/DefaultFilterManagerTest.java
@@ -18,28 +18,20 @@
  */
 
 package org.apache.wiki.filters;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.log4j.PropertyConfigurator;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.filters.PageFilter;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
-public class DefaultFilterManagerTest {
-    Properties props = TestEngine.getTestProperties();
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
 
-    TestEngine engine;
+public class DefaultFilterManagerTest {
 
-    @BeforeEach
-    public void setUp() throws Exception {
-        PropertyConfigurator.configure(props);
-        engine = new TestEngine(props);
-    }
+    Properties props = TestEngine.getTestProperties();
+    TestEngine engine = TestEngine.build();
 
     @Test
     public void testInitFilters() throws Exception {


[jspwiki] 11/18: add some missing package.html files

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 93ecf13a19db2bc0b39ab4874d635bd1fbf01002
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 2 16:39:53 2020 +0100

    add some missing package.html files
---
 .../main/java/org/apache/wiki/render/package.html  | 34 ++++++++++++++++++++++
 .../java/org/apache/wiki/rpc/atom/package.html     | 34 ++++++++++++++++++++++
 .../src/main/java/org/apache/wiki/rss/package.html | 34 ++++++++++++++++++++++
 3 files changed, 102 insertions(+)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/package.html b/jspwiki-main/src/main/java/org/apache/wiki/render/package.html
new file mode 100644
index 0000000..abf3af1
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/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.render</title>
+</head>
+<body>
+Provides the JSPWiki rendering functionality.
+
+<h3>Package Specification</h3>
+
+<h3>Related Documentation</h3>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/package.html b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/package.html
new file mode 100644
index 0000000..c4f99c8
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/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.rpc.atom</title>
+</head>
+<body>
+Provides the JSPWiki ATOM API functionality.
+
+<h3>Package Specification</h3>
+
+<h3>Related Documentation</h3>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/package.html b/jspwiki-main/src/main/java/org/apache/wiki/rss/package.html
new file mode 100644
index 0000000..4286b51
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/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.rss</title>
+</head>
+<body>
+Provides the JSPWiki RSS feeds functionality.
+
+<h3>Package Specification</h3>
+
+<h3>Related Documentation</h3>
+
+</body>
+</html>
\ No newline at end of file


[jspwiki] 09/18: JSPWIKI-120: move ReferenceManager to its own package, as DefaultReferenceManager; extract there new ReferenceManager interface from it

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ab8d3d47484b87fef6cce906d6030c4d70fd62d5
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Jan 2 16:38:28 2020 +0100

    JSPWIKI-120: move ReferenceManager to its own package, as DefaultReferenceManager; extract there new ReferenceManager interface from it
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  23 +--
 .../DefaultReferenceManager.java}                  |  18 ++-
 .../apache/wiki/references/ReferenceManager.java   | 171 +++++++++++++++++++++
 .../java/org/apache/wiki/references/package.html   |  34 ++++
 .../src/main/resources/ini/classmappings.xml       |   8 +-
 .../test/java/org/apache/wiki/WikiEngineTest.java  |   1 +
 .../{ => references}/ReferenceManagerTest.java     |  14 +-
 7 files changed, 238 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 5d0a7d2..227ec74 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -47,6 +47,7 @@ import org.apache.wiki.pages.PageTimeComparator;
 import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.parser.WikiDocument;
 import org.apache.wiki.providers.WikiPageProvider;
+import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.rss.RSSGenerator;
 import org.apache.wiki.rss.RSSThread;
@@ -148,9 +149,7 @@ public class WikiEngine  {
     Double negative, cause for most servers you don't need the property */
     public static final String PROP_NO_FILTER_ENCODING     = "jspwiki.nofilterencoding";
 
-    /** The name for the property which allows you to set the current reference
-     *  style.  The value is {@value}.
-     */
+    /** The name for the property which allows you to set the current reference style.  The value is {@value}. */
     public static final String PROP_REFSTYLE     = "jspwiki.referenceStyle";
 
     /** Property name for the "spaces in titles" -hack. */
@@ -173,7 +172,6 @@ public class WikiEngine  {
     public static final String PROP_FRONTPAGE    = "jspwiki.frontPage";
 
     /** Property name for setting the url generator instance */
-
     public static final String PROP_URLCONSTRUCTOR = "jspwiki.urlConstructor";
 
     /** If this property is set to false, all filters are disabled when translating. */
@@ -182,22 +180,20 @@ public class WikiEngine  {
     /** Does the work in renaming pages. */
     private PageRenamer    m_pageRenamer = null;
 
-    /** The name of the property containing the ACLManager implementing class.
-     *  The value is {@value}. */
+    /** The name of the property containing the ACLManager implementing class. The value is {@value}. */
     public static final String PROP_ACL_MANAGER_IMPL = "jspwiki.aclManager";
 
     /** If this property is set to false, we don't allow the creation of empty pages */
     public static final String PROP_ALLOW_CREATION_OF_EMPTY_PAGES = "jspwiki.allowCreationOfEmptyPages";
 
     /** Should the user info be saved with the page data as well? */
-    private boolean          m_saveUserInfo = true;
+    private boolean m_saveUserInfo = true;
 
     /** If true, uses UTF8 encoding for all data */
-    private boolean          m_useUTF8      = true;
+    private boolean m_useUTF8 = true;
 
-    /** Store the file path to the basic URL.  When we're not running as
-        a servlet, it defaults to the user's current directory. */
-    private String           m_rootPath = System.getProperty("user.dir");
+    /** Store the file path to the basic URL.  When we're not running as a servlet, it defaults to the user's current directory. */
+    private String m_rootPath = System.getProperty("user.dir");
 
     /** Stores references between wikipages. */
     private ReferenceManager m_referenceManager = null;
@@ -303,13 +299,10 @@ public class WikiEngine  {
      *  @param config The ServletConfig object for this servlet.
      *
      *  @return A WikiEngine instance.
-     *  @throws InternalWikiException in case something fails.  This
-     *          is a RuntimeException, so be prepared for it.
+     *  @throws InternalWikiException in case something fails.  This is a RuntimeException, so be prepared for it.
      */
-
     // FIXME: It seems that this does not work too well, jspInit()
     // does not react to RuntimeExceptions, or something...
-
     public static synchronized WikiEngine getInstance( ServletConfig config )
         throws InternalWikiException
     {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java
similarity index 98%
rename from jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java
rename to jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java
index ea09f2d..3360c9a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java
@@ -16,18 +16,22 @@
     specific language governing permissions and limitations
     under the License.
  */
-package org.apache.wiki;
+package org.apache.wiki.references;
 
 import org.apache.commons.lang3.time.StopWatch;
 import org.apache.log4j.Logger;
+import org.apache.wiki.InternalWikiException;
+import org.apache.wiki.LinkCollector;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.event.WikiEvent;
-import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventUtils;
 import org.apache.wiki.event.WikiPageEvent;
-import org.apache.wiki.modules.InternalModule;
 import org.apache.wiki.providers.WikiPageProvider;
 import org.apache.wiki.util.TextUtil;
 
@@ -106,13 +110,13 @@ import java.util.TreeSet;
  *  The owning class must take responsibility of filling in any pre-existing information, probably by loading each and every WikiPage
  *  and calling this class to update the references when created.
  *
- *  @since 1.6.1
+ *  @since 1.6.1 (as of 2.11.0, moved to org.apache.wiki.references)
  */
 
 // FIXME: The way that we save attributes is now a major booboo, and must be
 //        replace forthwith.  However, this is a workaround for the great deal
 //        of problems that occur here...
-public class ReferenceManager extends BasicPageFilter implements InternalModule, WikiEventListener {
+public class DefaultReferenceManager extends BasicPageFilter implements ReferenceManager {
 
     /**
      *  Maps page wikiname to a Collection of pages it refers to. The Collection must contain Strings. The Collection may contain
@@ -130,7 +134,7 @@ public class ReferenceManager extends BasicPageFilter implements InternalModule,
 
     private boolean m_matchEnglishPlurals;
 
-    private static final Logger log = Logger.getLogger(ReferenceManager.class);
+    private static final Logger log = Logger.getLogger( DefaultReferenceManager.class);
     private static final String SERIALIZATION_FILE = "refmgr.ser";
     private static final String SERIALIZATION_DIR  = "refmgr-attr";
 
@@ -142,7 +146,7 @@ public class ReferenceManager extends BasicPageFilter implements InternalModule,
      *
      *  @param engine The WikiEngine to which this is managing references to.
      */
-    public ReferenceManager( final WikiEngine engine ) {
+    public DefaultReferenceManager( final WikiEngine engine ) {
         m_refersTo = new HashMap<>();
         m_referredBy = new HashMap<>();
         m_engine = engine;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/references/ReferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/references/ReferenceManager.java
new file mode 100644
index 0000000..5e97420
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/references/ReferenceManager.java
@@ -0,0 +1,171 @@
+/*
+    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.references;
+
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.exceptions.ProviderException;
+import org.apache.wiki.api.filters.PageFilter;
+import org.apache.wiki.event.WikiEventListener;
+import org.apache.wiki.modules.InternalModule;
+
+import java.util.Collection;
+import java.util.Set;
+
+/**
+ *  Keeps track of wikipage references:
+ *  <ul>
+ *  <li>What pages a given page refers to</li>
+ *  <li>What pages refer to a given page</li>
+ *  </ul>
+ *
+ *  When a page is added or edited, its references are parsed, a Collection is received, and we crudely replace anything previous with
+ *  this new Collection. We then check each referenced page name and make sure they know they are referred to by the new page.
+ *  <p>
+ *  Based on this information, we can perform non-optimal searches for e.g. unreferenced pages, top ten lists, etc.
+ *  <p>
+ *  The owning class must take responsibility of filling in any pre-existing information, probably by loading each and every WikiPage
+ *  and calling this class to update the references when created.
+ */
+public interface ReferenceManager extends PageFilter, InternalModule, WikiEventListener {
+
+    /**
+     *  Initializes the entire reference manager with the initial set of pages from the collection.
+     *
+     *  @param pages A collection of all pages you want to be included in the reference count.
+     *  @since 2.2
+     *  @throws ProviderException If reading of pages fails.
+     */
+    void initialize( final Collection<WikiPage> pages ) throws ProviderException;
+
+    /**
+     *  Reads a WikiPageful of data from a String and returns all links internal to this Wiki in a Collection.
+     *
+     *  @param page The WikiPage to scan
+     *  @param pagedata The page contents
+     *  @return a Collection of Strings
+     */
+    Collection< String > scanWikiLinks( final WikiPage page, final String pagedata );
+
+    /**
+     * Updates the m_referedTo and m_referredBy hashmaps when a page has been deleted.
+     * <P>
+     * Within the m_refersTo map the pagename is a key. The whole key-value-set has to be removed to keep the map clean.
+     * Within the m_referredBy map the name is stored as a value. Since a key can have more than one value we have to
+     * delete just the key-value-pair referring page:deleted page.
+     *
+     *  @param page Name of the page to remove from the maps.
+     */
+    void pageRemoved( final WikiPage page );
+
+    /**
+     *  Updates all references for the given page.
+     *
+     *  @param page wiki page for which references should be updated
+     */
+    void updateReferences( final WikiPage page );
+
+    /**
+     *  Updates the referred pages of a new or edited WikiPage. If a refersTo entry for this page already exists, it is removed
+     *  and a new one is built from scratch. Also calls updateReferredBy() for each referenced page.
+     *  <P>
+     *  This is the method to call when a new page has been created and we want to a) set up its references and b) notify the
+     *  referred pages of the references. Use this method during run-time.
+     *
+     *  @param page Name of the page to update.
+     *  @param references A Collection of Strings, each one pointing to a page this page references.
+     */
+    void updateReferences( final String page, final Collection<String> references );
+
+    /**
+     * Clears the references to a certain page so it's no longer in the map.
+     *
+     * @param pagename  Name of the page to clear references for.
+     */
+    void clearPageEntries( String pagename );
+
+
+    /**
+     *  Finds all unreferenced pages. This requires a linear scan through m_referredBy to locate keys with null or empty values.
+     *
+     *  @return The Collection of Strings
+     */
+    Collection< String > findUnreferenced();
+
+    /**
+     * Finds all references to non-existant pages. This requires a linear scan through m_refersTo values; each value
+     * must have a corresponding key entry in the reference Maps, otherwise such a page has never been created.
+     * <P>
+     * Returns a Collection containing Strings of unreferenced page names. Each non-existant page name is shown only
+     * once - we don't return information on who referred to it.
+     *
+     * @return A Collection of Strings
+     */
+    Collection< String > findUncreated();
+
+    /**
+     * Find all pages that refer to this page. Returns null if the page does not exist or is not referenced at all,
+     * otherwise returns a collection containing page names (String) that refer to this one.
+     * <p>
+     * @param pagename The page to find referrers for.
+     * @return A Set of Strings.  May return null, if the page does not exist, or if it has no references.
+     */
+    Set< String > findReferrers( String pagename );
+
+    /**
+     *  Returns all pages that refer to this page.  Note that this method returns an unmodifiable Map, which may be abruptly changed.
+     *  So any access to any iterator may result in a ConcurrentModificationException.
+     *  <p>
+     *  The advantages of using this method over findReferrers() is that it is very fast, as it does not create a new object.
+     *  The disadvantages are that it does not do any mapping between plural names, and you may end up getting a
+     *  ConcurrentModificationException.
+     *
+     * @param pageName Page name to query.
+     * @return A Set of Strings containing the names of all the pages that refer to this page.  May return null, if the page does
+     *         not exist or has not been indexed yet.
+     * @since 2.2.33
+     */
+    Set< String > findReferredBy( String pageName );
+
+    /**
+     *  Returns all pages that this page refers to.  You can use this as a quick way of getting the links from a page, but note
+     *  that it does not link any InterWiki, image, or external links.  It does contain attachments, though.
+     *  <p>
+     *  The Collection returned is unmutable, so you cannot change it.  It does reflect the current status and thus is a live
+     *  object.  So, if you are using any kind of an iterator on it, be prepared for ConcurrentModificationExceptions.
+     *  <p>
+     *  The returned value is a Collection, because a page may refer to another page multiple times.
+     *
+     * @param pageName Page name to query
+     * @return A Collection of Strings containing the names of the pages that this page refers to. May return null, if the page
+     *         does not exist or has not been indexed yet.
+     * @since 2.2.33
+     */
+    Collection< String > findRefersTo( String pageName );
+
+    /**
+     *  Returns a list of all pages that the ReferenceManager knows about. This should be roughly equivalent to
+     *  PageManager.getAllPages(), but without the potential disk access overhead.  Note that this method is not guaranteed
+     *  to return a Set of really all pages (especially during startup), but it is very fast.
+     *
+     *  @return A Set of all defined page names that ReferenceManager knows about.
+     *  @since 2.3.24
+     */
+    Set< String > findCreated();
+
+}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/references/package.html b/jspwiki-main/src/main/java/org/apache/wiki/references/package.html
new file mode 100644
index 0000000..61ac2e8
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/references/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.references</title>
+</head>
+<body>
+Provides the JSPWiki track of pages' references.
+
+<h3>Package Specification</h3>
+
+<h3>Related Documentation</h3>
+
+</body>
+</html>
\ No newline at end of file
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index 7a2ca54..dbd3cdb 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -52,10 +52,6 @@
     <mappedClass>org.apache.wiki.pages.DefaultPageManager</mappedClass>
   </mapping>
   <mapping>
-    <requestedClass>org.apache.wiki.ReferenceManager</requestedClass>
-    <mappedClass>org.apache.wiki.ReferenceManager</mappedClass>
-  </mapping>
-  <mapping>
     <requestedClass>org.apache.wiki.VariableManager</requestedClass>
     <mappedClass>org.apache.wiki.WikiVariableManager</mappedClass>
   </mapping>
@@ -108,6 +104,10 @@
     <mappedClass>org.apache.wiki.i18n.InternationalizationManager</mappedClass>
   </mapping>
   <mapping>
+    <requestedClass>org.apache.wiki.references.ReferenceManager</requestedClass>
+    <mappedClass>org.apache.wiki.references.DefaultReferenceManager</mappedClass>
+  </mapping>
+  <mapping>
     <requestedClass>org.apache.wiki.render.RenderingManager</requestedClass>
     <mappedClass>org.apache.wiki.render.RenderingManager</mappedClass>
   </mapping>
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 6f7f9c8..6bbddce 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -27,6 +27,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.references.ReferenceManager;
 import org.apache.wiki.util.TextUtil;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ReferenceManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/references/ReferenceManagerTest.java
similarity index 96%
rename from jspwiki-main/src/test/java/org/apache/wiki/ReferenceManagerTest.java
rename to jspwiki-main/src/test/java/org/apache/wiki/references/ReferenceManagerTest.java
index 80d7e6a..ff58d40 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/ReferenceManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/references/ReferenceManagerTest.java
@@ -11,8 +11,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.wiki;
+package org.apache.wiki.references;
 import net.sf.ehcache.CacheManager;
+import org.apache.wiki.TestEngine;
+import org.apache.wiki.Util;
+import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
@@ -325,14 +328,15 @@ public class ReferenceManagerTest  {
      * with one user, one WikiEngine only.
      */
     public static String dumpReferenceManager( final ReferenceManager rm ) {
+        final DefaultReferenceManager drm = ( DefaultReferenceManager )rm;
     	final StringBuilder buf = new StringBuilder();
         try {
             buf.append( "================================================================\n" );
             buf.append( "Referred By list:\n" );
-            Set< String > keys = rm.getReferredBy().keySet();
+            Set< String > keys = drm.getReferredBy().keySet();
             for( final String key : keys ) {
                 buf.append( key ).append( " referred by: " );
-                final Set< String > refs = rm.getReferredBy().get( key );
+                final Set< String > refs = drm.getReferredBy().get( key );
                 for( final String aRef : refs ) {
                     buf.append( aRef ).append( " " );
                 }
@@ -342,10 +346,10 @@ public class ReferenceManagerTest  {
 
             buf.append( "----------------------------------------------------------------\n" );
             buf.append( "Refers To list:\n" );
-            keys = rm.getRefersTo().keySet();
+            keys = drm.getRefersTo().keySet();
             for( final String key : keys ) {
                 buf.append( key ).append( " refers to: " );
-                final Collection< String > refs = rm.getRefersTo().get( key );
+                final Collection< String > refs = drm.getRefersTo().get( key );
                 if(refs != null) {
                     for( final String aRef : refs ) {
                         buf.append( aRef ).append( " " );


[jspwiki] 06/18: p can't be null here, as an NPE would've raised on the call to m_engine.getReferenceManager().updateReferences( p );

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 f6825505d7ca47df6c788d9dc1d880d2a5a1ac4f
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 1 21:09:56 2020 +0100

    p can't be null here, as an NPE would've raised on the call to m_engine.getReferenceManager().updateReferences( p );
---
 .../org/apache/wiki/pages/DefaultPageManager.java  | 40 ++++++++--------------
 1 file changed, 15 insertions(+), 25 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 3d5245a..c1d9c16 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
@@ -95,11 +95,11 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * @throws NoSuchElementException {@value #PROP_PAGEPROVIDER} property not found on WikiEngine properties
      * @throws WikiException If anything goes wrong, you get this.
      */
-    public DefaultPageManager(WikiEngine engine, Properties props) throws NoSuchElementException, WikiException {
+    public DefaultPageManager(final WikiEngine engine, final Properties props) throws NoSuchElementException, WikiException {
         super(engine);
-        String classname;
+        final String classname;
         m_engine = engine;
-        boolean useCache = "true".equals(props.getProperty(PROP_USECACHE));
+        final boolean useCache = "true".equals(props.getProperty(PROP_USECACHE));
 
         m_expiryTime = TextUtil.parseIntParameter(props.getProperty(PROP_LOCKEXPIRY), 60);
 
@@ -116,24 +116,24 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
 
         try {
             LOG.debug("Page provider class: '" + classname + "'");
-            Class<?> providerclass = ClassUtil.findClass("org.apache.wiki.providers", classname);
+            final Class<?> providerclass = ClassUtil.findClass("org.apache.wiki.providers", classname);
             m_provider = (WikiPageProvider) providerclass.newInstance();
 
             LOG.debug("Initializing page provider class " + m_provider);
             m_provider.initialize(m_engine, props);
-        } catch (ClassNotFoundException e) {
+        } catch (final ClassNotFoundException e) {
             LOG.error("Unable to locate provider class '" + classname + "' (" + e.getMessage() + ")", e);
             throw new WikiException("No provider class. (" + e.getMessage() + ")", e);
-        } catch (InstantiationException e) {
+        } catch (final InstantiationException e) {
             LOG.error("Unable to create provider class '" + classname + "' (" + e.getMessage() + ")", e);
             throw new WikiException("Faulty provider class. (" + e.getMessage() + ")", e);
-        } catch (IllegalAccessException e) {
+        } catch (final IllegalAccessException e) {
             LOG.error("Illegal access to provider class '" + classname + "' (" + e.getMessage() + ")", e);
             throw new WikiException("Illegal provider class. (" + e.getMessage() + ")", e);
-        } catch (NoRequiredPropertyException e) {
+        } catch (final NoRequiredPropertyException e) {
             LOG.error("Provider did not found a property it was looking for: " + e.getMessage(), e);
             throw e;  // Same exception works.
-        } catch (IOException e) {
+        } catch (final IOException e) {
             LOG.error("An I/O exception occurred while trying to create a new page provider: " + classname, e);
             throw new WikiException("Unable to start page provider: " + e.getMessage(), e);
         }
@@ -164,30 +164,20 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         if (pageName == null || pageName.length() == 0) {
             throw new ProviderException("Illegal page name");
         }
-        String text = null;
+        String text;
 
         try {
             text = m_provider.getPageText(pageName, version);
-        } catch (final RepositoryModifiedException e) {
+        } catch ( final RepositoryModifiedException e ) {
             //  This only occurs with the latest version.
-            LOG.info("Repository has been modified externally while fetching page " + pageName);
+            LOG.info( "Repository has been modified externally while fetching page " + pageName );
 
             //  Empty the references and yay, it shall be recalculated
-            final WikiPage p = m_provider.getPageInfo(pageName, version);
+            final WikiPage p = m_provider.getPageInfo( pageName, version );
 
             m_engine.getReferenceManager().updateReferences( p );
-
-            if (p != null) {
-                m_engine.getSearchManager().reindexPage(p);
-                text = m_provider.getPageText(pageName, version);
-            } else {
-                //
-                //  Make sure that it no longer exists in internal data structures either.
-                //
-                final WikiPage dummy = new WikiPage(m_engine, pageName);
-                m_engine.getSearchManager().pageRemoved(dummy);
-                m_engine.getReferenceManager().pageRemoved(dummy);
-            }
+            m_engine.getSearchManager().reindexPage( p );
+            text = m_provider.getPageText( pageName, version );
         }
 
         return text;


[jspwiki] 07/18: * Dependency updates

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 fa2b64d666be37cd2d416a588a0daad7ff18f6ae
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 1 22:43:43 2020 +0100

    * Dependency updates
    
        * Flexmark to 0.50.46
        * Lucene to 8.4.0
        * Selenide to 5.6.0
        * Tomcat to 8.5.50
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 972277e..d28be99 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,7 @@
     <commons-lang.version>3.9</commons-lang.version>
     <commons-text.version>1.8</commons-text.version>
     <ehcache.version>2.10.6</ehcache.version>
-    <flexmark.version>0.50.44</flexmark.version>
+    <flexmark.version>0.50.46</flexmark.version>
     <freshcookies-security.version>0.60</freshcookies-security.version>
     <gson.version>2.8.5</gson.version>
     <hsqldb.version>2.5.0</hsqldb.version>
@@ -65,15 +65,15 @@
     <jrcs-diff.version>0.4.2</jrcs-diff.version>
     <junit.version>5.5.2</junit.version>
     <log4j.version>1.2.17</log4j.version>
-    <lucene.version>8.3.1</lucene.version>
+    <lucene.version>8.4.0</lucene.version>
     <nekohtml.version>1.9.22</nekohtml.version>
     <oro.version>2.0.8</oro.version>
     <sandler.version>0.5</sandler.version>
-    <selenide.version>5.5.1</selenide.version>
+    <selenide.version>5.6.0</selenide.version>
     <slf4j.version>1.7.29</slf4j.version>
     <stripes.version>1.7.0-async-beta</stripes.version>
     <tika.version>1.23</tika.version>
-    <tomcat.version>8.5.49</tomcat.version>
+    <tomcat.version>8.5.50</tomcat.version>
     <wro4j.version>1.8.0</wro4j.version>
     <xmlrpc.version>2.0.1</xmlrpc.version>
 


[jspwiki] 15/18: renamed WikiPageRenamer to DefaultPageRenamer

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 fa2ab40be1829e196b9cd92be929fe7e07ce8933
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 00:06:38 2020 +0100

    renamed WikiPageRenamer to DefaultPageRenamer
---
 .../wiki/content/{WikiPageRenamer.java => DefaultPageRenamer.java}    | 4 ++--
 jspwiki-main/src/main/resources/ini/classmappings.xml                 | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/content/WikiPageRenamer.java b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
similarity index 99%
rename from jspwiki-main/src/main/java/org/apache/wiki/content/WikiPageRenamer.java
rename to jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
index 5eed7be..21f6204 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/content/WikiPageRenamer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
@@ -46,9 +46,9 @@ import java.util.regex.Pattern;
  *
  * @since 2.8
  */
-public class WikiPageRenamer implements PageRenamer {
+public class DefaultPageRenamer implements PageRenamer {
 
-    private static final Logger log = Logger.getLogger( WikiPageRenamer.class );
+    private static final Logger log = Logger.getLogger( DefaultPageRenamer.class );
     
     private boolean m_camelCase = false;
     
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index f7c2628..192a1ea 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -89,7 +89,7 @@
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.content.PageRenamer</requestedClass>
-    <mappedClass>org.apache.wiki.content.WikiPageRenamer</mappedClass>
+    <mappedClass>org.apache.wiki.content.DefaultPageRenamer</mappedClass>
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.diff.DifferenceManager</requestedClass>


[jspwiki] 04/18: intellij format + fixes

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 c5ef842c54c262c9ef1dd63b0ba04feefa9f4aa2
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 1 20:11:11 2020 +0100

    intellij format + fixes
---
 .../java/org/apache/wiki/ReferenceManager.java     | 875 +++++++--------------
 1 file changed, 304 insertions(+), 571 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java
index 0939371..cc46816 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ReferenceManager.java
@@ -49,7 +49,6 @@ import java.util.Collections;
 import java.util.ConcurrentModificationException;
 import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -58,14 +57,12 @@ import java.util.TreeSet;
 /*
   BUGS
 
-  - if a wikilink is added to a page, then removed, RefMan still thinks that
-    the page refers to the wikilink page. Hm.
+  - if a wikilink is added to a page, then removed, RefMan still thinks that the page refers to the wikilink page. Hm.
 
   - if a page is deleted, gets very confused.
 
-  - Serialization causes page attributes to be missing, when InitializablePlugins
-    are not executed properly.  Thus, serialization should really also mark whether
-    a page is serializable or not...
+  - Serialization causes page attributes to be missing, when InitializablePlugins are not executed properly.  Thus,
+    serialization should really also mark whether a page is serializable or not...
  */
 
 
@@ -75,19 +72,14 @@ import java.util.TreeSet;
    I expect this object to be accessed in three situations:
    - when a WikiEngine is created and it scans its wikipages
    - when the WE saves a page
-   - when a JSP page accesses one of the WE's ReferenceManagers
-     to display a list of (un)referenced pages.
-
-   So, access to this class is fairly rare, and usually triggered by
-   user interaction. OTOH, the methods in this class use their storage
-   objects intensively (and, sorry to say, in an unoptimized manner =).
-   My deduction: using unsynchronized HashMaps etc and syncing methods
-   or code blocks is preferrable to using slow, synced storage objects.
-   We don't have iterative code here, so I'm going to use synced methods
-   for now.
-
-   Please contact me if you notice problems with ReferenceManager, and
-   especially with synchronization, or if you have suggestions about
+   - when a JSP page accesses one of the WE's ReferenceManagers to display a list of (un)referenced pages.
+
+   So, access to this class is fairly rare, and usually triggered by user interaction. OTOH, the methods in this class use their storage
+   objects intensively (and, sorry to say, in an unoptimized manner =). My deduction: using unsynchronized HashMaps etc and syncing methods
+   or code blocks is preferrable to using slow, synced storage objects. We don't have iterative code here, so I'm going to use synced
+   methods for now.
+
+   Please contact me if you notice problems with ReferenceManager, and especially with synchronization, or if you have suggestions about
    syncing.
 
    ebu@memecry.net
@@ -100,27 +92,19 @@ import java.util.TreeSet;
  *  <LI>What pages refer to a given page
  *  </UL>
  *
- *  This is a quick'n'dirty approach without any finesse in storage and
- *  searching algorithms; we trust java.util.*.
+ *  This is a quick'n'dirty approach without any finesse in storage and searching algorithms; we trust java.util.*.
  *  <P>
- *  This class contains two HashMaps, m_refersTo and m_referredBy. The
- *  first is indexed by WikiPage names and contains a Collection of all
- *  WikiPages the page refers to. (Multiple references are not counted,
- *  naturally.) The second is indexed by WikiPage names and contains
- *  a Set of all pages that refer to the indexing page. (Notice -
- *  the keys of both Maps should be kept in sync.)
+ *  This class contains two HashMaps, m_refersTo and m_referredBy. The first is indexed by WikiPage names and contains a Collection of all
+ *  WikiPages the page refers to. (Multiple references are not counted, naturally.) The second is indexed by WikiPage names and contains
+ *  a Set of all pages that refer to the indexing page. (Notice - the keys of both Maps should be kept in sync.)
  *  <P>
- *  When a page is added or edited, its references are parsed, a Collection
- *  is received, and we crudely replace anything previous with this new
- *  Collection. We then check each referenced page name and make sure they
- *  know they are referred to by the new page.
+ *  When a page is added or edited, its references are parsed, a Collection is received, and we crudely replace anything previous with
+ *  this new Collection. We then check each referenced page name and make sure they know they are referred to by the new page.
  *  <P>
- *  Based on this information, we can perform non-optimal searches for
- *  e.g. unreferenced pages, top ten lists, etc.
+ *  Based on this information, we can perform non-optimal searches for e.g. unreferenced pages, top ten lists, etc.
  *  <P>
- *  The owning class must take responsibility of filling in any pre-existing
- *  information, probably by loading each and every WikiPage and calling this
- *  class to update the references when created.
+ *  The owning class must take responsibility of filling in any pre-existing information, probably by loading each and every WikiPage
+ *  and calling this class to update the references when created.
  *
  *  @since 1.6.1
  */
@@ -128,32 +112,25 @@ import java.util.TreeSet;
 // FIXME: The way that we save attributes is now a major booboo, and must be
 //        replace forthwith.  However, this is a workaround for the great deal
 //        of problems that occur here...
+public class ReferenceManager extends BasicPageFilter implements InternalModule, WikiEventListener {
 
-public class ReferenceManager
-    extends BasicPageFilter
-    implements InternalModule, WikiEventListener
-{
-    /** Maps page wikiname to a Collection of pages it refers to. The Collection
-     *  must contain Strings. The Collection may contain names of non-existing
-     *  pages.
+    /**
+     *  Maps page wikiname to a Collection of pages it refers to. The Collection must contain Strings. The Collection may contain
+     *  names of non-existing pages.
      */
-    private Map<String,Collection<String>> m_refersTo;
-    private Map<String,Collection<String>> m_unmutableRefersTo;
+    private Map< String, Collection< String > > m_refersTo;
+    private Map< String, Collection< String > > m_unmutableRefersTo;
 
-    /** Maps page wikiname to a Set of referring pages. The Set must
-     *  contain Strings. Non-existing pages (a reference exists, but not a file
-     *  for the page contents) may have an empty Set in m_referredBy.
+    /**
+     *  Maps page wikiname to a Set of referring pages. The Set must contain Strings. Non-existing pages (a reference exists, but
+     *  not a file for the page contents) may have an empty Set in m_referredBy.
      */
-    private Map<String,Set<String>> m_referredBy;
-    private Map<String,Set<String>> m_unmutableReferredBy;
-
-    /** The WikiEngine that owns this object. */
-    //private WikiEngine     m_engine;   //inherited from BasicPageFilter class
+    private Map< String, Set< String > > m_referredBy;
+    private Map< String, Set< String > > m_unmutableReferredBy;
 
-    private boolean        m_matchEnglishPlurals = false;
-
-    private static Logger log = Logger.getLogger(ReferenceManager.class);
+    private boolean m_matchEnglishPlurals;
 
+    private static final Logger log = Logger.getLogger(ReferenceManager.class);
     private static final String SERIALIZATION_FILE = "refmgr.ser";
     private static final String SERIALIZATION_DIR  = "refmgr-attr";
 
@@ -165,15 +142,11 @@ public class ReferenceManager
      *
      *  @param engine The WikiEngine to which this is managing references to.
      */
-    public ReferenceManager( WikiEngine engine )
-    {
-        m_refersTo   = new HashMap<>();
+    public ReferenceManager( final WikiEngine engine ) {
+        m_refersTo = new HashMap<>();
         m_referredBy = new HashMap<>();
         m_engine = engine;
-
-        m_matchEnglishPlurals = TextUtil.getBooleanProperty( engine.getWikiProperties(),
-                                                             WikiEngine.PROP_MATCHPLURALS,
-                                                             m_matchEnglishPlurals );
+        m_matchEnglishPlurals = TextUtil.getBooleanProperty( engine.getWikiProperties(), WikiEngine.PROP_MATCHPLURALS, false );
 
         //
         //  Create two maps that contain unmutable versions of the two basic maps.
@@ -185,122 +158,70 @@ public class ReferenceManager
     /**
      *  Does a full reference update.  Does not sync; assumes that you do it afterwards.
      */
-    private void updatePageReferences( WikiPage page ) throws ProviderException
-    {
-        String content = m_engine.getPageManager().getPageText( page.getName(),
-                                                                WikiPageProvider.LATEST_VERSION );
-
-        TreeSet<String> res = new TreeSet<String>();
-        Collection<String> links = m_engine.scanWikiLinks( page, content );
-
-        res.addAll( links );
-        List< Attachment > attachments = m_engine.getAttachmentManager().listAttachments( page );
-
-        for( Iterator< Attachment > atti = attachments.iterator(); atti.hasNext(); )
-        {
-            res.add( atti.next().getName() );
+    private void updatePageReferences( final WikiPage page ) throws ProviderException {
+        final String content = m_engine.getPageManager().getPageText( page.getName(), WikiPageProvider.LATEST_VERSION );
+        final Collection< String > links = m_engine.scanWikiLinks( page, content );
+        final TreeSet< String > res = new TreeSet<>( links );
+        final List< Attachment > attachments = m_engine.getAttachmentManager().listAttachments( page );
+        for( final Attachment att : attachments ) {
+            res.add( att.getName() );
         }
 
         internalUpdateReferences( page.getName(), res );
     }
 
     /**
-     *  Initializes the entire reference manager with the initial set of pages
-     *  from the collection.
+     *  Initializes the entire reference manager with the initial set of pages from the collection.
      *
-     *  @param pages A collection of all pages you want to be included in the reference
-     *               count.
+     *  @param pages A collection of all pages you want to be included in the reference count.
      *  @since 2.2
-     *  @throws ProviderException If reading of pages fail.
+     *  @throws ProviderException If reading of pages fails.
      */
-    public void initialize( Collection< WikiPage > pages ) throws ProviderException
-    {
-        log.debug( "Initializing new ReferenceManager with "+pages.size()+" initial pages." );
-        StopWatch sw = new StopWatch();
+    public void initialize( final Collection< WikiPage > pages ) throws ProviderException {
+        log.debug( "Initializing new ReferenceManager with " + pages.size() + " initial pages." );
+        final StopWatch sw = new StopWatch();
         sw.start();
         log.info( "Starting cross reference scan of WikiPages" );
 
-        //
-        //  First, try to serialize old data from disk.  If that fails,
-        //  we'll go and update the entire reference lists (which'll take
-        //  time)
-        //
-        try
-        {
-            //
-            //  Unserialize things.  The loop below cannot be combined with
-            //  the other loop below, simply because engine.getPage() has
-            //  side effects such as loading initializing the user databases,
-            //  which in turn want all of the pages to be read already...
+        //  First, try to serialize old data from disk.  If that fails, we'll go and update the entire reference lists (which'll take time)
+        try {
+            //  Unserialize things.  The loop below cannot be combined with the other loop below, simply because
+            //  engine.getPage() has side effects such as loading initializing the user databases, which in turn want all
+            //  of the pages to be read already...
             //
             //  Yes, this is a kludge.  We know.  Will be fixed.
-            //
-            long saved = unserializeFromDisk();
-
-            for( Iterator< WikiPage > it = pages.iterator(); it.hasNext(); )
-            {
-                WikiPage page = it.next();
+            final long saved = unserializeFromDisk();
 
+            for( final WikiPage page : pages ) {
                 unserializeAttrsFromDisk( page );
             }
 
-            //
-            //  Now we must check if any of the pages have been changed
-            //  while we were in the electronic la-la-land, and update
-            //  the references for them.
-            //
-
-            Iterator< WikiPage > it = pages.iterator();
-
-            while( it.hasNext() )
-            {
-                WikiPage page = it.next();
-
-                if( page instanceof Attachment )
-                {
-                    // Skip attachments
-                }
-                else
-                {
-
+            //  Now we must check if any of the pages have been changed  while we were in the electronic la-la-land,
+            //  and update the references for them.
+            for( final WikiPage page : pages ) {
+                if( !( page instanceof Attachment ) ) {
                     // Refresh with the latest copy
-                    page = m_engine.getPage( page.getName() );
+                    final WikiPage wp = m_engine.getPage( page.getName() );
 
-                    if( page.getLastModified() == null )
-                    {
+                    if( wp.getLastModified() == null ) {
                         log.fatal( "Provider returns null lastModified.  Please submit a bug report." );
-                    }
-                    else if( page.getLastModified().getTime() > saved )
-                    {
-                        updatePageReferences( page );
+                    } else if( wp.getLastModified().getTime() > saved ) {
+                        updatePageReferences( wp );
                     }
                 }
             }
 
-        }
-        catch( Exception e )
-        {
-            log.info("Unable to unserialize old refmgr information, rebuilding database: "+e.getMessage());
+        } catch( final Exception e ) {
+            log.info( "Unable to unserialize old refmgr information, rebuilding database: " + e.getMessage() );
             buildKeyLists( pages );
 
             // Scan the existing pages from disk and update references in the manager.
-            Iterator< WikiPage > it = pages.iterator();
-            while( it.hasNext() )
-            {
-                WikiPage page  = it.next();
-
-                if( page instanceof Attachment )
-                {
-                    // We cannot build a reference list from the contents
-                    // of attachments, so we skip them.
-                }
-                else
-                {
+            for( final WikiPage page : pages ) {
+                // We cannot build a reference list from the contents of attachments, so we skip them.
+                if( !( page instanceof Attachment ) ) {
                     updatePageReferences( page );
-
                     serializeAttrsToDisk( page );
                 }
-
             }
 
             serializeToDisk();
@@ -309,30 +230,24 @@ public class ReferenceManager
         sw.stop();
         log.info( "Cross reference scan done in "+sw );
 
-        WikiEventUtils.addWikiEventListener(m_engine.getPageManager(), WikiPageEvent.PAGE_DELETED, this);
+        WikiEventUtils.addWikiEventListener( m_engine.getPageManager(), WikiPageEvent.PAGE_DELETED, this );
     }
 
     /**
-     *  Reads the serialized data from the disk back to memory.
-     *  Returns the date when the data was last written on disk
+     *  Reads the serialized data from the disk back to memory. Returns the date when the data was last written on disk
      */
     @SuppressWarnings("unchecked")
-    private synchronized long unserializeFromDisk()
-        throws IOException,
-               ClassNotFoundException
-    {
-        long saved = 0L;
+    private synchronized long unserializeFromDisk() throws IOException, ClassNotFoundException {
+        final long saved;
 
-        File f = new File( m_engine.getWorkDir(), SERIALIZATION_FILE );
-        try( ObjectInputStream in = new ObjectInputStream( new BufferedInputStream(new FileInputStream(f)) ) )
-        {
-            StopWatch sw = new StopWatch();
+        final File f = new File( m_engine.getWorkDir(), SERIALIZATION_FILE );
+        try( final ObjectInputStream in = new ObjectInputStream( new BufferedInputStream( new FileInputStream( f ) ) ) ) {
+            final StopWatch sw = new StopWatch();
             sw.start();
 
-            long ver     = in.readLong();
+            final long ver = in.readLong();
 
-            if( ver != serialVersionUID )
-            {
+            if( ver != serialVersionUID ) {
                 throw new IOException("File format has changed; I need to recalculate references.");
             }
 
@@ -340,8 +255,6 @@ public class ReferenceManager
             m_refersTo   = ( Map< String, Collection< String > > ) in.readObject();
             m_referredBy = ( Map< String, Set< String > > ) in.readObject();
 
-            in.close();
-
             m_unmutableReferredBy = Collections.unmodifiableMap( m_referredBy );
             m_unmutableRefersTo   = Collections.unmodifiableMap( m_refersTo );
 
@@ -355,11 +268,10 @@ public class ReferenceManager
     /**
      *  Serializes hashmaps to disk.  The format is private, don't touch it.
      */
-    private synchronized void serializeToDisk()
-    {
-        File f = new File( m_engine.getWorkDir(), SERIALIZATION_FILE );
-        try( ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream( new FileOutputStream( f ) ) ) ) {
-            StopWatch sw = new StopWatch();
+    private synchronized void serializeToDisk() {
+        final File f = new File( m_engine.getWorkDir(), SERIALIZATION_FILE );
+        try( final ObjectOutputStream out = new ObjectOutputStream( new BufferedOutputStream( new FileOutputStream( f ) ) ) ) {
+            final StopWatch sw = new StopWatch();
             sw.start();
 
             out.writeLong( serialVersionUID );
@@ -367,153 +279,124 @@ public class ReferenceManager
             out.writeObject( m_refersTo );
             out.writeObject( m_referredBy );
 
-            out.close();
-
             sw.stop();
 
             log.debug("serialization done - took "+sw);
-        }
-        catch( IOException ioe )
-        {
+        } catch( final IOException ioe ) {
             log.error("Unable to serialize!", ioe);
         }
     }
 
-    private String getHashFileName( String pageName ) {
+    private String getHashFileName( final String pageName ) {
+        if( pageName == null ) {
+            return null;
+        }
 		try {
-			MessageDigest digest = MessageDigest.getInstance("MD5");
-			byte[] dig = digest.digest( pageName.getBytes(StandardCharsets.UTF_8) );
+            final MessageDigest digest = MessageDigest.getInstance( "MD5" );
+            final byte[] dig = digest.digest( pageName.getBytes( StandardCharsets.UTF_8 ) );
 
-	        return TextUtil.toHexString(dig)+".cache";
-		} catch( NoSuchAlgorithmException e ) {
+	        return TextUtil.toHexString( dig ) + ".cache";
+		} catch( final NoSuchAlgorithmException e ) {
 			log.fatal( "What do you mean - no such algorithm?", e );
 			return null;
 		}
     }
 
     /**
-     *  Reads the serialized data from the disk back to memory.
-     *  Returns the date when the data was last written on disk
+     *  Reads the serialized data from the disk back to memory. Returns the date when the data was last written on disk
      */
-    private synchronized long unserializeAttrsFromDisk(WikiPage p)
-        throws IOException,
-               ClassNotFoundException
-    {
+    private synchronized long unserializeAttrsFromDisk( final WikiPage p ) throws IOException, ClassNotFoundException {
         long saved = 0L;
 
-        //
         //  Find attribute cache, and check if it exists
-        //
-        String hashName = getHashFileName( p.getName() );
+        final String hashName = getHashFileName( p.getName() );
         if( hashName != null ) {
         	File f = new File( m_engine.getWorkDir(), SERIALIZATION_DIR );
-
             f = new File( f, hashName );
-
-            if( !f.exists() )
-            {
+            if( !f.exists() ) {
                 return 0L;
             }
-            try( ObjectInputStream in = new ObjectInputStream( new BufferedInputStream(new FileInputStream(f)) ))
-            {
-                StopWatch sw = new StopWatch();
-                sw.start();
-
-                log.debug("Deserializing attributes for "+p.getName());
 
-                long ver = in.readLong();
+            try( final ObjectInputStream in = new ObjectInputStream( new BufferedInputStream( new FileInputStream( f ) ) ) ) {
+                final StopWatch sw = new StopWatch();
+                sw.start();
+                log.debug( "Deserializing attributes for " + p.getName() );
 
-                if( ver != serialVersionUID )
-                {
+                final long ver = in.readLong();
+                if( ver != serialVersionUID ) {
                     log.debug("File format has changed; cannot deserialize.");
                     return 0L;
                 }
 
-                saved        = in.readLong();
-
-                String name  = in.readUTF();
-
-                if( !name.equals(p.getName()) )
-                {
-                    log.debug("File name does not match ("+name+"), skipping...");
+                saved = in.readLong();
+                final String name  = in.readUTF();
+                if( !name.equals( p.getName() ) ) {
+                    log.debug("File name does not match (" + name + "), skipping...");
                     return 0L; // Not here
                 }
 
-                long entries = in.readLong();
-
-                for( int i = 0; i < entries; i++ )
-                {
-                    String key   = in.readUTF();
-                    Object value = in.readObject();
-
+                final long entries = in.readLong();
+                for( int i = 0; i < entries; i++ ) {
+                    final String key   = in.readUTF();
+                    final Object value = in.readObject();
                     p.setAttribute( key, value );
-
                     log.debug("   attr: "+key+"="+value);
                 }
 
-                in.close();
-
                 sw.stop();
                 log.debug("Read serialized data for "+name+" successfully in "+sw);
                 p.setHasMetadata();
             }
         }
 
-
         return saved;
     }
 
     /**
      *  Serializes hashmaps to disk.  The format is private, don't touch it.
      */
-    private synchronized void serializeAttrsToDisk( WikiPage p )
-    {
-        StopWatch sw = new StopWatch();
+    private synchronized void serializeAttrsToDisk( final WikiPage p ) {
+        final StopWatch sw = new StopWatch();
         sw.start();
 
-        String hashName = getHashFileName( p.getName() );
+        final String hashName = getHashFileName( p.getName() );
         if( hashName != null ) {
         	File f = new File( m_engine.getWorkDir(), SERIALIZATION_DIR );
+            if( !f.exists() ) {
+                f.mkdirs();
+            }
 
-            if( !f.exists() ) f.mkdirs();
-
-            //
             //  Create a digest for the name
-            //
             f = new File( f, hashName );
 
-            try( ObjectOutputStream out =  new ObjectOutputStream( new BufferedOutputStream( new FileOutputStream( f ) ) ) ) {
-                Set< Map.Entry < String, Object > > entries = new HashSet<>( p.getAttributes().entrySet() ); // new Set to avoid concurrency issue
+            try( final ObjectOutputStream out =  new ObjectOutputStream( new BufferedOutputStream( new FileOutputStream( f ) ) ) ) {
+                // new Set to avoid concurrency issues
+                final Set< Map.Entry < String, Object > > entries = new HashSet<>( p.getAttributes().entrySet() );
 
-                if( entries.size() == 0 )
-                {
-                    //  Nothing to serialize, therefore we will just simply remove the
-                    //  serialization file so that the next time we boot, we don't
-                    //  deserialize old data.
+                if( entries.size() == 0 ) {
+                    //  Nothing to serialize, therefore we will just simply remove the serialization file so that the
+                    //  next time we boot, we don't deserialize old data.
                     f.delete();
                     return;
                 }
 
                 out.writeLong( serialVersionUID );
                 out.writeLong( System.currentTimeMillis() ); // Timestamp
-
                 out.writeUTF( p.getName() );
                 out.writeLong( entries.size() );
 
-                for( Iterator< Map.Entry < String, Object > > i = entries.iterator(); i.hasNext(); ) {
-                    Map.Entry< String, Object > e = i.next();
-
+                for( final Map.Entry< String, Object > e : entries ) {
                     if( e.getValue() instanceof Serializable ) {
                         out.writeUTF( e.getKey() );
                         out.writeObject( e.getValue() );
                     }
                 }
 
-            } catch( IOException e ) {
+            } catch( final IOException e ) {
                 log.error( "Unable to serialize!", e );
             } finally {
                 sw.stop();
-                log.debug("serialization for "+p.getName()+" done - took "+sw);
+                log.debug( "serialization for " + p.getName() + " done - took " + sw );
             }
         }
 
@@ -526,58 +409,41 @@ public class ReferenceManager
      *  @param content {@inheritDoc}
      */
     @Override
-	public void postSave( WikiContext context, String content )
-    {
-        WikiPage page = context.getPage();
-
-        updateReferences( page.getName(),
-                          context.getEngine().scanWikiLinks( page, content ) );
-
+	public void postSave( final WikiContext context, final String content ) {
+        final WikiPage page = context.getPage();
+        updateReferences( page.getName(), context.getEngine().scanWikiLinks( page, content ) );
         serializeAttrsToDisk( page );
     }
 
     /**
-     * Updates the m_referedTo and m_referredBy hashmaps when a page has been
-     * deleted.
+     * Updates the m_referedTo and m_referredBy hashmaps when a page has been deleted.
      * <P>
-     * Within the m_refersTo map the pagename is a key. The whole key-value-set
-     * has to be removed to keep the map clean.
-     * Within the m_referredBy map the name is stored as a value. Since a key
-     * can have more than one value we have to delete just the key-value-pair
-     * referring page:deleted page.
+     * Within the m_refersTo map the pagename is a key. The whole key-value-set has to be removed to keep the map clean.
+     * Within the m_referredBy map the name is stored as a value. Since a key can have more than one value we have to
+     * delete just the key-value-pair referring page:deleted page.
      *
      *  @param page Name of the page to remove from the maps.
      */
-    public synchronized void pageRemoved( WikiPage page )
-    {
-        String pageName = page.getName();
-
-        pageRemoved(pageName);
+    public synchronized void pageRemoved( final WikiPage page ) {
+        pageRemoved( page.getName() );
     }
 
-    private void pageRemoved(String pageName)
-    {
-        Collection<String> refTo = m_refersTo.get( pageName );
-
-        if( refTo != null )
-        {
-            Iterator< String > itRefTo = refTo.iterator();
-            while( itRefTo.hasNext() )
-            {
-                String referredPageName = itRefTo.next();
-                Set<String> refBy = m_referredBy.get( referredPageName );
-
-                if( refBy == null )
-                    throw new InternalWikiException("Refmgr out of sync: page "+pageName+" refers to "+referredPageName+", which has null referrers.");
-
-                refBy.remove(pageName);
+    private void pageRemoved( final String pageName ) {
+        final Collection< String > refTo = m_refersTo.get( pageName );
+        if( refTo != null ) {
+            for( final String referredPageName : refTo ) {
+                final Set< String > refBy = m_referredBy.get( referredPageName );
+                if( refBy == null ) {
+                    throw new InternalWikiException( "Refmgr out of sync: page " + pageName +
+                                                     " refers to " + referredPageName + ", which has null referrers." );
+                }
 
+                refBy.remove( pageName );
                 m_referredBy.remove( referredPageName );
 
                 // 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.pageExists( referredPageName ) ) ) {
                     m_referredBy.put( referredPageName, refBy );
                 }
             }
@@ -586,104 +452,76 @@ public class ReferenceManager
             m_refersTo.remove( pageName );
         }
 
-        Set<String> refBy = m_referredBy.get( pageName );
-        if( refBy == null || refBy.isEmpty() )
-        {
+        final Set< String > refBy = m_referredBy.get( pageName );
+        if( refBy == null || refBy.isEmpty() ) {
             m_referredBy.remove( pageName );
         }
 
-        //
         //  Remove any traces from the disk, too
-        //
         serializeToDisk();
 
-        String hashName = getHashFileName( pageName );
+        final String hashName = getHashFileName( pageName );
         if( hashName != null ) {
         	File f = new File( m_engine.getWorkDir(), SERIALIZATION_DIR );
-
-            f = new File( f, getHashFileName(pageName) );
-
-            if( f.exists() ) f.delete();
+            f = new File( f, getHashFileName( pageName ) );
+            if( f.exists() ) {
+                f.delete();
+            }
         }
     }
 
     /**
-     *  Updates the referred pages of a new or edited WikiPage. If a refersTo
-     *  entry for this page already exists, it is removed and a new one is built
-     *  from scratch. Also calls updateReferredBy() for each referenced page.
+     *  Updates the referred pages of a new or edited WikiPage. If a refersTo entry for this page already exists, it is removed
+     *  and a new one is built from scratch. Also calls updateReferredBy() for each referenced page.
      *  <P>
-     *  This is the method to call when a new page has been created and we
-     *  want to a) set up its references and b) notify the referred pages
-     *  of the references. Use this method during run-time.
+     *  This is the method to call when a new page has been created and we want to a) set up its references and b) notify the
+     *  referred pages of the references. Use this method during run-time.
      *
      *  @param page Name of the page to update.
      *  @param references A Collection of Strings, each one pointing to a page this page references.
      */
-    public synchronized void updateReferences( String page, Collection< String > references )
-    {
-        internalUpdateReferences(page, references);
-
+    public synchronized void updateReferences( final String page, final Collection< String > references ) {
+        internalUpdateReferences( page, references );
         serializeToDisk();
     }
 
     /**
-     *  Updates the referred pages of a new or edited WikiPage. If a refersTo
-     *  entry for this page already exists, it is removed and a new one is built
-     *  from scratch. Also calls updateReferredBy() for each referenced page.
+     *  Updates the referred pages of a new or edited WikiPage. If a refersTo entry for this page already exists, it is
+     *  removed and a new one is built from scratch. Also calls updateReferredBy() for each referenced page.
      *  <p>
      *  This method does not synchronize the database to disk.
      *
      *  @param page Name of the page to update.
      *  @param references A Collection of Strings, each one pointing to a page this page references.
      */
-
-    private void internalUpdateReferences(String page, Collection< String > references)
-    {
+    private void internalUpdateReferences( String page, final Collection< String > references) {
         page = getFinalPageName( page );
 
-        //
         // Create a new entry in m_refersTo.
-        //
-        Collection< String > oldRefTo = m_refersTo.get( page );
+        final Collection< String > oldRefTo = m_refersTo.get( page );
         m_refersTo.remove( page );
 
-        TreeSet<String> cleanedRefs = new TreeSet<>();
-        for( Iterator< String > i = references.iterator(); i.hasNext(); )
-        {
-            String ref = i.next();
-
-            ref = getFinalPageName( ref );
-
-            cleanedRefs.add( ref );
+        final TreeSet< String > cleanedRefs = new TreeSet<>();
+        for( final String ref : references ) {
+            final String reference = getFinalPageName( ref );
+            cleanedRefs.add( reference );
         }
 
         m_refersTo.put( page, cleanedRefs );
 
-        //
-        //  We know the page exists, since it's making references somewhere.
-        //  If an entry for it didn't exist previously in m_referredBy, make
-        //  sure one is added now.
-        //
-        if( !m_referredBy.containsKey( page ) )
-        {
-            m_referredBy.put( page, new TreeSet<String>() );
+        //  We know the page exists, since it's making references somewhere. If an entry for it didn't exist previously
+        //  in m_referredBy, make sure one is added now.
+        if( !m_referredBy.containsKey( page ) ) {
+            m_referredBy.put( page, new TreeSet<>() );
         }
 
-        //
-        //  Get all pages that used to be referred to by 'page' and
-        //  remove that reference. (We don't want to try to figure out
+        //  Get all pages that used to be referred to by 'page' and remove that reference. (We don't want to try to figure out
         //  which particular references were removed...)
-        //
         cleanReferredBy( page, oldRefTo, cleanedRefs );
 
-        //
         //  Notify all referred pages of their referinesshoodicity.
-        //
-        Iterator<String> it = cleanedRefs.iterator();
-        while( it.hasNext() )
-        {
-            String referredPageName = it.next();
-            updateReferredBy( getFinalPageName(referredPageName), page );
+        for( final String referredPageName : cleanedRefs ) {
+            updateReferredBy( getFinalPageName( referredPageName ), page );
         }
     }
 
@@ -692,8 +530,7 @@ public class ReferenceManager
      *
      * @return The refers-to list.
      */
-    protected Map< String, Collection< String > > getRefersTo()
-    {
+    protected Map< String, Collection< String > > getRefersTo() {
         return m_refersTo;
     }
 
@@ -702,101 +539,79 @@ public class ReferenceManager
      *
      * @return Referred-by lists.
      */
-    protected Map< String, Set< String > > getReferredBy()
-    {
+    protected Map< String, Set< String > > getReferredBy() {
         return m_referredBy;
     }
 
     /**
-     * Cleans the 'referred by' list, removing references by 'referrer' to
-     * any other page. Called after 'referrer' is removed.
+     * Cleans the 'referred by' list, removing references by 'referrer' to any other page. Called after 'referrer' is removed.
+     *
+     * Two ways to go about this. One is to look up all pages previously referred by referrer and remove referrer
+     * from their lists, and let the update put them back in (except possibly removed ones).
+     *
+     * The other is to get the old referred-to list, compare to the new, and tell the ones missing in the latter to remove referrer from
+     * their list.
+     *
+     * We'll just try the first for now. Need to come back and optimize this a bit.
      */
-    private void cleanReferredBy( String referrer,
-                                  Collection<String> oldReferred,
-                                  Collection<String> newReferred )
-    {
-        // Two ways to go about this. One is to look up all pages previously
-        // referred by referrer and remove referrer from their lists, and let
-        // the update put them back in (except possibly removed ones).
-        // The other is to get the old referred to list, compare to the new,
-        // and tell the ones missing in the latter to remove referrer from
-        // their list. Hm. We'll just try the first for now. Need to come
-        // back and optimize this a bit.
-
-        if( oldReferred == null )
+    private void cleanReferredBy( final String referrer,
+                                  final Collection< String > oldReferred,
+                                  final Collection< String > newReferred ) {
+        if( oldReferred == null ) {
             return;
+        }
 
-        Iterator< String > it = oldReferred.iterator();
-        while( it.hasNext() )
-        {
-            String referredPage = it.next();
-            Set< String > oldRefBy = m_referredBy.get( referredPage );
-            if( oldRefBy != null )
-            {
+        for( final String referredPage : oldReferred ) {
+            final Set< String > oldRefBy = m_referredBy.get( referredPage );
+            if( oldRefBy != null ) {
                 oldRefBy.remove( referrer );
             }
 
-            // 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 ) == false ) )
-            {
+            // 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 ) ) {
                 m_referredBy.remove( referredPage );
             }
         }
-
     }
 
-
     /**
-     *  When initially building a ReferenceManager from scratch, call this method
-     * BEFORE calling updateReferences() with a full list of existing page names.
-     * It builds the refersTo and referredBy key lists, thus enabling
-     * updateReferences() to function correctly.
+     * When initially building a ReferenceManager from scratch, call this method BEFORE calling updateReferences() with
+     * a full list of existing page names. It builds the refersTo and referredBy key lists, thus enabling updateReferences()
+     * to function correctly.
      * <P>
-     * This method should NEVER be called after initialization. It clears all mappings
-     * from the reference tables.
+     * This method should NEVER be called after initialization. It clears all mappings from the reference tables.
      *
-     * @param pages   a Collection containing WikiPage objects.
+     * @param pages a Collection containing WikiPage objects.
      */
-    private synchronized void buildKeyLists( Collection< WikiPage > pages )
-    {
+    private synchronized void buildKeyLists( final Collection< WikiPage > pages ) {
         m_refersTo.clear();
         m_referredBy.clear();
-
-        if( pages == null )
+        if( pages == null ) {
             return;
+        }
 
-        Iterator< WikiPage > it = pages.iterator();
-        try
-        {
-            while( it.hasNext() )
-            {
-                WikiPage page = it.next();
+        try {
+            for( final WikiPage page : pages ) {
                 // We add a non-null entry to referredBy to indicate the referred page exists
-                m_referredBy.put( page.getName(), new TreeSet<String>() );
+                m_referredBy.put( page.getName(), new TreeSet<>() );
                 // Just add a key to refersTo; the keys need to be in sync with referredBy.
                 m_refersTo.put( page.getName(), null );
             }
-        }
-        catch( ClassCastException e )
-        {
+        } catch( final ClassCastException e ) {
             log.fatal( "Invalid collection entry in ReferenceManager.buildKeyLists().", e );
         }
     }
 
 
     /**
-     * Marks the page as referred to by the referrer. If the page does not
-     * exist previously, nothing is done. (This means that some page, somewhere,
-     * has a link to a page that does not exist.)
+     * Marks the page as referred to by the referrer. If the page does not exist previously, nothing is done. (This means
+     * that some page, somewhere, has a link to a page that does not exist.)
      * <P>
-     * This method is NOT synchronized. It should only be referred to from
-     * within a synchronized method, or it should be made synced if necessary.
+     * This method is NOT synchronized. It should only be referred to from within a synchronized method, or it should be
+     * made synced if necessary.
      */
-    private void updateReferredBy( String page, String referrer )
-    {
+    private void updateReferredBy( final String page, final String referrer ) {
         // We're not really interested in first level self-references.
         /*
         if( page.equals( referrer ) )
@@ -805,26 +620,16 @@ public class ReferenceManager
         }
         */
         // Neither are we interested if plural forms refer to each other.
-        if( m_matchEnglishPlurals )
-        {
-            String p2 = page.endsWith("s") ? page.substring(0,page.length()-1) : page+"s";
-
-            if( referrer.equals(p2) )
-            {
+        if( m_matchEnglishPlurals ) {
+            final String p2 = page.endsWith( "s" ) ? page.substring( 0, page.length() - 1 ) : page + "s";
+            if( referrer.equals( p2 ) ) {
                 return;
             }
         }
 
-        Set<String> referrers = m_referredBy.get( page );
-
-        // Even if 'page' has not been created yet, it can still be referenced.
-        // This requires we don't use m_referredBy keys when looking up missing
-        // pages, of course.
-        if(referrers == null)
-        {
-            referrers = new TreeSet<String>();
-            m_referredBy.put( page, referrers );
-        }
+        // Even if 'page' has not been created yet, it can still be referenced. This requires we don't use m_referredBy
+        // keys when looking up missing pages, of course.
+        final Set< String > referrers = m_referredBy.computeIfAbsent( page, k -> new TreeSet<>() );
         referrers.add( referrer );
     }
 
@@ -834,50 +639,34 @@ public class ReferenceManager
      *
      * @param pagename  Name of the page to clear references for.
      */
-    public synchronized void clearPageEntries( String pagename )
-    {
-        pagename = getFinalPageName(pagename);
-
-        //
-        //  Remove this item from the referredBy list of any page
-        //  which this item refers to.
-        //
-        Collection<String> c = m_refersTo.get( pagename );
-
-        if( c != null )
-        {
-            for( String key : c )
-            {
-                Collection<?> dref = m_referredBy.get( key );
-
+    public synchronized void clearPageEntries( String pagename ) {
+        pagename = getFinalPageName( pagename );
+
+        //  Remove this item from the referredBy list of any page which this item refers to.
+        final Collection< String > c = m_refersTo.get( pagename );
+        if( c != null ) {
+            for( final String key : c ) {
+                final Collection< ? > dref = m_referredBy.get( key );
                 dref.remove( pagename );
             }
         }
 
-        //
         //  Finally, remove direct references.
-        //
         m_referredBy.remove( pagename );
         m_refersTo.remove( pagename );
     }
 
 
     /**
-     *  Finds all unreferenced pages. This requires a linear scan through
-     *  m_referredBy to locate keys with null or empty values.
+     *  Finds all unreferenced pages. This requires a linear scan through m_referredBy to locate keys with null or empty values.
      *
      *  @return The Collection of Strings
      */
-    public synchronized Collection< String > findUnreferenced()
-    {
-        ArrayList<String> unref = new ArrayList<String>();
-
-        for( String key : m_referredBy.keySet() )
-        {
-            Set<?> refs = getReferenceList( m_referredBy, key );
-
-            if( refs == null || refs.isEmpty() )
-            {
+    public synchronized Collection< String > findUnreferenced() {
+        final ArrayList< String > unref = new ArrayList<>();
+        for( final String key : m_referredBy.keySet() ) {
+            final Set< ? > refs = getReferenceList( m_referredBy, key );
+            if( refs == null || refs.isEmpty() ) {
                 unref.add( key );
             }
         }
@@ -887,34 +676,24 @@ public class ReferenceManager
 
 
     /**
-     * Finds all references to non-existant pages. This requires a linear
-     * scan through m_refersTo values; each value must have a corresponding
-     * key entry in the reference Maps, otherwise such a page has never
-     * been created.
+     * Finds all references to non-existant pages. This requires a linear scan through m_refersTo values; each value
+     * must have a corresponding key entry in the reference Maps, otherwise such a page has never been created.
      * <P>
-     * Returns a Collection containing Strings of unreferenced page names.
-     * Each non-existant page name is shown only once - we don't return information
-     * on who referred to it.
+     * Returns a Collection containing Strings of unreferenced page names. Each non-existant page name is shown only
+     * once - we don't return information on who referred to it.
      *
      * @return A Collection of Strings
      */
-    public synchronized Collection< String > findUncreated()
-    {
-        TreeSet<String> uncreated = new TreeSet<String>();
+    public synchronized Collection< String > findUncreated() {
+        final TreeSet< String > uncreated = new TreeSet<>();
 
         // Go through m_refersTo values and check that m_refersTo has the corresponding keys.
         // We want to reread the code to make sure our HashMaps are in sync...
-
-        Collection<Collection<String>> allReferences = m_refersTo.values();
-
-        for( Collection<String> refs : allReferences )
-        {
-            if( refs != null )
-            {
-                for( String aReference : refs )
-                {
-                    if( m_engine.pageExists( aReference ) == false )
-                    {
+        final Collection< Collection< String > > allReferences = m_refersTo.values();
+        for( final Collection<String> refs : allReferences ) {
+            if( refs != null ) {
+                for( final String aReference : refs ) {
+                    if( !m_engine.pageExists( aReference ) ) {
                         uncreated.add( aReference );
                     }
                 }
@@ -925,144 +704,112 @@ public class ReferenceManager
     }
 
     /**
-     *  Searches for the given page in the given Map, and returns
-     *  the set of references.  This method also takes care of English plural
-     *  matching.
+     *  Searches for the given page in the given Map, and returns the set of references. This method also takes care of
+     *  English plural matching.
      *
      *  @param coll The Map to search in
      *  @param pagename The name to find.
      *  @return The references list.
      */
-    private <T> Set<T> getReferenceList( Map<String,Set<T>> coll, String pagename )
-    {
-        Set<T> refs = coll.get( pagename );
+    private < T > Set< T > getReferenceList( final Map< String, Set< T > > coll, final String pagename ) {
+        Set< T > refs = coll.get( pagename );
 
-        if( m_matchEnglishPlurals )
-        {
-            //
+        if( m_matchEnglishPlurals ) {
             //  We'll add also matches from the "other" page.
-            //
-            Set<T> refs2;
+            final Set< T > refs2;
 
-            if( pagename.endsWith("s") )
-            {
-                refs2 = coll.get( pagename.substring(0,pagename.length()-1) );
-            }
-            else
-            {
-                refs2 = coll.get( pagename+"s" );
+            if( pagename.endsWith( "s" ) ) {
+                refs2 = coll.get( pagename.substring( 0, pagename.length() - 1 ) );
+            } else {
+                refs2 = coll.get( pagename + "s" );
             }
 
-            if( refs2 != null )
-            {
-                if( refs != null )
+            if( refs2 != null ) {
+                if( refs != null ) {
                     refs.addAll( refs2 );
-                else
+                } else {
                     refs = refs2;
+                }
             }
         }
         return refs;
     }
 
     /**
-     * Find all pages that refer to this page. Returns null if the page
-     * does not exist or is not referenced at all, otherwise returns a
-     * collection containing page names (String) that refer to this one.
+     * Find all pages that refer to this page. Returns null if the page does not exist or is not referenced at all,
+     * otherwise returns a collection containing page names (String) that refer to this one.
      * <p>
      * @param pagename The page to find referrers for.
-     * @return A Set of Strings.  May return null, if the page
-     *         does not exist, or if it has no references.
+     * @return A Set of Strings.  May return null, if the page does not exist, or if it has no references.
      */
-    public synchronized Set< String > findReferrers( String pagename )
-    {
-        Set<String> refs = getReferenceList( m_referredBy, pagename );
-
-        if( refs == null || refs.isEmpty() )
-        {
+    public synchronized Set< String > findReferrers( final String pagename ) {
+        final Set< String > refs = getReferenceList( m_referredBy, pagename );
+        if( refs == null || refs.isEmpty() ) {
             return null;
         }
 
         return refs;
-
     }
 
     /**
-     *  Returns all pages that refer to this page.  Note that this method
-     *  returns an unmodifiable Map, which may be abruptly changed.  So any
-     *  access to any iterator may result in a ConcurrentModificationException.
+     *  Returns all pages that refer to this page.  Note that this method returns an unmodifiable Map, which may be abruptly changed.
+     *  So any access to any iterator may result in a ConcurrentModificationException.
      *  <p>
-     *  The advantages of using this method over findReferrers() is that
-     *  it is very fast, as it does not create a new object.  The disadvantages
-     *  are that it does not do any mapping between plural names, and you
-     *  may end up getting a ConcurrentModificationException.
+     *  The advantages of using this method over findReferrers() is that it is very fast, as it does not create a new object.
+     *  The disadvantages are that it does not do any mapping between plural names, and you may end up getting a
+     *  ConcurrentModificationException.
      *
      * @param pageName Page name to query.
-     * @return A Set of Strings containing the names of all the pages that refer
-     *         to this page.  May return null, if the page does not exist or
-     *         has not been indexed yet.
+     * @return A Set of Strings containing the names of all the pages that refer to this page.  May return null, if the page does
+     *         not exist or has not been indexed yet.
      * @since 2.2.33
      */
-    public Set< String > findReferredBy( String pageName )
-    {
+    public Set< String > findReferredBy( final String pageName ) {
         return m_unmutableReferredBy.get( getFinalPageName(pageName) );
     }
 
     /**
-     *  Returns all pages that this page refers to.  You can use this as a quick
-     *  way of getting the links from a page, but note that it does not link any
-     *  InterWiki, image, or external links.  It does contain attachments, though.
+     *  Returns all pages that this page refers to.  You can use this as a quick way of getting the links from a page, but note
+     *  that it does not link any InterWiki, image, or external links.  It does contain attachments, though.
      *  <p>
-     *  The Collection returned is unmutable, so you cannot change it.  It does reflect
-     *  the current status and thus is a live object.  So, if you are using any
-     *  kind of an iterator on it, be prepared for ConcurrentModificationExceptions.
+     *  The Collection returned is unmutable, so you cannot change it.  It does reflect the current status and thus is a live
+     *  object.  So, if you are using any kind of an iterator on it, be prepared for ConcurrentModificationExceptions.
      *  <p>
-     *  The returned value is a Collection, because a page may refer to another page
-     *  multiple times.
+     *  The returned value is a Collection, because a page may refer to another page multiple times.
      *
      * @param pageName Page name to query
-     * @return A Collection of Strings containing the names of the pages that this page
-     *         refers to. May return null, if the page does not exist or has not
-     *         been indexed yet.
+     * @return A Collection of Strings containing the names of the pages that this page refers to. May return null, if the page
+     *         does not exist or has not been indexed yet.
      * @since 2.2.33
      */
-    public Collection< String > findRefersTo( String pageName )
-    {
-        return m_unmutableRefersTo.get( getFinalPageName(pageName) );
+    public Collection< String > findRefersTo( final String pageName ) {
+        return m_unmutableRefersTo.get( getFinalPageName( pageName ) );
     }
 
     /**
-     * This 'deepHashCode' can be used to determine if there were any
-     * modifications made to the underlying to and by maps of the
-     * ReferenceManager. The maps of the ReferenceManager are not
-     * synchronized, so someone could add/remove entries in them while the
+     * This 'deepHashCode' can be used to determine if there were any modifications made to the underlying to and by maps of the
+     * ReferenceManager. The maps of the ReferenceManager are not synchronized, so someone could add/remove entries in them while the
      * hashCode is being computed.
      *
-     * @return Sum of the hashCodes for the to and by maps of the
-     *         ReferenceManager
+     * This method traps and retries if a concurrent modification occurs.
+     *
+     * @return Sum of the hashCodes for the to and by maps of the ReferenceManager
      * @since 2.3.24
      */
     //
-    //   This method traps and retries if a concurrent
-    //   modifcaition occurs.
-    //   TODO: It is unnecessary to calculate the hashcode; it should be calculated only
-    //         when the hashmaps are changed.  This is slow.
+    //   TODO: It is unnecessary to calculate the hashcode; it should be calculated only when the hashmaps are changed.  This is slow.
     //
-    public int deepHashCode()
-    {
+    public int deepHashCode() {
         boolean failed = true;
         int signature = 0;
 
-        while (failed)
-        {
+        while( failed ) {
             signature = 0;
-            try
-            {
+            try {
                 signature ^= m_referredBy.hashCode();
                 signature ^= m_refersTo.hashCode();
                 failed = false;
-            }
-            catch (ConcurrentModificationException e)
-            {
+            } catch ( final ConcurrentModificationException e) {
                 Thread.yield();
             }
         }
@@ -1071,34 +818,23 @@ public class ReferenceManager
     }
 
     /**
-     *  Returns a list of all pages that the ReferenceManager knows about.
-     *  This should be roughly equivalent to PageManager.getAllPages(), but without
-     *  the potential disk access overhead.  Note that this method is not guaranteed
-     *  to return a Set of really all pages (especially during startup), but it is
-     *  very fast.
+     *  Returns a list of all pages that the ReferenceManager knows about. This should be roughly equivalent to
+     *  PageManager.getAllPages(), but without the potential disk access overhead.  Note that this method is not guaranteed
+     *  to return a Set of really all pages (especially during startup), but it is very fast.
      *
      *  @return A Set of all defined page names that ReferenceManager knows about.
      *  @since 2.3.24
      */
-    public Set< String > findCreated()
-    {
-        return new HashSet<String>( m_refersTo.keySet() );
+    public Set< String > findCreated() {
+        return new HashSet<>( m_refersTo.keySet() );
     }
 
-    private String getFinalPageName( String orig )
-    {
-        try
-        {
-            String s = m_engine.getFinalPageName( orig );
-
-            if( s == null ) s = orig;
-
-            return s;
-        }
-        catch( ProviderException e )
-        {
+    private String getFinalPageName( final String orig ) {
+        try {
+            final String s = m_engine.getFinalPageName( orig );
+            return s != null ? s : orig;
+        } catch( final ProviderException e ) {
             log.error("Error while trying to fetch a page name; trying to cope with the situation.",e);
-
             return orig;
         }
     }
@@ -1107,16 +843,13 @@ public class ReferenceManager
      *  {@inheritDoc}
      */
     @Override
-	public void actionPerformed(WikiEvent event)
-    {
-        if( (event instanceof WikiPageEvent) && (event.getType() == WikiPageEvent.PAGE_DELETED) )
-        {
-            String pageName = ((WikiPageEvent) event).getPageName();
-
-            if( pageName != null )
-            {
+	public void actionPerformed( final WikiEvent event ) {
+        if( event instanceof WikiPageEvent && event.getType() == WikiPageEvent.PAGE_DELETED ) {
+            final String pageName = ( ( WikiPageEvent ) event ).getPageName();
+            if( pageName != null ) {
                 pageRemoved( pageName );
             }
         }
     }
+
 }


[jspwiki] 16/18: use VariableManager from its new package

Posted by ju...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit fbd85175c171cbc35f0f7819b48f333ca0d3d976
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 00:19:16 2020 +0100

    use VariableManager from its new package
---
 jspwiki-war/src/main/webapp/Comment.jsp         | 1 +
 jspwiki-war/src/main/webapp/UserPreferences.jsp | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/jspwiki-war/src/main/webapp/Comment.jsp b/jspwiki-war/src/main/webapp/Comment.jsp
index 40cd8c3..1577189 100644
--- a/jspwiki-war/src/main/webapp/Comment.jsp
+++ b/jspwiki-war/src/main/webapp/Comment.jsp
@@ -34,6 +34,7 @@
 <%@ page import="org.apache.wiki.workflow.DecisionRequiredException" %>
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.preferences.Preferences.TimeFormat" %>
+<%@ page import="org.apache.wiki.variables.VariableManager" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ page import="javax.servlet.http.Cookie" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>
diff --git a/jspwiki-war/src/main/webapp/UserPreferences.jsp b/jspwiki-war/src/main/webapp/UserPreferences.jsp
index ecddb9e..700d0b0 100644
--- a/jspwiki-war/src/main/webapp/UserPreferences.jsp
+++ b/jspwiki-war/src/main/webapp/UserPreferences.jsp
@@ -18,7 +18,6 @@
 --%>
 
 <%@ page import="org.apache.log4j.*" %>
-<%@ page import="org.apache.wiki.VariableManager" %>
 <%@ page import="org.apache.wiki.WikiContext" %>
 <%@ page import="org.apache.wiki.WikiSession" %>
 <%@ page import="org.apache.wiki.WikiEngine" %>
@@ -31,6 +30,7 @@
 <%@ page import="org.apache.wiki.preferences.Preferences" %>
 <%@ page import="org.apache.wiki.ui.EditorManager" %>
 <%@ page import="org.apache.wiki.ui.TemplateManager" %>
+<%@ page import="org.apache.wiki.variables.VariableManager" %>
 <%@ page import="org.apache.wiki.workflow.DecisionRequiredException" %>
 <%@ page errorPage="/Error.jsp" %>
 <%@ taglib uri="http://jspwiki.apache.org/tags" prefix="wiki" %>


[jspwiki] 13/18: renamed WikiDifferenceManager to DefaultDifferenceManager

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 a26f8eff1ed5e9eb2f1ff4d6e426d70ea272fd61
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 00:03:51 2020 +0100

    renamed WikiDifferenceManager to DefaultDifferenceManager
---
 .../{WikiDifferenceManager.java => DefaultDifferenceManager.java}   | 6 +++---
 jspwiki-main/src/main/resources/ini/classmappings.xml               | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/diff/WikiDifferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
similarity index 95%
rename from jspwiki-main/src/main/java/org/apache/wiki/diff/WikiDifferenceManager.java
rename to jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
index e7100ad..c9c6c6a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/diff/WikiDifferenceManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
@@ -34,9 +34,9 @@ import java.util.Properties;
 /**
  * Load, initialize and delegate to the DiffProvider that will actually do the work.
  */
-public class WikiDifferenceManager implements DifferenceManager {
+public class DefaultDifferenceManager implements DifferenceManager {
 
-    private static final Logger log = Logger.getLogger( WikiDifferenceManager.class );
+    private static final Logger log = Logger.getLogger( DefaultDifferenceManager.class );
 
     private DiffProvider m_provider;
 
@@ -46,7 +46,7 @@ public class WikiDifferenceManager implements DifferenceManager {
      * @param engine The WikiEngine.
      * @param props  A set of properties.
      */
-    public WikiDifferenceManager( final WikiEngine engine, final Properties props ) {
+    public DefaultDifferenceManager( final WikiEngine engine, final Properties props ) {
         loadProvider( props );
         initializeProvider( engine, props );
 
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index c2fbecf..f7c2628 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -93,7 +93,7 @@
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.diff.DifferenceManager</requestedClass>
-    <mappedClass>org.apache.wiki.diff.WikiDifferenceManager</mappedClass>
+    <mappedClass>org.apache.wiki.diff.DefaultDifferenceManager</mappedClass>
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.i18n.InternationalizationManager</requestedClass>


[jspwiki] 17/18: remove unneeded cast + apply format & fixes from 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 8f6331800370cee76bdbd3161f891cf0b96e6767
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Jan 3 00:29:08 2020 +0100

    remove unneeded cast + apply format & fixes from intellij
---
 .../java/org/apache/wiki/WikiBackgroundThread.java | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiBackgroundThread.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiBackgroundThread.java
index 636e57a..18e48e3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiBackgroundThread.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiBackgroundThread.java
@@ -32,11 +32,11 @@ import org.apache.wiki.event.WikiEventListener;
  */
 public abstract class WikiBackgroundThread extends Thread implements WikiEventListener {
 	
-    private static final Logger LOG = Logger.getLogger(WikiBackgroundThread.class);
+    private static final Logger LOG = Logger.getLogger( WikiBackgroundThread.class );
     private volatile boolean m_killMe = false;
     private final WikiEngine m_engine;
     private final int m_interval;
-    private static final long POLLING_INTERVAL = 1000L;
+    private static final long POLLING_INTERVAL = 1_000L;
     
     /**
      * Constructs a new instance of this background thread with a specified sleep interval, and adds the new instance 
@@ -46,7 +46,7 @@ public abstract class WikiBackgroundThread extends Thread implements WikiEventLi
      * @param sleepInterval the interval between invocations of
      * the thread's {@link Thread#run()} method, in seconds
      */
-    public WikiBackgroundThread( WikiEngine engine, int sleepInterval ) {
+    public WikiBackgroundThread( final WikiEngine engine, final int sleepInterval ) {
         super();
         m_engine = engine;
         m_interval = sleepInterval;
@@ -60,9 +60,9 @@ public abstract class WikiBackgroundThread extends Thread implements WikiEventLi
      * @param event {@inheritDoc}
      * @see org.apache.wiki.event.WikiEventListener#actionPerformed(org.apache.wiki.event.WikiEvent)
      */
-    public final void actionPerformed( WikiEvent event ) {
+    public final void actionPerformed( final WikiEvent event ) {
         if ( event instanceof WikiEngineEvent ) {
-            if ( ((WikiEngineEvent)event).getType() == WikiEngineEvent.SHUTDOWN ) {
+            if ( event.getType() == WikiEngineEvent.SHUTDOWN ) {
                 LOG.warn( "Detected wiki engine shutdown: killing " + getName() + "." );
                 m_killMe = true;
             }
@@ -110,15 +110,13 @@ public abstract class WikiBackgroundThread extends Thread implements WikiEventLi
             LOG.warn( "Starting up background thread: " + name + ".");
             startupTask();
             
-            // Perform the background task; check every
-            // second for thread death
+            // Perform the background task; check every second for thread death
             while( !m_killMe ) {
                 // Perform the background task
                 // log.debug( "Running background task: " + name + "." );
                 backgroundTask();
                 
-                // Sleep for the interval we're supposed to, but
-                // wake up every POLLING_INTERVAL to see if thread should die
+                // Sleep for the interval we're supposed to, but wake up every POLLING_INTERVAL to see if thread should die
                 boolean interrupted = false;
                 try {
                     for( int i = 0; i < m_interval; i++ ) {
@@ -132,16 +130,16 @@ public abstract class WikiBackgroundThread extends Thread implements WikiEventLi
                     if( interrupted ) {
                         break;
                     }
-                } catch( Throwable t ) {
+                } catch( final Throwable t ) {
                     LOG.error( "Background thread error: (stack trace follows)", t );
                 }
             }
             
             // Perform the shutdown task
             shutdownTask();
-        } catch( Throwable t ) {
+        } catch( final Throwable t ) {
             LOG.error( "Background thread error: (stack trace follows)", t );
-            throw new InternalWikiException( t.getMessage() ,t);
+            throw new InternalWikiException( t.getMessage() ,t );
         }
     }
     


[jspwiki] 08/18: update portable launchers to tomcat 8.5.50

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 e0a20c1a304f0e11dcd53160b22857b57aba336b
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Jan 1 22:44:14 2020 +0100

    update portable launchers to tomcat 8.5.50
---
 .../tomcat/woas.app/Contents/Java/bootstrap.jar    | Bin 35165 -> 35203 bytes
 .../tomcat/woas.app/Contents/Java/tomcat-juli.jar  | Bin 49901 -> 49903 bytes
 .../src/overlay/launchers/tomcat/woas.exe          | Bin 3475006 -> 3493354 bytes
 3 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar
index f25d02d..c84e05e 100644
Binary files a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar and b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/bootstrap.jar differ
diff --git a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar
index c409af1..f00f867 100644
Binary files a/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar and b/jspwiki-portable/src/overlay/launchers/tomcat/woas.app/Contents/Java/tomcat-juli.jar differ
diff --git a/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe b/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe
index 75bcdd5..38ad409 100644
Binary files a/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe and b/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe differ