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/02/27 15:10:25 UTC

[jspwiki] branch master updated (b03d0b5 -> d680e47)

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 b03d0b5  2.11.0-M7-git-09
     new 910e586  JSPWIKI-120: ModuleManager and implementing classes use Engine instead of WikiEngine
     new 4e13073  JSPWIKI-120: InitializablePlugin and implementing classes use Engine instead of WikiEngine
     new f8e3e5e  JSPWIKI-120: PageFilters use Engine instead of WikiEngine on initialize method.
     new 6d7dbc3  JSPWIKI-120: use Engine instead of WikiEngine
     new 25e2488  JSPWIKI-120: URLConstructor#initialize(..) uses Engine instead of WikiEngine
     new d127551  JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (1)
     new acd5373  JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (2)
     new b365691  JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (3)
     new d6c25ea  JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (4)
     new f3005db  JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (5)
     new 32c889f  JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (6)
     new c6a58f7  small refactor move parsePageFromURL( HttpServletRequest, Charset ) from DefaultURLConstructor to URLConstructor
     new a35b48e  move static UserProfile newProfile( UserDatabase db ) from DefaultUserProfile into AbstractUserDatabase to break a cycle between those two classes
     new 2c5995b  apply format & fixes suggested by intellij
     new 558e491  JSPWIKI-120: rename + extract interfaces from InternationalizationManager, SearchManager, EditorManager and TemplateManager
     new b1f6b04  register TemplateManager modules as mbeans
     new 0a2c57c  minor formatting edits
     new 1e578aa  update flexmark to 0.60.2
     new cbcdd3c  update portable binaries to tomcat 8.5.51
     new d680e47  2.11.0-M7-git-10

The 20 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                                       |  14 +
 .../src/main/java/org/apache/wiki/Release.java     |   2 +-
 .../src/main/java/org/apache/wiki/WatchDog.java    |   4 +-
 .../java/org/apache/wiki/WikiBackgroundThread.java |  13 +-
 .../src/main/java/org/apache/wiki/WikiContext.java |  10 +-
 .../src/main/java/org/apache/wiki/WikiPage.java    |   2 +-
 .../main/java/org/apache/wiki/WikiProvider.java    |   2 +-
 .../src/main/java/org/apache/wiki/WikiServlet.java |  20 +-
 .../wiki/ajax/WikiAjaxDispatcherServlet.java       |   9 +-
 .../main/java/org/apache/wiki/api/core/Engine.java |  10 +-
 .../apache/wiki/api/filters/BasicPageFilter.java   |  71 +--
 .../org/apache/wiki/api/filters/PageFilter.java    |  94 ++--
 .../wiki/api/plugin/InitializablePlugin.java       |  22 +-
 .../apache/wiki/attachment/AttachmentManager.java  |   2 +-
 .../apache/wiki/attachment/AttachmentServlet.java  | 179 +++----
 .../apache/wiki/attachment/DynamicAttachment.java  |  49 +-
 .../wiki/attachment/DynamicAttachmentProvider.java |  22 +-
 .../apache/wiki/auth/AuthenticationManager.java    |  16 +-
 .../wiki/auth/DefaultAuthenticationManager.java    |   2 +-
 .../org/apache/wiki/auth/SecurityVerifier.java     |  31 +-
 .../java/org/apache/wiki/auth/SessionMonitor.java  |  35 +-
 .../java/org/apache/wiki/auth/UserManager.java     |   2 +-
 .../java/org/apache/wiki/auth/acl/AclManager.java  |  35 +-
 .../apache/wiki/auth/acl/DefaultAclManager.java    |  89 +---
 .../login/CookieAuthenticationLoginModule.java     |  16 +-
 .../auth/login/WebContainerCallbackHandler.java    |   2 +-
 .../wiki/auth/login/WikiCallbackHandler.java       |   2 +-
 .../wiki/auth/user/AbstractUserDatabase.java       |  79 +--
 .../apache/wiki/auth/user/DefaultUserProfile.java  | 176 +++----
 .../org/apache/wiki/auth/user/UserDatabase.java    |   1 +
 .../apache/wiki/diff/DefaultDifferenceManager.java |  20 +-
 .../org/apache/wiki/event/WikiEngineEvent.java     |  19 +-
 .../org/apache/wiki/event/WikiEventManager.java    |  18 +-
 .../java/org/apache/wiki/filters/CreoleFilter.java |  41 +-
 .../apache/wiki/filters/DefaultFilterManager.java  |  19 +-
 .../apache/wiki/filters/PingWeblogsComFilter.java  |  22 +-
 .../java/org/apache/wiki/filters/SpamFilter.java   | 122 ++---
 .../DefaultInternationalizationManager.java}       |  22 +-
 .../wiki/i18n/InternationalizationManager.java     |  54 +-
 .../org/apache/wiki/modules/ModuleManager.java     |  47 +-
 .../org/apache/wiki/pages/DefaultPageManager.java  | 114 ++--
 .../java/org/apache/wiki/pages/PageManager.java    |   2 +-
 .../java/org/apache/wiki/pages/PageSorter.java     |  12 +-
 .../apache/wiki/parser/LinkParsingOperations.java  |   2 +-
 .../apache/wiki/plugin/DefaultPluginManager.java   | 157 +++---
 .../org/apache/wiki/plugin/PageViewPlugin.java     | 300 ++++-------
 .../org/apache/wiki/plugin/WeblogEntryPlugin.java  |   2 +-
 .../java/org/apache/wiki/plugin/WeblogPlugin.java  |   2 +-
 .../wiki/providers/AbstractFileProvider.java       |   7 +-
 .../org/apache/wiki/providers/CachingProvider.java |   2 +-
 .../wiki/providers/VersioningFileProvider.java     |   5 +-
 .../wiki/references/DefaultReferenceManager.java   |  34 +-
 .../wiki/render/DefaultRenderingManager.java       |  33 +-
 .../org/apache/wiki/render/RenderingManager.java   |   4 +-
 .../org/apache/wiki/rpc/atom/AtomAPIServlet.java   | 214 +++-----
 .../java/org/apache/wiki/rss/RSSGenerator.java     |  29 +-
 .../main/java/org/apache/wiki/rss/RSSThread.java   |  67 +--
 ...earchManager.java => DefaultSearchManager.java} | 115 +---
 .../apache/wiki/search/LuceneSearchProvider.java   |   2 +-
 .../java/org/apache/wiki/search/SearchManager.java | 288 +----------
 .../main/java/org/apache/wiki/tags/IncludeTag.java |  17 +-
 .../main/java/org/apache/wiki/tags/LinkTag.java    |  23 +-
 .../java/org/apache/wiki/ui/CommandResolver.java   |   4 +-
 .../org/apache/wiki/ui/DefaultCommandResolver.java |  15 +-
 ...ditorManager.java => DefaultEditorManager.java} | 129 ++---
 .../org/apache/wiki/ui/DefaultTemplateManager.java | 353 +++++++++++++
 .../java/org/apache/wiki/ui/EditorManager.java     | 186 ++-----
 .../main/java/org/apache/wiki/ui/Installer.java    |  15 +-
 .../java/org/apache/wiki/ui/TemplateManager.java   | 392 ++------------
 .../main/java/org/apache/wiki/ui/WikiCommand.java  |  18 +-
 .../java/org/apache/wiki/ui/WikiJSPFilter.java     |  38 +-
 .../org/apache/wiki/ui/WikiRequestWrapper.java     |  10 +-
 .../java/org/apache/wiki/ui/WikiServletFilter.java |  22 +-
 .../wiki/ui/admin/DefaultAdminBeanManager.java     | 160 +++---
 .../org/apache/wiki/ui/admin/SimpleAdminBean.java  |  74 ++-
 .../org/apache/wiki/ui/admin/beans/ModuleBean.java |  11 +-
 .../org/apache/wiki/url/DefaultURLConstructor.java |  51 +-
 .../org/apache/wiki/url/ShortURLConstructor.java   |   8 +-
 .../apache/wiki/url/ShortViewURLConstructor.java   |   4 +-
 .../java/org/apache/wiki/url/URLConstructor.java   |  26 +-
 .../org/apache/wiki/variables/VariableManager.java |   2 +-
 .../wiki/workflow/DefaultWorkflowManager.java      |   4 +-
 .../java/org/apache/wiki/workflow/Workflow.java    | 576 ++++++++-------------
 .../org/apache/wiki/workflow/WorkflowBuilder.java  |   4 +-
 .../org/apache/wiki/workflow/WorkflowManager.java  |   2 +-
 .../java/org/apache/wiki/xmlrpc/RPCHandler.java    |   5 +-
 .../java/org/apache/wiki/xmlrpc/RPCServlet.java    |  30 +-
 .../src/main/resources/ini/classmappings.xml       |   8 +-
 .../wiki/filters/DefaultFilterManagerTest.java     |  22 +-
 .../java/org/apache/wiki/filters/TestFilter.java   |   8 +-
 .../wiki/i18n/InternationalizationManagerTest.java |  10 +-
 .../org/apache/wiki/plugin/JavaScriptPlugin.java   |  15 +-
 .../markdown/renderer/JSPWikiLinkRenderer.java     |   3 +-
 .../renderer/JSPWikiNodeRendererFactory.java       |   2 +-
 .../wiki/parser/markdown/MarkdownDocument.java     |   2 +-
 .../tomcat/woas.app/Contents/Java/bootstrap.jar    | Bin 35203 -> 35204 bytes
 .../tomcat/woas.app/Contents/Java/tomcat-juli.jar  | Bin 49903 -> 49783 bytes
 .../src/overlay/launchers/tomcat/woas.exe          | Bin 3493354 -> 3500245 bytes
 pom.xml                                            |   2 +-
 99 files changed, 1978 insertions(+), 3059 deletions(-)
 copy jspwiki-main/src/main/java/org/apache/wiki/{event/WikiEventListener.java => i18n/DefaultInternationalizationManager.java} (67%)
 copy jspwiki-main/src/main/java/org/apache/wiki/search/{SearchManager.java => DefaultSearchManager.java} (73%)
 copy jspwiki-main/src/main/java/org/apache/wiki/ui/{EditorManager.java => DefaultEditorManager.java} (57%)
 create mode 100644 jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultTemplateManager.java


[jspwiki] 02/20: JSPWIKI-120: InitializablePlugin and implementing classes use Engine instead of WikiEngine

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

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

commit 4e130737bdfcae92b67f4edafd24a0118e9505a4
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 13:12:37 2020 +0100

    JSPWIKI-120: InitializablePlugin and implementing classes use Engine instead of WikiEngine
---
 .../wiki/api/plugin/InitializablePlugin.java       |  20 +-
 .../org/apache/wiki/plugin/PageViewPlugin.java     | 300 +++++++--------------
 .../org/apache/wiki/plugin/JavaScriptPlugin.java   |  15 +-
 3 files changed, 115 insertions(+), 220 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java
index 6287ec7..1f4d33e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java
@@ -18,28 +18,24 @@
  */
 package org.apache.wiki.api.plugin;
 
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.PluginException;
 
 /**
- *  If a plugin defines this interface, it is called exactly once
- *  prior to the actual execute() routine.  If the plugin has its
- *  own declaration in jspwiki_modules.xml, then it is called during
- *  startup - otherwise it is called the first time the plugin is
+ *  If a plugin defines this interface, it is called exactly once prior to the actual execute() routine.  If the plugin has its
+ *  own declaration in jspwiki_modules.xml, then it is called during startup - otherwise it is called the first time the plugin is
  *  encountered.
  *  <p>
- *  This method did not actually work until 2.5.30.  The method signature
- *  has been changed in 2.6 to reflect the new operation.
+ *  This method did not actually work until 2.5.30.  The method signature has been changed in 2.6 to reflect the new operation.
  */
-public interface InitializablePlugin
-{
+public interface InitializablePlugin {
+
     /**
-     *  Called whenever the plugin is being instantiated for
-     *  the first time.
+     *  Called whenever the plugin is being instantiated for the first time.
      *  
      *  @param engine The WikiEngine.
      *  @throws PluginException If something goes wrong.
      */
+    void initialize( Engine engine ) throws PluginException;
 
-    void initialize( WikiEngine engine ) throws PluginException;
 }
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 58777b4..7572450 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
@@ -29,7 +29,6 @@ import org.apache.oro.text.regex.PatternMatcher;
 import org.apache.oro.text.regex.Perl5Matcher;
 import org.apache.wiki.WikiBackgroundThread;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.PluginException;
@@ -134,16 +133,12 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
      * 
      * @param engine The wiki engine.
      */
-    @Override public void initialize( final WikiEngine engine )
-    {
-
+    @Override
+    public void initialize( final Engine engine ) {
         log.info( "initializing PageViewPlugin" );
-
-        synchronized( this )
-        {
-            if( c_singleton == null )
-            {
-                c_singleton = new PageViewManager(  );
+        synchronized( this ) {
+            if( c_singleton == null ) {
+                c_singleton = new PageViewManager();
             }
             c_singleton.initialize( engine );
         }
@@ -152,23 +147,20 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
     /**
      * Cleanup the singleton reference.
      */
-    private void cleanup()
-    {
+    private void cleanup() {
         log.info( "cleaning up PageView Manager" );
-
         c_singleton = null;
     }
 
     /**
      *  {@inheritDoc}
      */
-    @Override public String execute( final WikiContext context, final Map<String, String> params ) throws PluginException
-    {
+    @Override
+    public String execute( final WikiContext context, final Map< String, String > params ) throws PluginException {
         final PageViewManager manager = c_singleton;
         String result = STR_EMPTY;
 
-        if( manager != null )
-        {
+        if( manager != null ) {
             result = manager.execute( context, params );
         }
 
@@ -178,8 +170,7 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
     /**
      * Page view manager, handling all storage.
      */
-    public final class PageViewManager implements WikiEventListener
-    {
+    public final class PageViewManager implements WikiEventListener {
         /** Are we initialized? */
         private boolean m_initialized = false;
 
@@ -199,13 +190,10 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
         private String m_workDir = null;
 
         /** Comparator for descending sort on page count. */
-        private final Comparator<Object> m_compareCountDescending = new Comparator<Object>() {
-            @Override public int compare( final Object o1, final Object o2 )
-            {
-                final int v1 = getCount( o1 );
-                final int v2 = getCount( o2 );
-                return (v1 == v2) ? ((String) o1).compareTo( (String) o2 ) : (v1 < v2) ? 1 : -1;
-            }
+        private final Comparator< Object > m_compareCountDescending = ( o1, o2 ) -> {
+            final int v1 = getCount( o1 );
+            final int v2 = getCount( o2 );
+            return ( v1 == v2 ) ? ( ( String )o1 ).compareTo( ( String )o2 ) : ( v1 < v2 ) ? 1 : -1;
         };
 
         /**
@@ -213,16 +201,11 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
          * 
          * @param engine The wiki engine.
          */
-        public synchronized void initialize( final WikiEngine engine )
-        {
+        public synchronized void initialize( final Engine engine ) {
             log.info( "initializing PageView Manager" );
-
             m_workDir = engine.getWorkDir();
-
             engine.addWikiEventListener( this );
-
-            if( m_counters == null )
-            {
+            if( m_counters == null ) {
                 // Load the counters into a collection
                 m_storage = new Properties();
                 m_counters = new TreeMap<>();
@@ -231,8 +214,7 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
             }
 
             // backup counters every 5 minutes
-            if( m_pageCountSaveThread == null )
-            {
+            if( m_pageCountSaveThread == null ) {
                 m_pageCountSaveThread = new CounterSaveThread( engine, 5 * STORAGE_INTERVAL, this );
                 m_pageCountSaveThread.start();
             }
@@ -242,16 +224,13 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
 
         /**
          * Handle the shutdown event via the page counter thread.
-         * 
          */
-        private synchronized void handleShutdown()
-        {
+        private synchronized void handleShutdown() {
             log.info( "handleShutdown: The counter store thread was shut down." );
 
             cleanup();
 
-            if( m_counters != null )
-            {
+            if( m_counters != null ) {
 
                 m_dirty = true;
                 storeCounters();
@@ -273,35 +252,28 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
          * 
          * @param event The wiki event to inspect.
          */
-        @Override public void actionPerformed( final WikiEvent event )
-        {
-            if( event instanceof WikiEngineEvent )
-            {
-                if( event.getType() == WikiEngineEvent.SHUTDOWN )
-                {
+        @Override
+        public void actionPerformed( final WikiEvent event ) {
+            if( event instanceof WikiEngineEvent ) {
+                if( event.getType() == WikiEngineEvent.SHUTDOWN ) {
                     log.info( "Detected wiki engine shutdown" );
                     handleShutdown();
                 }
-            } 
-            else if( (event instanceof WikiPageRenameEvent) && (event.getType() == WikiPageRenameEvent.PAGE_RENAMED) )
-            {
-                final String oldPageName = ((WikiPageRenameEvent) event).getOldPageName();
-                final String newPageName = ((WikiPageRenameEvent) event).getNewPageName();
-                final Counter oldCounter = m_counters.get(oldPageName);
-                if ( oldCounter != null )
-                {
-                    m_storage.remove(oldPageName);
-                    m_counters.put(newPageName, oldCounter);
-                    m_storage.setProperty(newPageName, oldCounter.toString());
-                    m_counters.remove(oldPageName);
+            } else if( ( event instanceof WikiPageRenameEvent ) && ( event.getType() == WikiPageRenameEvent.PAGE_RENAMED ) ) {
+                final String oldPageName = ( ( WikiPageRenameEvent )event ).getOldPageName();
+                final String newPageName = ( ( WikiPageRenameEvent )event ).getNewPageName();
+                final Counter oldCounter = m_counters.get( oldPageName );
+                if( oldCounter != null ) {
+                    m_storage.remove( oldPageName );
+                    m_counters.put( newPageName, oldCounter );
+                    m_storage.setProperty( newPageName, oldCounter.toString() );
+                    m_counters.remove( oldPageName );
                     m_dirty = true;
                 }
-            }
-            else if( (event instanceof WikiPageEvent) && (event.getType() == WikiPageEvent.PAGE_DELETED) )
-            {
-                 final String pageName = ((WikiPageEvent) event).getPageName();
-                 m_storage.remove(pageName);
-                 m_counters.remove(pageName);
+            } else if( ( event instanceof WikiPageEvent ) && ( event.getType() == WikiPageEvent.PAGE_DELETED ) ) {
+                final String pageName = ( ( WikiPageEvent )event ).getPageName();
+                m_storage.remove( pageName );
+                m_counters.remove( pageName );
             }
         }
 
@@ -313,13 +285,12 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
          * @return String Wiki page snippet
          * @throws PluginException Malformed pattern parameter.
          */
-        public String execute( final WikiContext context, final Map<String, String> params ) throws PluginException {
+        public String execute( final WikiContext context, final Map< String, String > params ) throws PluginException {
             final Engine engine = context.getEngine();
             final WikiPage page = context.getPage();
             String result = STR_EMPTY;
 
-            if( page != null )
-            {
+            if( page != null ) {
                 // get parameters
                 final String pagename = page.getName();
                 String count = params.get( PARAM_COUNT );
@@ -336,48 +307,32 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
                 boolean increment = false;
 
                 // increment counter?
-                if( STR_YES.equals( count ) )
-                {
+                if( STR_YES.equals( count ) ) {
                     increment = true;
-                }
-                else
-                {
+                } else {
                     count = null;
                 }
 
                 // default increment counter?
-                if( (show == null || STR_NONE.equals( show )) && count == null )
-                {
+                if( ( show == null || STR_NONE.equals( show ) ) && count == null ) {
                     increment = true;
                 }
 
                 // filter on referring pages?
-                Collection<String> referrers = null;
+                Collection< String > referrers = null;
 
-                if( refer != null )
-                {
+                if( refer != null ) {
                     final ReferenceManager refManager = engine.getManager( ReferenceManager.class );
-
-                    final Iterator< String > iter = refManager.findCreated().iterator();
-
-                    while ( iter != null && iter.hasNext() )
-                    {
-                        final String name = iter.next();
+                    for( final String name : refManager.findCreated() ) {
                         boolean use = false;
-
-                        for( int n = 0; !use && n < refer.length; n++ )
-                        {
-                            use = matcher.matches( name, refer[n] );
+                        for( int n = 0; !use && n < refer.length; n++ ) {
+                            use = matcher.matches( name, refer[ n ] );
                         }
 
-                        if( use )
-                        {
+                        if( use ) {
                             final Collection< String > refs = engine.getManager( ReferenceManager.class ).findReferrers( name );
-
-                            if( refs != null && !refs.isEmpty() )
-                            {
-                                if( referrers == null )
-                                {
+                            if( refs != null && !refs.isEmpty() ) {
+                                if( referrers == null ) {
                                     referrers = new HashSet<>();
                                 }
                                 referrers.addAll( refs );
@@ -386,15 +341,12 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
                     }
                 }
 
-                synchronized( this )
-                {
+                synchronized( this ) {
                     Counter counter = m_counters.get( pagename );
 
                     // only count in view mode, keep storage values in sync
-                    if( increment && WikiContext.VIEW.equalsIgnoreCase( context.getRequestContext() ) )
-                    {
-                        if( counter == null )
-                        {
+                    if( increment && WikiContext.VIEW.equalsIgnoreCase( context.getRequestContext() ) ) {
+                        if( counter == null ) {
                             counter = new Counter();
                             m_counters.put( pagename, counter );
                         }
@@ -403,16 +355,12 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
                         m_dirty = true;
                     }
 
-                    if( show == null || STR_NONE.equals( show ) )
-                    {
+                    if( show == null || STR_NONE.equals( show ) ) {
                         // nothing to show
 
-                    }
-                    else if( PARAM_COUNT.equals( show ) )
-                    {
+                    } else if( PARAM_COUNT.equals( show ) ) {
                         // show page count
-                        if( counter == null )
-                        {
+                        if( counter == null ) {
                             counter = new Counter();
                             m_counters.put( pagename, counter );
                             m_storage.setProperty( pagename, counter.toString() );
@@ -420,47 +368,31 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
                         }
                         result = counter.toString();
 
-                    }
-                    else if( body != null && 0 < body.length() && STR_LIST.equals( show ) )
-                    {
+                    } else if( body != null && 0 < body.length() && STR_LIST.equals( show ) ) {
                         // show list of counts
                         String header = STR_EMPTY;
                         String line = body;
                         String footer = STR_EMPTY;
                         int start = body.indexOf( STR_SEPARATOR );
 
-                        // split body into header, line, footer on ----
-                        // separator
-                        if( 0 < start )
-                        {
+                        // split body into header, line, footer on ---- separator
+                        if( 0 < start ) {
                             header = body.substring( 0, start );
-
                             start = skipWhitespace( start + STR_SEPARATOR.length(), body );
-
                             int end = body.indexOf( STR_SEPARATOR, start );
-
-                            if( start >= end )
-                            {
+                            if( start >= end ) {
                                 line = body.substring( start );
-
-                            }
-                            else
-                            {
+                            } else {
                                 line = body.substring( start, end );
-
                                 end = skipWhitespace( end + STR_SEPARATOR.length(), body );
-
                                 footer = body.substring( end );
                             }
                         }
 
                         // sort on name or count?
-                        Map<String, Counter> sorted = m_counters;
-
-                        if( sort != null && PARAM_COUNT.equals( sort ) )
-                        {
+                        Map< String, Counter > sorted = m_counters;
+                        if( PARAM_COUNT.equals( sort ) ) {
                             sorted = new TreeMap<>( m_compareCountDescending );
-
                             sorted.putAll( m_counters );
                         }
 
@@ -470,8 +402,7 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
                         final Object[] args = new Object[] { pagename, STR_EMPTY, STR_EMPTY };
                         final Iterator< Entry< String, Counter > > iter = sorted.entrySet().iterator();
 
-                        while ( iter != null && 0 < entries && iter.hasNext() )
-                        {
+                        while( 0 < entries && iter.hasNext() ) {
                             final Entry< String, Counter > entry = iter.next();
                             final String name = entry.getKey();
 
@@ -480,35 +411,29 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
                             boolean use = min <= value && value <= max;
 
                             // did we specify a refer-to page?
-                            if( use && referrers != null )
-                            {
+                            if( use && referrers != null ) {
                                 use = referrers.contains( name );
                             }
 
                             // did we specify what pages to include?
-                            if( use && include != null )
-                            {
+                            if( use && include != null ) {
                                 use = false;
 
-                                for( int n = 0; !use && n < include.length; n++ )
-                                {
-                                    use = matcher.matches( name, include[n] );
+                                for( int n = 0; !use && n < include.length; n++ ) {
+                                    use = matcher.matches( name, include[ n ] );
                                 }
                             }
 
                             // did we specify what pages to exclude?
-                            if( use && null != exclude )
-                            {
-                                for( int n = 0; use && n < exclude.length; n++ )
-                                {
-                                    use &= !matcher.matches( name, exclude[n] );
+                            if( use && null != exclude ) {
+                                for( int n = 0; use && n < exclude.length; n++ ) {
+                                    use &= !matcher.matches( name, exclude[ n ] );
                                 }
                             }
 
-                            if( use )
-                            {
-                                args[1] = engine.getManager( RenderingManager.class ).beautifyTitle( name );
-                                args[2] = entry.getValue();
+                            if( use ) {
+                                args[ 1 ] = engine.getManager( RenderingManager.class ).beautifyTitle( name );
+                                args[ 2 ] = entry.getValue();
 
                                 fmt.format( args, buf, null );
 
@@ -533,27 +458,18 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
          * @return Pattern[] The compiled patterns, or <code>null</code>.
          * @throws PluginException On malformed patterns.
          */
-        private Pattern[] compileGlobs( final String name, final String value ) throws PluginException
-        {
+        private Pattern[] compileGlobs( final String name, final String value ) throws PluginException {
             Pattern[] result = null;
-
-            if( value != null && 0 < value.length() && !STR_GLOBSTAR.equals( value ) )
-            {
-                try
-                {
+            if( value != null && 0 < value.length() && !STR_GLOBSTAR.equals( value ) ) {
+                try {
                     final PatternCompiler pc = new GlobCompiler();
-
                     final String[] ptrns = StringUtils.split( value, STR_COMMA );
+                    result = new Pattern[ ptrns.length ];
 
-                    result = new Pattern[ptrns.length];
-
-                    for( int n = 0; n < ptrns.length; n++ )
-                    {
-                        result[n] = pc.compile( ptrns[n] );
+                    for( int n = 0; n < ptrns.length; n++ ) {
+                        result[ n ] = pc.compile( ptrns[ n ] );
                     }
-                }
-                catch( final MalformedPatternException e )
-                {
+                } catch( final MalformedPatternException e ) {
                     throw new PluginException( "Parameter " + name + " has a malformed pattern: " + e.getMessage() );
                 }
             }
@@ -568,10 +484,8 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
          * @param value String in which offset points.
          * @return int Adjusted offset into value.
          */
-        private int skipWhitespace( int offset, final String value )
-        {
-            while ( Character.isWhitespace( value.charAt( offset ) ) )
-            {
+        private int skipWhitespace( int offset, final String value ) {
+            while( Character.isWhitespace( value.charAt( offset ) ) ) {
                 offset++;
             }
             return offset;
@@ -602,11 +516,8 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
                     }
 
                     // Copy the collection into a sorted map
-                    final Iterator< Entry< Object, Object > > iter = m_storage.entrySet().iterator();
-
-                    while ( iter != null && iter.hasNext() ) {
-                        final Entry< ?, ? > entry = iter.next();
-                        m_counters.put( (String) entry.getKey(), new Counter( (String) entry.getValue() ) );
+                    for( final Entry< ?, ? > entry : m_storage.entrySet() ) {
+                        m_counters.put( ( String )entry.getKey(), new Counter( ( String )entry.getValue() ) );
                     }
                     
                     log.info( "Loaded " + m_counters.size() + " counter values." );
@@ -636,10 +547,9 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
 
         /**
          * Is the given thread still current?
-         * 
-         * @return boolean <code>true</code> if the thread is still the current
-         *         background thread.
-         * @param thrd
+         *
+         * @param thrd thread that can be the current background thread.
+         * @return boolean <code>true</code> if the thread is still the current background thread.
          */
         private synchronized boolean isRunning( final Thread thrd )
         {
@@ -648,12 +558,8 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
 
     }
 
-
-    /**
-     * Counter for page hits collection.
-     */
-    private static final class Counter
-    {
+    /** Counter for page hits collection. */
+    private static final class Counter {
 
         /** The count value. */
         private int m_count = 0;
@@ -661,8 +567,7 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
         /**
          * Create a new counter.
          */
-        public Counter()
-        {
+        public Counter() {
         }
 
         /**
@@ -706,17 +611,18 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
         /**
          * @return String String representation of the count.
          */
-        @Override public String toString()
+        @Override
+        public String toString()
         {
             return String.valueOf( m_count );
         }
+
     }
 
     /**
      * Background thread storing the page counters.
      */
-    static final class CounterSaveThread extends WikiBackgroundThread
-    {
+    static final class CounterSaveThread extends WikiBackgroundThread {
 
         /** The page view manager. */
         private final PageViewManager m_manager;
@@ -726,15 +632,11 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
          * 
          * @param engine The wiki engine.
          * @param interval Delay in seconds between saves.
-         * @param pageViewManager
+         * @param pageViewManager page view manager.
          */
-        public CounterSaveThread( final WikiEngine engine, final int interval, final PageViewManager pageViewManager )
-        {
-
+        public CounterSaveThread( final Engine engine, final int interval, final PageViewManager pageViewManager ) {
             super( engine, interval );
-
-            if( pageViewManager == null )
-            {
+            if( pageViewManager == null ) {
                 throw new IllegalArgumentException( "Manager cannot be null" );
             }
 
@@ -744,11 +646,9 @@ public class PageViewPlugin extends AbstractReferralPlugin implements WikiPlugin
         /**
          * Save the page counters to file.
          */
-        @Override public void backgroundTask()
-        {
-
-            if( m_manager.isRunning( this ) )
-            {
+        @Override
+        public void backgroundTask() {
+            if( m_manager.isRunning( this ) ) {
                 m_manager.storeCounters();
             }
         }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/JavaScriptPlugin.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/JavaScriptPlugin.java
index 5e2a51c..5ab8b01 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/JavaScriptPlugin.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/JavaScriptPlugin.java
@@ -18,30 +18,29 @@
  */
 package org.apache.wiki.plugin;
 
-import java.util.Map;
-
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.InitializablePlugin;
 import org.apache.wiki.api.plugin.WikiPlugin;
 
+import java.util.Map;
+
 
 /**
  *  Implements a simple plugin that just returns a piece of Javascript
  *  <P>
  *  Parameters: text - text to return.
- *
  */
-public class JavaScriptPlugin implements WikiPlugin, InitializablePlugin
-{
+public class JavaScriptPlugin implements WikiPlugin, InitializablePlugin {
+
     protected static boolean c_inited = false;
     
-    public String execute( WikiContext context, Map< String, String > params ) throws PluginException {
+    @Override public String execute( final WikiContext context, final Map< String, String > params ) throws PluginException {
         return "<script language=\"JavaScript\"><!--\nfoo='';\n--></script>\n";
     }
 
-    public void initialize( WikiEngine engine ) throws PluginException {
+    @Override public void initialize( final Engine engine ) throws PluginException {
         c_inited = true;
     }
 


[jspwiki] 01/20: JSPWIKI-120: ModuleManager and implementing classes use Engine instead of WikiEngine

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

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

commit 910e586975e3929c1929bad927c1fac3bfc0dab1
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 13:11:14 2020 +0100

    JSPWIKI-120: ModuleManager and implementing classes use Engine instead of WikiEngine
---
 .../apache/wiki/filters/DefaultFilterManager.java  |  18 +--
 .../org/apache/wiki/modules/ModuleManager.java     |  45 +++----
 .../org/apache/wiki/pages/DefaultPageManager.java  | 101 +++++++-------
 .../apache/wiki/plugin/DefaultPluginManager.java   | 148 ++++++++++-----------
 .../java/org/apache/wiki/ui/EditorManager.java     |   5 +-
 .../java/org/apache/wiki/ui/TemplateManager.java   |   4 +-
 6 files changed, 161 insertions(+), 160 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 6409ee0..b0004ef 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
@@ -20,7 +20,7 @@ package org.apache.wiki.filters;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.FilterException;
 import org.apache.wiki.api.exceptions.WikiException;
@@ -100,7 +100,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *  @param props Properties to initialize the FilterManager with
      *  @throws WikiException If something goes wrong.
      */
-    public DefaultFilterManager( final WikiEngine engine, final Properties props ) throws WikiException {
+    public DefaultFilterManager( final Engine engine, final Properties props ) throws WikiException {
         super( engine );
         initialize( props );
     }
@@ -116,7 +116,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *  @param priority The priority in which position to add it in.
      *  @throws IllegalArgumentException If the PageFilter is null or invalid.
      */
-    public void addPageFilter( final PageFilter f, final int priority ) throws IllegalArgumentException {
+    @Override public void addPageFilter( final PageFilter f, final int priority ) throws IllegalArgumentException {
         if( f == null ) {
             throw new IllegalArgumentException("Attempt to provide a null filter - this should never happen.  Please check your configuration (or if you're a developer, check your own code.)");
         }
@@ -240,7 +240,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *
      *  @see PageFilter#preTranslate(WikiContext, String)
      */
-    public String doPreTranslateFiltering( final WikiContext context, String pageData ) throws FilterException {
+    @Override public String doPreTranslateFiltering( final WikiContext context, String pageData ) throws FilterException {
         fireEvent( WikiPageEvent.PRE_TRANSLATE_BEGIN, context );
         for( final PageFilter f : m_pageFilters ) {
             pageData = f.preTranslate( context, pageData );
@@ -260,7 +260,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *  @return The modified HTML
      *  @see PageFilter#postTranslate(WikiContext, String)
      */
-    public String doPostTranslateFiltering( final WikiContext context, String htmlData ) throws FilterException {
+    @Override public String doPostTranslateFiltering( final WikiContext context, String htmlData ) throws FilterException {
         fireEvent( WikiPageEvent.POST_TRANSLATE_BEGIN, context );
         for( final PageFilter f : m_pageFilters ) {
             htmlData = f.postTranslate( context, htmlData );
@@ -280,7 +280,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *  @return The modified WikiMarkup
      *  @see PageFilter#preSave(WikiContext, String)
      */
-    public String doPreSaveFiltering( final WikiContext context, String pageData ) throws FilterException {
+    @Override public String doPreSaveFiltering( final WikiContext context, String pageData ) throws FilterException {
         fireEvent( WikiPageEvent.PRE_SAVE_BEGIN, context );
         for( final PageFilter f : m_pageFilters ) {
             pageData = f.preSave( context, pageData );
@@ -300,7 +300,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *
      *  @see PageFilter#postSave(WikiContext, String)
      */
-    public void doPostSaveFiltering( final WikiContext context, final String pageData ) throws FilterException {
+    @Override public void doPostSaveFiltering( final WikiContext context, final String pageData ) throws FilterException {
         fireEvent( WikiPageEvent.POST_SAVE_BEGIN, context );
         for( final PageFilter f : m_pageFilters ) {
             // log.info("POSTSAVE: "+f.toString() );
@@ -316,7 +316,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *
      *  @return A List of PageFilter objects
      */
-    public List< PageFilter > getFilterList()
+    @Override public List< PageFilter > getFilterList()
     {
         return m_pageFilters;
     }
@@ -326,7 +326,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      * Notifies PageFilters to clean up their ressources.
      *
      */
-    public void destroy() {
+    @Override public void destroy() {
         for( final PageFilter f : m_pageFilters ) {
             f.destroy( m_engine );
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java b/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java
index e0e5b82..a59e401 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java
@@ -18,28 +18,24 @@
  */
 package org.apache.wiki.modules;
 
+import org.apache.wiki.Release;
+import org.apache.wiki.api.core.Engine;
+
 import java.util.Collection;
 import java.util.Iterator;
 import java.util.Set;
 import java.util.TreeSet;
 
-import org.apache.wiki.Release;
-import org.apache.wiki.WikiEngine;
-
 
 /**
  *  Superclass for all JSPWiki managers for modules (plugins, etc).
  */
-public abstract class ModuleManager
-{
+public abstract class ModuleManager {
 
-    /**
-     * Location of the property-files of plugins.
-     *  (Each plugin should include this property-file in its jar-file)
-     */
+    /** Location of the property-files of plugins. (Each plugin should include this property-file in its jar-file) */
     public static final String PLUGIN_RESOURCE_LOCATION = "ini/jspwiki_module.xml";
 
-    protected WikiEngine m_engine;
+    protected Engine m_engine;
 
     private boolean m_loadIncompatibleModules = false;
 
@@ -48,8 +44,7 @@ public abstract class ModuleManager
      *
      *  @param engine The WikiEngine which owns this manager.
      */
-    public ModuleManager( WikiEngine engine )
-    {
+    public ModuleManager( final Engine engine ) {
         m_engine = engine;
     }
 
@@ -59,12 +54,10 @@ public abstract class ModuleManager
      *  @param info The module to check
      *  @return True, if the module is compatible.
      */
-    public boolean checkCompatibility( WikiModuleInfo info )
-    {
-        if( !m_loadIncompatibleModules )
-        {
-            String minVersion = info.getMinVersion();
-            String maxVersion = info.getMaxVersion();
+    public boolean checkCompatibility( final WikiModuleInfo info ) {
+        if( !m_loadIncompatibleModules ) {
+            final String minVersion = info.getMinVersion();
+            final String maxVersion = info.getMaxVersion();
 
             return Release.isNewerOrEqual( minVersion ) && Release.isOlderOrEqual( maxVersion );
         }
@@ -81,12 +74,13 @@ public abstract class ModuleManager
      */
     public abstract Collection< WikiModuleInfo > modules();
 
-    protected < T extends WikiModuleInfo > Collection< WikiModuleInfo > modules( Iterator< T > iterator ) {
-        Set< WikiModuleInfo > ls = new TreeSet<>();
-
-        for( Iterator< T > i = iterator; i.hasNext(); ) {
-            WikiModuleInfo wmi = i.next();
-            if( !ls.contains( wmi ) ) ls.add( wmi );
+    protected < T extends WikiModuleInfo > Collection< WikiModuleInfo > modules( final Iterator< T > iterator ) {
+        final Set< WikiModuleInfo > ls = new TreeSet<>();
+        for( final Iterator< T > i = iterator; i.hasNext(); ) {
+            final WikiModuleInfo wmi = i.next();
+            if( !ls.contains( wmi ) ) {
+                ls.add( wmi );
+            }
         }
 
         return ls;
@@ -94,8 +88,9 @@ public abstract class ModuleManager
 
     /**
      * Returns the {@link WikiModuleInfo} information about the provided moduleName.
+     *
      * @param moduleName
      * @return The wikiModuleInfo
      */
-    public abstract WikiModuleInfo getModuleInfo(String moduleName);
+    public abstract WikiModuleInfo getModuleInfo( final String moduleName );
 }
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 8dcaa8f..fbbedc7 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
@@ -25,15 +25,18 @@ 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.core.Engine;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.auth.WikiPrincipal;
 import org.apache.wiki.auth.WikiSecurityException;
 import org.apache.wiki.auth.acl.Acl;
 import org.apache.wiki.auth.acl.AclEntry;
 import org.apache.wiki.auth.acl.AclEntryImpl;
+import org.apache.wiki.auth.acl.AclManager;
 import org.apache.wiki.auth.user.UserProfile;
 import org.apache.wiki.diff.DifferenceManager;
 import org.apache.wiki.event.WikiEvent;
@@ -45,6 +48,9 @@ import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.providers.RepositoryModifiedException;
 import org.apache.wiki.providers.WikiPageProvider;
 import org.apache.wiki.references.ReferenceManager;
+import org.apache.wiki.search.SearchManager;
+import org.apache.wiki.tasks.TasksManager;
+import org.apache.wiki.ui.CommandResolver;
 import org.apache.wiki.util.ClassUtil;
 import org.apache.wiki.util.TextUtil;
 import org.apache.wiki.workflow.Decision;
@@ -103,21 +109,17 @@ 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(final WikiEngine engine, final Properties props) throws NoSuchElementException, WikiException {
+    public DefaultPageManager(final Engine engine, final Properties props) throws NoSuchElementException, WikiException {
         super(engine);
         final String classname;
-        m_engine = engine;
-        final 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 );
 
-        m_expiryTime = TextUtil.parseIntParameter(props.getProperty(PROP_LOCKEXPIRY), 60);
-
-        //
         //  If user wants to use a cache, then we'll use the CachingProvider.
-        //
-        if (useCache) {
+        if( useCache ) {
             classname = "org.apache.wiki.providers.CachingProvider";
         } else {
-            classname = TextUtil.getRequiredProperty(props, PROP_PAGEPROVIDER);
+            classname = TextUtil.getRequiredProperty( props, PROP_PAGEPROVIDER );
         }
 
         pageSorter.initialize( props );
@@ -187,7 +189,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
             final WikiPage p = m_provider.getPageInfo( pageName, version );
 
             m_engine.getManager( ReferenceManager.class ).updateReferences( p );
-            m_engine.getSearchManager().reindexPage( p );
+            m_engine.getManager( SearchManager.class ).reindexPage( p );
             text = m_provider.getPageText( pageName, version );
         }
 
@@ -243,8 +245,8 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         // messages will appear in his/her workflow inbox.
         final WorkflowBuilder builder = WorkflowBuilder.getBuilder( m_engine );
         final Principal submitter = context.getCurrentUser();
-        final Step prepTask = m_engine.getTasksManager().buildPreSaveWikiPageTask( context, proposedText );
-        final Step completionTask = m_engine.getTasksManager().buildSaveWikiPageTask();
+        final Step prepTask = m_engine.getManager( TasksManager.class ).buildPreSaveWikiPageTask( context, proposedText );
+        final Step completionTask = m_engine.getManager( TasksManager.class ).buildSaveWikiPageTask();
         final String diffText = m_engine.getManager( DifferenceManager.class ).makeDiff( context, oldText, proposedText );
         final boolean isAuthenticated = context.getWikiSession().isAuthenticated();
         final Fact[] facts = new Fact[ 5 ];
@@ -261,7 +263,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
                                                                  facts,
                                                                  completionTask,
                                                                  rejectKey );
-        m_engine.getWorkflowManager().start( workflow );
+        m_engine.getManager( WorkflowManager.class ).start( workflow );
 
         // Let callers know if the page-save requires approval
         if ( workflow.getCurrentStep() instanceof Decision ) {
@@ -274,7 +276,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      *
      * @return The WikiEngine object.
      */
-    protected WikiEngine getEngine() {
+    protected Engine getEngine() {
         return m_engine;
     }
 
@@ -377,7 +379,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         try {
             WikiPage p = getPageInfo( pagereq, version );
             if( p == null ) {
-                p = m_engine.getAttachmentManager().getAttachmentInfo( null, pagereq );
+                p = m_engine.getManager( AttachmentManager.class ).getAttachmentInfo( null, pagereq );
             }
 
             return p;
@@ -419,17 +421,17 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getVersionHistory(java.lang.String)
      */
-    @Override
+    @Override @SuppressWarnings( "unchecked" )
     public < T extends WikiPage > List< T > getVersionHistory( final String pageName ) {
         List< T > c = null;
 
         try {
             if( pageExists( pageName ) ) {
-                c = (List< T >)m_provider.getVersionHistory( pageName );
+                c = ( List< T > )m_provider.getVersionHistory( pageName );
             }
 
             if( c == null ) {
-                c = (List< T >)m_engine.getAttachmentManager().getVersionHistory( pageName );
+                c = ( List< T > )m_engine.getManager( AttachmentManager.class ).getVersionHistory( pageName );
             }
         } catch( final ProviderException e ) {
             LOG.error( "ProviderException requesting version history for " + pageName, e );
@@ -442,15 +444,17 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#getCurrentProvider()
      */
-    @Override public String getCurrentProvider() {
+    @Override 
+    public String getCurrentProvider() {
         return getProvider().getClass().getName();
     }
 
     /**
      * {@inheritDoc}
+     *
      * @see org.apache.wiki.pages.PageManager#getProviderDescription()
      */
-    @Override
+    @Override 
     public String getProviderDescription() {
         return m_provider.getProviderInfo();
     }
@@ -478,7 +482,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         try {
             final TreeSet< WikiPage > sortedPages = new TreeSet<>( new PageTimeComparator() );
             sortedPages.addAll( getAllPages() );
-            sortedPages.addAll( m_engine.getAttachmentManager().getAllAttachments() );
+            sortedPages.addAll( m_engine.getManager( AttachmentManager.class ).getAllAttachments() );
 
             return sortedPages;
         } catch( final ProviderException e ) {
@@ -506,23 +510,24 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      */
     @Override
     public boolean pageExists( final String pageName, final int version ) throws ProviderException {
-        if (pageName == null || pageName.length() == 0) {
-            throw new ProviderException("Illegal page name");
+        if( pageName == null || pageName.length() == 0 ) {
+            throw new ProviderException( "Illegal page name" );
         }
 
-        if (version == WikiProvider.LATEST_VERSION) {
-            return pageExists(pageName);
+        if( version == WikiProvider.LATEST_VERSION ) {
+            return pageExists( pageName );
         }
 
-        return m_provider.pageExists(pageName, version);
+        return m_provider.pageExists( pageName, version );
     }
 
     /**
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#wikiPageExists(java.lang.String)
      */
-    @Override public boolean wikiPageExists( final String page ) {
-        if( m_engine.getCommandResolver().getSpecialPageReference( page ) != null ) {
+    @Override
+    public boolean wikiPageExists( final String page ) {
+        if( m_engine.getManager( CommandResolver.class ).getSpecialPageReference( page ) != null ) {
             return true;
         }
 
@@ -532,7 +537,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
                 return true;
             }
 
-            att = m_engine.getAttachmentManager().getAttachmentInfo( null, page );
+            att = m_engine.getManager( AttachmentManager.class ).getAttachmentInfo( null, page );
         } catch( final ProviderException e ) {
             LOG.debug( "pageExists() failed to find attachments", e );
         }
@@ -544,8 +549,9 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#wikiPageExists(java.lang.String, int)
      */
-    @Override public boolean wikiPageExists( final String page, final int version ) throws ProviderException {
-        if( m_engine.getCommandResolver().getSpecialPageReference( page ) != null ) {
+    @Override
+    public boolean wikiPageExists( final String page, final int version ) throws ProviderException {
+        if( m_engine.getManager( CommandResolver.class ).getSpecialPageReference( page ) != null ) {
             return true;
         }
 
@@ -558,7 +564,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         if( !isThere ) {
             //  Go check if such an attachment exists.
             try {
-                isThere = m_engine.getAttachmentManager().getAttachmentInfo( null, page, version ) != null;
+                isThere = m_engine.getManager( AttachmentManager.class ).getAttachmentInfo( null, page, version ) != null;
             } catch( final ProviderException e ) {
                 LOG.debug( "wikiPageExists() failed to find attachments", e );
             }
@@ -574,7 +580,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
     @Override
     public void deleteVersion( final WikiPage page ) throws ProviderException {
         if( page instanceof Attachment ) {
-            m_engine.getAttachmentManager().deleteVersion( ( Attachment )page );
+            m_engine.getManager( AttachmentManager.class ).deleteVersion( ( Attachment )page );
         } else {
             m_provider.deleteVersion( page.getName(), page.getVersion() );
             // FIXME: If this was the latest, reindex Lucene, update RefMgr
@@ -585,23 +591,24 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
      * {@inheritDoc}
      * @see org.apache.wiki.pages.PageManager#deletePage(java.lang.String)
      */
-    @Override public void deletePage( final String pageName ) throws ProviderException {
+    @Override
+    public void deletePage( final String pageName ) throws ProviderException {
         final WikiPage p = getPage( pageName );
         if( p != null ) {
             if( p instanceof Attachment ) {
-                m_engine.getAttachmentManager().deleteAttachment( ( Attachment )p );
+                m_engine.getManager( AttachmentManager.class ).deleteAttachment( ( Attachment )p );
             } else {
                 final Collection< String > refTo = m_engine.getManager( ReferenceManager.class ).findRefersTo( pageName );
                 // May return null, if the page does not exist or has not been indexed yet.
 
-                if( m_engine.getAttachmentManager().hasAttachments( p ) ) {
-                    final List< Attachment > attachments = m_engine.getAttachmentManager().listAttachments( p );
+                if( m_engine.getManager( AttachmentManager.class ).hasAttachments( p ) ) {
+                    final List< Attachment > attachments = m_engine.getManager( AttachmentManager.class ).listAttachments( p );
                     for( final Attachment attachment : attachments ) {
                         if( refTo != null ) {
                             refTo.remove( attachment.getName() );
                         }
 
-                        m_engine.getAttachmentManager().deleteAttachment( attachment );
+                        m_engine.getManager( AttachmentManager.class ).deleteAttachment( attachment );
                     }
                 }
                 deletePage( p );
@@ -632,9 +639,9 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
          *
          * @param engine WikiEngine to own this thread.
          */
-        public LockReaper( final WikiEngine engine) {
-            super(engine, 60);
-            setName("JSPWiki Lock Reaper");
+        public LockReaper( final Engine engine) {
+            super( engine, 60 );
+            setName( "JSPWiki Lock Reaper" );
         }
 
         @Override
@@ -720,7 +727,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
                     if( aclChanged ) {
                         // If the Acl needed changing, change it now
                         try {
-                            m_engine.getAclManager().setPermissions( page, page.getAcl() );
+                            m_engine.getManager( AclManager.class ).setPermissions( page, page.getAcl() );
                         } catch( final WikiSecurityException e ) {
                             LOG.error("Could not change page ACL for page " + page.getName() + ": " + e.getMessage(), e);
                         }
@@ -753,18 +760,18 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
             final Collection< AclEntry > entriesToRemove = new ArrayList<>();
             while( entries.hasMoreElements() ) {
                 final AclEntry entry = entries.nextElement();
-                if( ArrayUtils.contains(oldPrincipals, entry.getPrincipal() ) ) {
+                if( ArrayUtils.contains( oldPrincipals, entry.getPrincipal() ) ) {
                     // Create new entry
                     final AclEntry newEntry = new AclEntryImpl();
                     newEntry.setPrincipal( newPrincipal );
-                    final Enumeration<Permission> permissions = entry.permissions();
+                    final Enumeration< Permission > permissions = entry.permissions();
                     while( permissions.hasMoreElements() ) {
                         final Permission permission = permissions.nextElement();
-                        newEntry.addPermission(permission);
+                        newEntry.addPermission( permission );
                     }
                     pageChanged = true;
-                    entriesToRemove.add(entry);
-                    entriesToAdd.add(newEntry);
+                    entriesToRemove.add( entry );
+                    entriesToAdd.add( newEntry );
                 }
             }
             for( final AclEntry entry : entriesToRemove ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
index 90c8131..55b6d6b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
@@ -34,6 +34,7 @@ import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
 import org.apache.wiki.ajax.WikiAjaxServlet;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.InitializablePlugin;
@@ -59,7 +60,6 @@ import java.text.MessageFormat;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.NoSuchElementException;
@@ -185,22 +185,22 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
      *  @param engine WikiEngine which owns this manager.
      *  @param props Contents of a "jspwiki.properties" file.
      */
-    public DefaultPluginManager( WikiEngine engine, Properties props ) {
+    public DefaultPluginManager( final WikiEngine engine, final Properties props ) {
         super( engine );
-        String packageNames = props.getProperty( PROP_SEARCHPATH );
+        final String packageNames = props.getProperty( PROP_SEARCHPATH );
 
         if ( packageNames != null ) {
-            StringTokenizer tok = new StringTokenizer( packageNames, "," );
+            final StringTokenizer tok = new StringTokenizer( packageNames, "," );
 
             while( tok.hasMoreTokens() ) {
                 m_searchPath.add( tok.nextToken().trim() );
             }
         }
 
-        String externalJars = props.getProperty( PROP_EXTERNALJARS );
+        final String externalJars = props.getProperty( PROP_EXTERNALJARS );
 
         if( externalJars != null ) {
-            StringTokenizer tok = new StringTokenizer( externalJars, "," );
+            final StringTokenizer tok = new StringTokenizer( externalJars, "," );
 
             while( tok.hasMoreTokens() ) {
                 m_externalJars.add( tok.nextToken().trim() );
@@ -215,11 +215,11 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
         m_searchPath.add( DEFAULT_PACKAGE );
         m_searchPath.add( DEFAULT_FORMS_PACKAGE );
 
-        PatternCompiler compiler = new Perl5Compiler();
+        final PatternCompiler compiler = new Perl5Compiler();
 
         try {
             m_pluginPattern = compiler.compile( PLUGIN_INSERT_PATTERN );
-        } catch( MalformedPatternException e ) {
+        } catch( final MalformedPatternException e ) {
             log.fatal( "Internal error: someone messed with pluginmanager patterns.", e );
             throw new InternalWikiException( "PluginManager patterns are broken" , e);
         }
@@ -230,7 +230,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
      * {@inheritDoc}
      */
     @Override
-    public void enablePlugins( boolean enabled ) {
+    public void enablePlugins( final boolean enabled ) {
         m_pluginsEnabled = enabled;
     }
 
@@ -268,30 +268,29 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
      *
      *  @throws ClassNotFoundException if no such class exists.
      */
-    private Class< ? > findPluginClass( String classname ) throws ClassNotFoundException {
+    private Class< ? > findPluginClass( final String classname ) throws ClassNotFoundException {
         return ClassUtil.findClass( m_searchPath, m_externalJars, classname );
     }
 
     /**
      *  Outputs a HTML-formatted version of a stack trace.
      */
-    private String stackTrace( Map<String,String> params, Throwable t )
+    private String stackTrace( final Map<String,String> params, final Throwable t )
     {
-        Element div = XhtmlUtil.element(XHTML.div,"Plugin execution failed, stack trace follows:");
+        final Element div = XhtmlUtil.element(XHTML.div,"Plugin execution failed, stack trace follows:");
         div.setAttribute(XHTML.ATTR_class,"debug");
 
 
-        StringWriter out = new StringWriter();
+        final StringWriter out = new StringWriter();
         t.printStackTrace(new PrintWriter(out));
         div.addContent(XhtmlUtil.element(XHTML.pre,out.toString()));
         div.addContent(XhtmlUtil.element(XHTML.b,"Parameters to the plugin"));
 
-        Element list = XhtmlUtil.element(XHTML.ul);
+        final Element list = XhtmlUtil.element(XHTML.ul);
 
-        for( Iterator<Map.Entry<String,String>> i = params.entrySet().iterator(); i.hasNext(); ) {
-            Map.Entry<String,String> e = i.next();
-            String key = e.getKey();
-            list.addContent(XhtmlUtil.element(XHTML.li,key + "'='" + e.getValue()));
+        for( final Map.Entry< String, String > e : params.entrySet() ) {
+            final String key = e.getKey();
+            list.addContent( XhtmlUtil.element( XHTML.li, key + "'='" + e.getValue() ) );
         }
 
         div.addContent(list);
@@ -318,18 +317,18 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
      *  @since 2.0
      */
     @Override
-    public String execute( WikiContext context, String classname, Map< String, String > params ) throws PluginException {
+    public String execute( final WikiContext context, final String classname, final Map< String, String > params ) throws PluginException {
         if( !m_pluginsEnabled ) {
             return "";
         }
 
-        ResourceBundle rb = Preferences.getBundle( context, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
-        boolean debug = TextUtil.isPositive( params.get( PARAM_DEBUG ) );
+        final ResourceBundle rb = Preferences.getBundle( context, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
+        final boolean debug = TextUtil.isPositive( params.get( PARAM_DEBUG ) );
         try {
             //
             //   Create...
             //
-            WikiPlugin plugin = newWikiPlugin( classname, rb );
+            final WikiPlugin plugin = newWikiPlugin( classname, rb );
             if( plugin == null ) {
                 return "Plugin '" + classname + "' not compatible with this version of JSPWiki";
             }
@@ -339,14 +338,14 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
             //
             try {
                 return plugin.execute( context, params );
-            } catch( PluginException e ) {
+            } catch( final PluginException e ) {
                 if( debug ) {
                     return stackTrace( params, e );
                 }
 
                 // Just pass this exception onward.
                 throw ( PluginException )e.fillInStackTrace();
-            } catch( Throwable t ) {
+            } catch( final Throwable t ) {
                 // But all others get captured here.
                 log.info( "Plugin failed while executing:", t );
                 if( debug ) {
@@ -356,7 +355,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
                 throw new PluginException( rb.getString( "plugin.error.failed" ), t );
             }
 
-        } catch( ClassCastException e ) {
+        } catch( final ClassCastException e ) {
             throw new PluginException( MessageFormat.format( rb.getString( "plugin.error.notawikiplugin" ), classname ), e );
         }
     }
@@ -382,23 +381,22 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
      * @throws IOException If the parsing fails.
      */
     @Override
-    public Map< String, String > parseArgs( String argstring ) throws IOException {
-        Map< String, String > arglist = new HashMap< >();
+    public Map< String, String > parseArgs( final String argstring ) throws IOException {
+        final Map< String, String > arglist = new HashMap<>();
 
-        //
         //  Protection against funny users.
-        //
-        if( argstring == null ) return arglist;
+        if( argstring == null ) {
+            return arglist;
+        }
 
         arglist.put( PARAM_CMDLINE, argstring );
 
-        StringReader    in      = new StringReader(argstring);
-        StreamTokenizer tok     = new StreamTokenizer(in);
+        final StringReader    in      = new StringReader(argstring);
+        final StreamTokenizer tok     = new StreamTokenizer(in);
         int             type;
 
-
         String param = null;
-        String value = null;
+        String value;
 
         tok.eolIsSignificant( true );
 
@@ -406,7 +404,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
         boolean quit               = false;
 
         while( !quit ) {
-            String s;
+            final String s;
             type = tok.nextToken();
 
             switch( type ) {
@@ -461,10 +459,10 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
         //  Now, we'll check the body.
         //
         if( potentialEmptyLine ) {
-            StringWriter out = new StringWriter();
+            final StringWriter out = new StringWriter();
             FileUtil.copyContents( in, out );
 
-            String bodyContent = out.toString();
+            final String bodyContent = out.toString();
 
             if( bodyContent != null ) {
                 arglist.put( PARAM_BODY, bodyContent );
@@ -489,32 +487,32 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
      *  @throws PluginException From the plugin itself, it propagates, waah!
      */
     @Override
-    public String execute( WikiContext context, String commandline ) throws PluginException {
+    public String execute( final WikiContext context, final String commandline ) throws PluginException {
         if( !m_pluginsEnabled ) {
             return "";
         }
 
-        ResourceBundle rb = Preferences.getBundle( context, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
-        PatternMatcher matcher = new Perl5Matcher();
+        final ResourceBundle rb = Preferences.getBundle( context, WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE );
+        final PatternMatcher matcher = new Perl5Matcher();
 
         try {
             if( matcher.contains( commandline, m_pluginPattern ) ) {
-                MatchResult res = matcher.getMatch();
+                final MatchResult res = matcher.getMatch();
 
-                String plugin   = res.group(2);
-                String args     = commandline.substring(res.endOffset(0),
+                final String plugin   = res.group(2);
+                final String args     = commandline.substring(res.endOffset(0),
                                                         commandline.length() -
                                                         (commandline.charAt(commandline.length()-1) == '}' ? 1 : 0 ) );
-                Map<String, String> arglist  = parseArgs( args );
+                final Map<String, String> arglist  = parseArgs( args );
 
                 return execute( context, plugin, arglist );
             }
-        } catch( NoSuchElementException e ) {
-            String msg =  "Missing parameter in plugin definition: "+commandline;
+        } catch( final NoSuchElementException e ) {
+            final String msg =  "Missing parameter in plugin definition: "+commandline;
             log.warn( msg, e );
             throw new PluginException( MessageFormat.format( rb.getString( "plugin.error.missingparameter" ), commandline ) );
-        } catch( IOException e ) {
-            String msg = "Zyrf.  Problems with parsing arguments: "+commandline;
+        } catch( final IOException e ) {
+            final String msg = "Zyrf.  Problems with parsing arguments: "+commandline;
             log.warn( msg, e );
             throw new PluginException( MessageFormat.format( rb.getString( "plugin.error.parsingarguments" ), commandline ) );
         }
@@ -528,7 +526,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
     /**
      *  Register a plugin.
      */
-    private void registerPlugin( WikiPluginInfo pluginClass ) {
+    private void registerPlugin( final WikiPluginInfo pluginClass ) {
         String name;
 
         // Registrar the plugin with the className without the package-part
@@ -557,16 +555,16 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
 
     private void registerPlugins() {
         log.info( "Registering plugins" );
-        List< Element > plugins = XmlUtil.parse( PLUGIN_RESOURCE_LOCATION, "/modules/plugin" );
+        final List< Element > plugins = XmlUtil.parse( PLUGIN_RESOURCE_LOCATION, "/modules/plugin" );
 
         //
         // Register all plugins which have created a resource containing its properties.
         //
         // Get all resources of all plugins.
         //
-        for( Element pluginEl : plugins ) {
-            String className = pluginEl.getAttributeValue( "class" );
-            WikiPluginInfo pluginInfo = WikiPluginInfo.newInstance( className, pluginEl ,m_searchPath, m_externalJars);
+        for( final Element pluginEl : plugins ) {
+            final String className = pluginEl.getAttributeValue( "class" );
+            final WikiPluginInfo pluginInfo = WikiPluginInfo.newInstance( className, pluginEl ,m_searchPath, m_externalJars);
 
             if( pluginInfo != null ) {
                 registerPlugin( pluginInfo );
@@ -601,10 +599,10 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
          *  @param externalJars the list of external jars to search
          *  @return A WikiPluginInfo object.
          */
-        protected static WikiPluginInfo newInstance( String className, Element el, List<String> searchPath, List<String> externalJars ) {
+        protected static WikiPluginInfo newInstance( final String className, final Element el, final List<String> searchPath, final List<String> externalJars ) {
             if( className == null || className.length() == 0 ) return null;
 
-            WikiPluginInfo info = new WikiPluginInfo( className );
+            final WikiPluginInfo info = new WikiPluginInfo( className );
             info.initializeFromXML( el );
             return info;
         }
@@ -618,24 +616,24 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
          *  @param searchPath A List of Strings, containing different package names.
          *  @param externalJars the list of external jars to search
          */
-        protected void initializePlugin( WikiPluginInfo info, WikiEngine engine , List<String> searchPath, List<String> externalJars) {
+        protected void initializePlugin( final WikiPluginInfo info, final Engine engine , final List<String> searchPath, final List<String> externalJars) {
             if( !m_initialized ) {
                 // This makes sure we only try once per class, even if init fails.
                 m_initialized = true;
 
                 try {
-                    WikiPlugin p = newPluginInstance(searchPath, externalJars);
+                    final WikiPlugin p = newPluginInstance(searchPath, externalJars);
                     if( p instanceof InitializablePlugin ) {
                         ( ( InitializablePlugin )p ).initialize( engine );
                     }
                     if( p instanceof WikiAjaxServlet ) {
                     	WikiAjaxDispatcherServlet.registerServlet( (WikiAjaxServlet) p );
-                    	String ajaxAlias = info.getAjaxAlias();
+                    	final String ajaxAlias = info.getAjaxAlias();
                     	if (StringUtils.isNotBlank(ajaxAlias)) {
                     		WikiAjaxDispatcherServlet.registerServlet( info.getAjaxAlias(), (WikiAjaxServlet) p );
                     	}
                     }
-                } catch( Exception e ) {
+                } catch( final Exception e ) {
                     log.info( "Cannot initialize plugin " + m_className, e );
                 }
             }
@@ -645,7 +643,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
          *  {@inheritDoc}
          */
         @Override
-        protected void initializeFromXML( Element el ) {
+        protected void initializeFromXML( final Element el ) {
             super.initializeFromXML( el );
             m_alias = el.getChildText( "alias" );
             m_ajaxAlias = el.getChildText( "ajaxAlias" );
@@ -657,16 +655,16 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
          *  @param clazz The class to check
          *  @return A WikiPluginInfo instance
          */
-        protected static WikiPluginInfo newInstance( Class< ? > clazz ) {
+        protected static WikiPluginInfo newInstance( final Class< ? > clazz ) {
         	return new WikiPluginInfo( clazz.getName() );
         }
 
-        private WikiPluginInfo( String className ) {
+        private WikiPluginInfo( final String className ) {
             super( className );
             setClassName( className );
         }
 
-        private void setClassName( String fullClassName ) {
+        private void setClassName( final String fullClassName ) {
             m_name = ClassUtils.getShortClassName( fullClassName );
             m_className = fullClassName;
         }
@@ -707,7 +705,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
          *  @throws IllegalAccessException If the class cannot be accessed.
          */
 
-        public WikiPlugin newPluginInstance(List<String> searchPath, List<String> externalJars) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+        public WikiPlugin newPluginInstance( final List<String> searchPath, final List<String> externalJars) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
             if( m_clazz == null ) {
                 m_clazz = ClassUtil.findClass(searchPath, externalJars ,m_className);
             }
@@ -721,14 +719,14 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
          *  @param type Either "script" or "stylesheet"
          *  @return Text, or an empty string, if there is nothing to be included.
          */
-        public String getIncludeText( String type ) {
+        public String getIncludeText( final String type ) {
             try {
                 if( "script".equals( type ) ) {
                     return getScriptText();
                 } else if( "stylesheet".equals( type ) ) {
                     return getStylesheetText();
                 }
-            } catch( Exception ex ) {
+            } catch( final Exception ex ) {
                 // We want to fail gracefully here
                 return ex.getMessage();
             }
@@ -747,7 +745,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
 
             try {
                 m_scriptText = getTextResource(m_scriptLocation);
-            } catch( IOException ex ) {
+            } catch( final IOException ex ) {
                 // Only throw this exception once!
                 m_scriptText = "";
                 throw ex;
@@ -767,7 +765,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
 
             try {
                 m_stylesheetText = getTextResource(m_stylesheetLocation);
-            } catch( IOException ex ) {
+            } catch( final IOException ex ) {
                 // Only throw this exception once!
                 m_stylesheetText = "";
                 throw ex;
@@ -799,7 +797,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
      *  {@inheritDoc}
      */
     @Override
-    public WikiPluginInfo getModuleInfo(String moduleName) {
+    public WikiPluginInfo getModuleInfo( final String moduleName) {
         return m_pluginClassMap.get(moduleName);
     }
 
@@ -812,7 +810,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
      * @throws PluginException if there is a problem building the {@link WikiPlugin}.
      */
     @Override
-    public WikiPlugin newWikiPlugin( String pluginName, ResourceBundle rb ) throws PluginException {
+    public WikiPlugin newWikiPlugin( final String pluginName, final ResourceBundle rb ) throws PluginException {
         WikiPlugin plugin = null;
         WikiPluginInfo pluginInfo = m_pluginClassMap.get( pluginName );
         try {
@@ -822,18 +820,18 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
             }
 
             if( !checkCompatibility( pluginInfo ) ) {
-                String msg = "Plugin '" + pluginInfo.getName() + "' not compatible with this version of JSPWiki";
+                final String msg = "Plugin '" + pluginInfo.getName() + "' not compatible with this version of JSPWiki";
                 log.info( msg );
             } else {
                 plugin = pluginInfo.newPluginInstance(m_searchPath, m_externalJars);
             }
-        } catch( ClassNotFoundException e ) {
+        } catch( final ClassNotFoundException e ) {
             throw new PluginException( MessageFormat.format( rb.getString( "plugin.error.couldnotfind" ), pluginName ), e );
-        } catch( InstantiationException e ) {
+        } catch( final InstantiationException e ) {
             throw new PluginException( MessageFormat.format( rb.getString( "plugin.error.cannotinstantiate" ), pluginName ), e );
-        } catch( IllegalAccessException e ) {
+        } catch( final IllegalAccessException e ) {
             throw new PluginException( MessageFormat.format( rb.getString( "plugin.error.notallowed" ), pluginName ), e );
-        } catch( Exception e ) {
+        } catch( final Exception e ) {
             throw new PluginException( MessageFormat.format( rb.getString( "plugin.error.instantationfailed" ), pluginName ), e );
         }
         return plugin;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
index 217c1bd..0d2f5f3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
@@ -26,6 +26,7 @@ import org.apache.wiki.modules.ModuleManager;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.util.XmlUtil;
+import org.apache.wiki.variables.VariableManager;
 import org.jdom2.Element;
 
 import javax.servlet.jsp.PageContext;
@@ -147,7 +148,7 @@ public class EditorManager extends ModuleManager {
         if( editor == null ) {
             // or use the default editor in jspwiki.properties
             try {
-                editor = m_engine.getVariableManager().getValue( context, PROP_EDITORTYPE );
+                editor = m_engine.getManager( VariableManager.class ).getValue( context, PROP_EDITORTYPE );
             } catch( final NoSuchVariableException e ) {} // This is fine
         }
 
@@ -224,7 +225,7 @@ public class EditorManager extends ModuleManager {
             return info;
         }
 
-        protected void initializeFromXML( final Element el ) {
+        @Override protected void initializeFromXML( final Element el ) {
             super.initializeFromXML( el );
             m_path = el.getChildText("path");
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
index c2db396..68441f9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
@@ -22,7 +22,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.modules.ModuleManager;
 import org.apache.wiki.modules.WikiModuleInfo;
@@ -122,7 +122,7 @@ public class TemplateManager extends ModuleManager {
      *  @param engine The owning engine.
      *  @param properties The property list used to initialize this.
      */
-    public TemplateManager( final WikiEngine engine, final Properties properties ) {
+    public TemplateManager( final Engine engine, final Properties properties ) {
         super( engine );
 
         //


[jspwiki] 10/20: JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (5)

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 f3005db149bbfa8c8c38f03eb3bddcbe286fa67e
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 19:23:50 2020 +0100

    JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (5)
---
 .../java/org/apache/wiki/ui/CommandResolver.java   |   4 +-
 .../org/apache/wiki/ui/DefaultCommandResolver.java |  15 +--
 .../java/org/apache/wiki/ui/EditorManager.java     |  35 +++---
 .../main/java/org/apache/wiki/ui/Installer.java    |  15 +--
 .../main/java/org/apache/wiki/ui/WikiCommand.java  |  18 +--
 .../java/org/apache/wiki/ui/WikiJSPFilter.java     |  30 +++--
 .../org/apache/wiki/ui/WikiRequestWrapper.java     |  10 +-
 .../java/org/apache/wiki/ui/WikiServletFilter.java |  22 ++--
 .../wiki/ui/admin/DefaultAdminBeanManager.java     | 135 ++++++++++-----------
 .../org/apache/wiki/ui/admin/SimpleAdminBean.java  |  74 +++++------
 .../org/apache/wiki/ui/admin/beans/ModuleBean.java |  11 +-
 11 files changed, 178 insertions(+), 191 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java
index 350523f..c684b2a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java
@@ -26,7 +26,7 @@ import java.util.Arrays;
 
 
 /**
- * <p>Resolves special pages, JSPs and Commands on behalf of a WikiEngine. CommandResolver will automatically resolve page names
+ * <p>Resolves special pages, JSPs and Commands on behalf of a Engine. CommandResolver will automatically resolve page names
  * with singular/plural variants. It can also detect the correct Command based on parameters supplied in an HTTP request, or due to the
  * JSP being accessed.</p>
  * <p>
@@ -36,7 +36,7 @@ import java.util.Arrays;
  * <p>For more complex lookups in which the caller supplies an HTTP request, {@link #findCommand(HttpServletRequest, String)} will
  * look up and return the correct Command. The String parameter <code>defaultContext</code> supplies the request context to use
  * if it cannot be detected. However, note that the default wiki context may be overridden if the request was for a "special page."</p>
- * <p>For example, suppose the WikiEngine's properties specify a special page called <code>UserPrefs</code> that redirects to
+ * <p>For example, suppose the Engine's properties specify a special page called <code>UserPrefs</code> that redirects to
  * <code>UserPreferences.jsp</code>. The ordinary lookup method {@linkplain #findCommand(String)} using a supplied context <code>view</code>
  * would return {@link PageCommand#VIEW}. But the {@linkplain #findCommand(HttpServletRequest, String)} method, when passed the same context
  * (<code>view</code>) and an HTTP request containing the page parameter value <code>UserPrefs</code>, will instead return
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java
index ce25685..1ee198e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultCommandResolver.java
@@ -20,13 +20,14 @@ package org.apache.wiki.ui;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.InternalWikiException;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.auth.GroupPrincipal;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.parser.MarkupParser;
+import org.apache.wiki.url.URLConstructor;
 import org.apache.wiki.util.TextUtil;
 
 import javax.servlet.http.HttpServletRequest;
@@ -62,7 +63,7 @@ public final class DefaultCommandResolver implements CommandResolver {
 
     private static final Logger LOG = Logger.getLogger( DefaultCommandResolver.class );
 
-    private final WikiEngine m_engine;
+    private final Engine m_engine;
 
     /** If true, we'll also consider english plurals (+s) a match. */
     private final boolean m_matchEnglishPlurals;
@@ -71,13 +72,13 @@ public final class DefaultCommandResolver implements CommandResolver {
     private final Map<String, Command> m_specialPages;
 
     /**
-     * Constructs a CommandResolver for a given WikiEngine. This constructor will extract the special page references for this wiki and
+     * Constructs a CommandResolver for a given Engine. This constructor will extract the special page references for this wiki and
      * store them in a cache used for resolution.
      *
      * @param engine the wiki engine
      * @param properties the properties used to initialize the wiki
      */
-    public DefaultCommandResolver( final WikiEngine engine, final Properties properties ) {
+    public DefaultCommandResolver( final Engine engine, final Properties properties ) {
         m_engine = engine;
         m_specialPages = new HashMap<>();
 
@@ -101,7 +102,7 @@ public final class DefaultCommandResolver implements CommandResolver {
         }
 
         // Do we match plurals?
-        m_matchEnglishPlurals = TextUtil.getBooleanProperty( properties, WikiEngine.PROP_MATCHPLURALS, true );
+        m_matchEnglishPlurals = TextUtil.getBooleanProperty( properties, Engine.PROP_MATCHPLURALS, true );
     }
 
     /**
@@ -214,7 +215,7 @@ public final class DefaultCommandResolver implements CommandResolver {
     public String getSpecialPageReference( final String page ) {
         final Command command = m_specialPages.get( page );
         if ( command != null ) {
-            return m_engine.getURLConstructor().makeURL( command.getRequestContext(), command.getURLPattern(), null );
+            return m_engine.getManager( URLConstructor.class ).makeURL( command.getRequestContext(), command.getURLPattern(), null );
         }
 
         return null;
@@ -266,7 +267,7 @@ public final class DefaultCommandResolver implements CommandResolver {
     public String extractPageFromParameter( final String requestContext, final HttpServletRequest request ) {
         // Extract the page name from the URL directly
         try {
-            String page = m_engine.getURLConstructor().parsePage( requestContext, request, m_engine.getContentEncoding() );
+            String page = m_engine.getManager( URLConstructor.class ).parsePage( requestContext, request, m_engine.getContentEncoding() );
             if ( page != null ) {
                 try {
                     // Look for singular/plural variants; if one not found, take the one the user supplied
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
index 0d2f5f3..9d173fd 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
@@ -20,7 +20,7 @@ package org.apache.wiki.ui;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.NoSuchVariableException;
 import org.apache.wiki.modules.ModuleManager;
 import org.apache.wiki.modules.WikiModuleInfo;
@@ -39,21 +39,19 @@ import java.util.Set;
 
 
 /**
- *  Defines an editor manager.  An editor can be added by adding a
- *  suitable JSP file under templates/default/editors
- *  If you want your editor to include any scripts or something, you
- *  can simply request it by adding the following in your
- *  ini/jspwiki_module.xml:
+ *  Defines an editor manager.  An editor can be added by adding a suitable JSP file under templates/default/editors
+ *  If you want your editor to include any scripts or something, you can simply request it by adding the following in your
+ *  {@code ini/jspwiki_module.xml}:
  *
  *  <pre>
- *  <modules>
- *   <editor name="myeditor">
- *       <author>Janne Jalkanen</author>
- *       <script>foo.js</script>
- *       <stylesheet>foo.css</stylesheet>
- *       <path>editors/myeditor.jsp</path>
- *   </editor>
- *  </modules>
+ *  &lt;modules>
+ *   &lt;editor name="myeditor">
+ *       &lt;author>Janne Jalkanen&lt;/author>
+ *       &lt;script>foo.js&lt;/script>
+ *       &lt;stylesheet>foo.css&lt;/stylesheet>
+ *       &lt;path>editors/myeditor.jsp&lt;/path>
+ *   &lt;/editor>
+ *  &lt;/modules>
  *  </pre>
  *
  *  @since 2.4
@@ -82,7 +80,7 @@ public class EditorManager extends ModuleManager {
 
     private static final Logger log = Logger.getLogger( EditorManager.class );
 
-    public EditorManager( final WikiEngine engine ) {
+    public EditorManager( final Engine engine ) {
         super( engine );
     }
 
@@ -96,9 +94,7 @@ public class EditorManager extends ModuleManager {
     }
 
     /**
-     *  This method goes through the jspwiki_module.xml files and hunts for editors.
-     *  Any editors found are put in the registry.
-     *
+     *  This method goes through the jspwiki_module.xml files and hunts for editors. Any editors found are put in the registry.
      */
     private void registerEditors() {
         log.info( "Registering editor modules" );
@@ -225,7 +221,8 @@ public class EditorManager extends ModuleManager {
             return info;
         }
 
-        @Override protected void initializeFromXML( final Element el ) {
+        @Override
+        protected void initializeFromXML( final Element el ) {
             super.initializeFromXML( el );
             m_path = el.getChildText("path");
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
index 243a67b..cad8a35 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java
@@ -20,6 +20,7 @@ package org.apache.wiki.ui;
 
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.auth.NoSuchPrincipalException;
 import org.apache.wiki.auth.UserManager;
 import org.apache.wiki.auth.WikiPrincipal;
@@ -58,17 +59,17 @@ public class Installer {
     public static final String INSTALL_INFO = "Installer.Info";
     public static final String INSTALL_ERROR = "Installer.Error";
     public static final String INSTALL_WARNING = "Installer.Warning";
-    public static final String APP_NAME = WikiEngine.PROP_APPNAME;
+    public static final String APP_NAME = Engine.PROP_APPNAME;
     public static final String STORAGE_DIR = BasicAttachmentProvider.PROP_STORAGEDIR;
     public static final String PAGE_DIR = FileSystemProvider.PROP_PAGEDIR;
-    public static final String WORK_DIR = WikiEngine.PROP_WORKDIR;
+    public static final String WORK_DIR = Engine.PROP_WORKDIR;
     public static final String ADMIN_GROUP = "Admin";
     public static final String PROPFILENAME = "jspwiki-custom.properties" ;
     public static final String TMP_DIR = System.getProperty("java.io.tmpdir");
     private final WikiSession m_session;
     private final File m_propertyFile;
     private final Properties m_props;
-    private final WikiEngine m_engine;
+    private final Engine m_engine;
     private HttpServletRequest m_request;
     private boolean m_validated;
     
@@ -93,7 +94,7 @@ public class Installer {
      */
     public boolean adminExists() {
         // See if the admin user exists already
-        final UserManager userMgr = m_engine.getUserManager();
+        final UserManager userMgr = m_engine.getManager( UserManager.class );
         final UserDatabase userDb = userMgr.getUserDatabase();
         try {
             userDb.findByLoginName( ADMIN_ID );
@@ -118,7 +119,7 @@ public class Installer {
         }
         
         // See if the admin user exists already
-        final UserManager userMgr = m_engine.getUserManager();
+        final UserManager userMgr = m_engine.getManager( UserManager.class );
         final UserDatabase userDb = userMgr.getUserDatabase();
         String password = null;
         
@@ -135,7 +136,7 @@ public class Installer {
         }
         
         // Create a new admin group
-        final GroupManager groupMgr = m_engine.getGroupManager();
+        final GroupManager groupMgr = m_engine.getManager( GroupManager.class );
         Group group;
         try {
             group = groupMgr.getGroup( ADMIN_GROUP );
@@ -166,7 +167,7 @@ public class Installer {
     }
 
     /**
-     * Returns a property from the WikiEngine's properties.
+     * Returns a property from the Engine's properties.
      * @param key the property key
      * @return the property value
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiCommand.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiCommand.java
index 1f22b44..1d81475 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiCommand.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiCommand.java
@@ -27,7 +27,7 @@ import java.security.Permission;
  * <p>Defines Commands for wiki-wide operations such as creating groups, editing preferences and profiles, and logging in/out.
  * WikiCommands can be combined with Strings (representing the name of a wiki instance) to produce targeted Commands.</p>
  *
- * @see org.apache.wiki.WikiEngine#getApplicationName()
+ * @see org.apache.wiki.api.core.Engine#getApplicationName()
  * @since 2.4.22
  */
 public final class WikiCommand extends AbstractCommand {
@@ -91,11 +91,13 @@ public final class WikiCommand extends AbstractCommand {
     }
 
     /**
-     *  Constructs an admin command.
+     * Constructs an admin command.
      *  
-     *  @param requestContext
-     *  @param urlPattern
-     *  @param contentTemplate
+     * @param requestContext the request context
+     * @param urlPattern the URL pattern
+     * @param contentTemplate the content template; may be <code>null</code>
+     * @param target the target of the command, such as a WikiPage; may be <code>null</code>
+     * @throws IllegalArgumentException if the request content or URL pattern is <code>null</code>
      */
     private WikiCommand( final String requestContext, final String urlPattern, final String contentTemplate, final String target ) {
         super( requestContext, urlPattern, contentTemplate, target );
@@ -111,7 +113,7 @@ public final class WikiCommand extends AbstractCommand {
      * @return the new targeted command
      * @throws IllegalArgumentException if the target is not of the correct type
      */
-    public Command targetedCommand( final Object target ) {
+    @Override public Command targetedCommand( final Object target ) {
         if ( !( target instanceof String ) ) {
             throw new IllegalArgumentException( "Target must non-null and of type String." );
         }
@@ -123,14 +125,14 @@ public final class WikiCommand extends AbstractCommand {
      *
      * @see org.apache.wiki.ui.Command#getName()
      */
-    public String getName() {
+    @Override public String getName() {
         return getJSPFriendlyName();
     }
 
     /**
      * @see org.apache.wiki.ui.Command#requiredPermission()
      */
-    public Permission requiredPermission() {
+    @Override public Permission requiredPermission() {
         return m_permission;
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
index 03e16cd..3924000 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
@@ -23,7 +23,7 @@ import org.apache.log4j.Logger;
 import org.apache.log4j.NDC;
 import org.apache.wiki.WatchDog;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.url.DefaultURLConstructor;
@@ -77,14 +77,16 @@ public class WikiJSPFilter extends WikiServletFilter {
     private boolean useEncoding;
 
     /** {@inheritDoc} */
-    @Override public void init( final FilterConfig config ) throws ServletException {
+    @Override
+    public void init( final FilterConfig config ) throws ServletException {
         super.init( config );
-        m_wiki_encoding = m_engine.getWikiProperties().getProperty(WikiEngine.PROP_ENCODING);
+        m_wiki_encoding = m_engine.getWikiProperties().getProperty( Engine.PROP_ENCODING );
 
-        useEncoding = !( Boolean.valueOf( m_engine.getWikiProperties().getProperty( WikiEngine.PROP_NO_FILTER_ENCODING, "false" ).trim() ).booleanValue() );
+        useEncoding = !Boolean.parseBoolean( m_engine.getWikiProperties().getProperty( Engine.PROP_NO_FILTER_ENCODING, "false" ).trim() );
     }
 
-    @Override public void doFilter( final ServletRequest  request, final ServletResponse response, final FilterChain chain ) throws ServletException, IOException {
+    @Override
+    public void doFilter( final ServletRequest  request, final ServletResponse response, final FilterChain chain ) throws ServletException, IOException {
         final WatchDog w = WatchDog.getCurrentWatchDog( m_engine );
         try {
             NDC.push( m_engine.getApplicationName()+":"+((HttpServletRequest)request).getRequestURI() );
@@ -226,18 +228,19 @@ public class WikiJSPFilter extends WikiServletFilter {
             m_response = r;
         }
 
-        /**
-         *  Returns a writer for output; this wraps the internal buffer into a PrintWriter.
-         */
-        @Override public PrintWriter getWriter() {
+        /** Returns a writer for output; this wraps the internal buffer into a PrintWriter. */
+        @Override
+        public PrintWriter getWriter() {
             return m_writer;
         }
 
-        @Override public ServletOutputStream getOutputStream() {
+        @Override
+        public ServletOutputStream getOutputStream() {
             return m_servletOut;
         }
 
-        @Override public void flushBuffer() throws IOException {
+        @Override
+        public void flushBuffer() throws IOException {
             m_writer.flush();
             super.flushBuffer();
         }
@@ -272,7 +275,8 @@ public class WikiJSPFilter extends WikiServletFilter {
         }
 
         /** Returns whatever was written so far into the Writer. */
-        @Override public String toString() {
+        @Override
+        public String toString() {
             try {
 				flushBuffer();
 			} catch( final IOException e ) {
@@ -298,7 +302,7 @@ public class WikiJSPFilter extends WikiServletFilter {
 
     /**
      *  Fires a WikiPageEvent of the provided type and page name
-     *  to all registered listeners of the current WikiEngine.
+     *  to all registered listeners of the current Engine.
      *
      * @see org.apache.wiki.event.WikiPageEvent
      * @param type       the event type to be fired
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java
index a0a9f48..5abfd26 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiRequestWrapper.java
@@ -18,8 +18,8 @@
  */
 package org.apache.wiki.ui;
 
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.auth.SessionMonitor;
 import org.apache.wiki.auth.authorize.Role;
 
@@ -43,7 +43,7 @@ public class WikiRequestWrapper extends HttpServletRequestWrapper {
      * @param engine the wiki engine
      * @param request the request to wrap
      */
-    public WikiRequestWrapper( final WikiEngine engine, final HttpServletRequest request ) {
+    public WikiRequestWrapper( final Engine engine, final HttpServletRequest request ) {
         super( request );
 
         // Get and stash a reference to the current WikiSession
@@ -56,7 +56,7 @@ public class WikiRequestWrapper extends HttpServletRequestWrapper {
      * WikiSession is an authenticated session (that is, {@link WikiSession#isAuthenticated()} returns <code>true</code>,
      * this method returns the name of the principal returned by {@link WikiSession#getLoginPrincipal()}.
      */
-    public String getRemoteUser() {
+    @Override public String getRemoteUser() {
         if( super.getRemoteUser() != null ) {
             return super.getRemoteUser();
         }
@@ -73,7 +73,7 @@ public class WikiRequestWrapper extends HttpServletRequestWrapper {
      * WikiSession is an authenticated session (that is, {@link WikiSession#isAuthenticated()} returns
      * <code>true</code>, this method returns the value of {@link WikiSession#getLoginPrincipal()}.
      */
-    public Principal getUserPrincipal() {
+    @Override public Principal getUserPrincipal() {
         if( super.getUserPrincipal() != null ) {
             return super.getUserPrincipal();
         }
@@ -90,7 +90,7 @@ public class WikiRequestWrapper extends HttpServletRequestWrapper {
      * this method iterates through the built-in Role objects (<em>e.g.</em>, ANONYMOUS, ASSERTED, AUTHENTICATED) returned by
      * {@link WikiSession#getRoles()} and checks to see if any of these principals' names match the supplied role.
      */
-    public boolean isUserInRole( final String role ) {
+    @Override public boolean isUserInRole( final String role ) {
         final boolean hasContainerRole = super.isUserInRole(role);
         if( hasContainerRole ) {
             return true;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
index 33c9454..39ff442 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
@@ -23,6 +23,8 @@ import org.apache.log4j.NDC;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.auth.AuthenticationManager;
 import org.apache.wiki.auth.SessionMonitor;
 import org.apache.wiki.auth.WikiSecurityException;
 
@@ -39,7 +41,7 @@ import java.io.IOException;
 import java.io.PrintWriter;
 
 /**
- * Filter that verifies that the {@link org.apache.wiki.WikiEngine} is running, and sets the authentication status for the user's
+ * Filter that verifies that the {@link org.apache.wiki.api.core.Engine} is running, and sets the authentication status for the user's
  * WikiSession. Each HTTP request processed by this filter is wrapped by a {@link WikiRequestWrapper}. The wrapper's primary responsibility
  * is to return the correct <code>userPrincipal</code> and <code>remoteUser</code> for authenticated JSPWiki users (whether authenticated
  * by container or by JSPWiki's custom system). The wrapper's other responsibility is to incorporate JSPWiki built-in roles
@@ -50,7 +52,7 @@ import java.io.PrintWriter;
 public class WikiServletFilter implements Filter {
 
     private static final Logger log = Logger.getLogger( WikiServletFilter.class );
-    protected WikiEngine m_engine = null;
+    protected Engine m_engine = null;
 
     /**
      *  Creates a Wiki Servlet Filter.
@@ -64,14 +66,14 @@ public class WikiServletFilter implements Filter {
      * Initializes the WikiServletFilter.
      * 
      * @param config The FilterConfig.
-     * @throws ServletException If a WikiEngine cannot be started.
+     * @throws ServletException If a Engine cannot be started.
      */
-    public void init( final FilterConfig config ) throws ServletException {
+    @Override public void init( final FilterConfig config ) throws ServletException {
         final ServletContext context = config.getServletContext();
 
         // TODO REMOVEME when resolving JSPWIKI-129
         if( System.getSecurityManager() != null ) {
-            context.log( "== JSPWIKI WARNING ==   : This container is running with a security manager. JSPWiki does not yet really support that right now. See issue JSPWIKI-129 for details and information on how to proceed." );
+            context.log( "== JSPWIKI WARNING ==  : This container is running with a security manager. JSPWiki does not yet really support that right now. See issue JSPWIKI-129 for details and information on how to proceed." );
         }
 
         m_engine = WikiEngine.getInstance( context, null );
@@ -80,11 +82,11 @@ public class WikiServletFilter implements Filter {
     /**
      * Destroys the WikiServletFilter.
      */
-    public void destroy() {
+    @Override public void destroy() {
     }
 
     /**
-    * Checks that the WikiEngine is running ok, wraps the current HTTP request, and sets the correct authentication state for the users's
+    * Checks that the Engine is running ok, wraps the current HTTP request, and sets the correct authentication state for the users's
     * WikiSession. First, the method {@link org.apache.wiki.auth.AuthenticationManager#login(HttpServletRequest)}
     * executes, which sets the authentication state. Then, the request is wrapped with a
     * {@link WikiRequestWrapper}.
@@ -94,7 +96,7 @@ public class WikiServletFilter implements Filter {
     * @throws ServletException if {@link org.apache.wiki.auth.AuthenticationManager#login(HttpServletRequest)} fails for any reason
     * @throws IOException If writing to the servlet response fails. 
     */
-    public void doFilter( final ServletRequest request, final ServletResponse response, final FilterChain chain ) throws IOException, ServletException {
+    @Override public void doFilter( final ServletRequest request, final ServletResponse response, final FilterChain chain ) throws IOException, ServletException {
         //  Sanity check; it might be true in some conditions, but we need to know where.
         if( chain == null ) {
             throw new ServletException("FilterChain is null, even if it should not be.  Please report this to the jspwiki development team.");
@@ -125,7 +127,7 @@ public class WikiServletFilter implements Filter {
         if ( !isWrapped( request ) ) {
             // Prepare the WikiSession
             try {
-                m_engine.getAuthenticationManager().login( httpRequest );
+                m_engine.getManager( AuthenticationManager.class ).login( httpRequest );
                 final WikiSession wikiSession = SessionMonitor.getInstance( m_engine ).find( httpRequest.getSession() );
                 httpRequest = new WikiRequestWrapper( m_engine, httpRequest );
                 if ( log.isDebugEnabled() ) {
@@ -137,7 +139,7 @@ public class WikiServletFilter implements Filter {
         }
 
         try {
-            NDC.push( m_engine.getApplicationName()+":"+httpRequest.getRequestURL() );
+            NDC.push( m_engine.getApplicationName() + ":" + httpRequest.getRequestURL() );
             chain.doFilter( httpRequest, response );
         } finally {
             NDC.pop();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
index ff94ccc..8fc3500 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
@@ -18,35 +18,36 @@
  */
 package org.apache.wiki.ui.admin;
 
-import java.lang.management.ManagementFactory;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import javax.management.DynamicMBean;
-import javax.management.InstanceAlreadyExistsException;
-import javax.management.InstanceNotFoundException;
-import javax.management.MBeanRegistrationException;
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.NotCompliantMBeanException;
-import javax.management.ObjectName;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.Release;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 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.event.WikiEngineEvent;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.modules.WikiModuleInfo;
+import org.apache.wiki.ui.EditorManager;
 import org.apache.wiki.ui.admin.beans.CoreBean;
 import org.apache.wiki.ui.admin.beans.FilterBean;
 import org.apache.wiki.ui.admin.beans.PluginBean;
 import org.apache.wiki.ui.admin.beans.SearchManagerBean;
 import org.apache.wiki.ui.admin.beans.UserBean;
 
+import javax.management.DynamicMBean;
+import javax.management.InstanceAlreadyExistsException;
+import javax.management.InstanceNotFoundException;
+import javax.management.MBeanRegistrationException;
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.NotCompliantMBeanException;
+import javax.management.ObjectName;
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
 
 /**
  *  Provides a manager class for all AdminBeans within JSPWiki.  This class also manages registration for any
@@ -56,14 +57,13 @@ import org.apache.wiki.ui.admin.beans.UserBean;
  */
 public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanManager {
 
-    private WikiEngine m_engine;
+    private Engine m_engine;
     private ArrayList< AdminBean >  m_allBeans;
+    private MBeanServer m_mbeanServer;
 
-    private MBeanServer m_mbeanServer = null;
+    private static final Logger log = Logger.getLogger(DefaultAdminBeanManager.class);
 
-    private static Logger log = Logger.getLogger(DefaultAdminBeanManager.class);
-
-    public DefaultAdminBeanManager( WikiEngine engine ) {
+    public DefaultAdminBeanManager( final Engine engine ) {
         log.info("Using JDK 1.5 Platform MBeanServer");
         m_mbeanServer = MBeanServerFactory15.getServer();
 
@@ -86,7 +86,7 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
         reload();
     }
 
-    private String getJMXTitleString( int title ) {
+    private String getJMXTitleString( final int title ) {
         switch( title ) {
             case AdminBean.CORE:
                 return "Core";
@@ -102,15 +102,14 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
 
 
     /**
-     *  Register an AdminBean.  If the AdminBean is also a JMX MBean, it also gets registered to the MBeanServer
-     *  we've found.
+     *  Register an AdminBean.  If the AdminBean is also a JMX MBean, it also gets registered to the MBeanServer we've found.
      *
      *  @param ab AdminBean to register.
      */
-    private void registerAdminBean( AdminBean ab ) {
+    private void registerAdminBean( final AdminBean ab ) {
         try {
             if( ab instanceof DynamicMBean && m_mbeanServer != null ) {
-                ObjectName name = getObjectName( ab );
+                final ObjectName name = getObjectName( ab );
 
                 if( !m_mbeanServer.isRegistered( name ) ) {
                     m_mbeanServer.registerMBean( ab, name );
@@ -120,25 +119,23 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
             m_allBeans.add( ab );
 
             log.info("Registered new admin bean "+ab.getTitle());
-        } catch( InstanceAlreadyExistsException e ) {
+        } catch( final InstanceAlreadyExistsException e ) {
             log.error("Admin bean already registered to JMX",e);
-        } catch( MBeanRegistrationException e ) {
+        } catch( final MBeanRegistrationException e ) {
             log.error("Admin bean cannot be registered to JMX",e);
-        } catch( NotCompliantMBeanException e ) {
+        } catch( final NotCompliantMBeanException e ) {
             log.error("Your admin bean is not very good",e);
-        } catch( MalformedObjectNameException e ) {
+        } catch( final MalformedObjectNameException e ) {
             log.error("Your admin bean name is not very good",e);
-        } catch( NullPointerException e ) {
+        } catch( final NullPointerException e ) {
             log.error("Evil NPE occurred",e);
         }
     }
 
-    private ObjectName getObjectName(AdminBean ab) throws MalformedObjectNameException {
-        String component = getJMXTitleString( ab.getType() );
-        String title     = ab.getTitle();
-
-        ObjectName name = new ObjectName( Release.APPNAME + ":component="+component+",name="+title );
-        return name;
+    private ObjectName getObjectName( final AdminBean ab ) throws MalformedObjectNameException {
+        final String component = getJMXTitleString( ab.getType() );
+        final String title     = ab.getTitle();
+        return new ObjectName( Release.APPNAME + ":component="+component+",name="+title );
     }
 
     /**
@@ -147,21 +144,16 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
      *
      *  @param c Collection of WikiModuleInfo instances
      */
-    private void registerBeans( Collection< WikiModuleInfo > c ) {
-        for( Iterator< WikiModuleInfo > i = c.iterator(); i.hasNext(); ) {
-            String abname = i.next().getAdminBeanClass();
-
+    private void registerBeans( final Collection< WikiModuleInfo > c ) {
+        for( final WikiModuleInfo wikiModuleInfo : c ) {
+            final String abname = wikiModuleInfo.getAdminBeanClass();
             try {
                 if( abname != null && abname.length() > 0 ) {
-                    Class< ? > abclass = Class.forName( abname );
-                    AdminBean ab = ( AdminBean ) abclass.newInstance();
+                    final Class< ? > abclass = Class.forName( abname );
+                    final AdminBean ab = ( AdminBean )abclass.newInstance();
                     registerAdminBean( ab );
                 }
-            } catch (ClassNotFoundException e) {
-                log.error( e.getMessage(), e );
-            } catch (InstantiationException e) {
-                log.error( e.getMessage(), e );
-            } catch (IllegalAccessException e) {
+            } catch( final ClassNotFoundException | InstantiationException | IllegalAccessException e ) {
                 log.error( e.getMessage(), e );
             }
         }
@@ -170,7 +162,7 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
 
     // FIXME: Should unload the beans first.
     private void reload() {
-        m_allBeans = new ArrayList<AdminBean>();
+        m_allBeans = new ArrayList<>();
 
         try {
             registerAdminBean( new CoreBean( m_engine ) );
@@ -178,12 +170,12 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
             registerAdminBean( new SearchManagerBean( m_engine ) );
             registerAdminBean( new PluginBean( m_engine ) );
             registerAdminBean( new FilterBean( m_engine ) );
-        } catch( NotCompliantMBeanException e ) {
+        } catch( final NotCompliantMBeanException e ) {
             log.error( e.getMessage(), e );
         }
-        registerBeans( m_engine.getEditorManager().modules() );
-        registerBeans( m_engine.getPluginManager().modules() );
-        registerBeans( m_engine.getFilterManager().modules() );
+        registerBeans( m_engine.getManager( EditorManager.class ).modules() );
+        registerBeans( m_engine.getManager( PluginManager.class ).modules() );
+        registerBeans( m_engine.getManager( FilterManager.class ).modules() );
     }
 
     /* (non-Javadoc)
@@ -202,12 +194,10 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
 	 * @see org.apache.wiki.ui.admin.AdminBeanManager#findBean(java.lang.String)
 	 */
     @Override
-	public AdminBean findBean( String id ) {
-        for( Iterator< AdminBean > i = m_allBeans.iterator(); i.hasNext(); ) {
-            AdminBean ab = i.next();
-
-            if( ab.getId().equals(id) ) {
-            	return ab;
+	public AdminBean findBean( final String id ) {
+        for( final AdminBean ab : m_allBeans ) {
+            if( ab.getId().equals( id ) ) {
+                return ab;
             }
         }
 
@@ -234,7 +224,7 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
      *  @return A type value.
      */
     @Override
-	public int getTypeFromString( String type ) {
+	public int getTypeFromString( final String type ) {
         if( "core".equals( type ) ) {
             return AdminBean.CORE;
         } else if( "editors".equals( type ) ) {
@@ -248,23 +238,22 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
 	 * @see org.apache.wiki.ui.admin.AdminBeanManager#actionPerformed(org.apache.wiki.event.WikiEvent)
 	 */
     @Override
-	public void actionPerformed(WikiEvent event) {
+	public void actionPerformed( final WikiEvent event ) {
         if( event instanceof WikiEngineEvent ) {
-            if( ( ( WikiEngineEvent )event ).getType() == WikiEngineEvent.SHUTDOWN ) {
-                for( Iterator< AdminBean > i = m_allBeans.iterator(); i.hasNext(); ) {
+            if( event.getType() == WikiEngineEvent.SHUTDOWN ) {
+                for( final AdminBean m_allBean : m_allBeans ) {
                     try {
-                        AdminBean ab = i.next();
-                        ObjectName on = getObjectName( ab );
+                        final ObjectName on = getObjectName( m_allBean );
                         if( m_mbeanServer.isRegistered( on ) ) {
-                            m_mbeanServer.unregisterMBean(on);
-                            log.info("Unregistered AdminBean "+ab.getTitle());
+                            m_mbeanServer.unregisterMBean( on );
+                            log.info( "Unregistered AdminBean " + m_allBean.getTitle() );
                         }
-                    } catch( MalformedObjectNameException e ) {
-                        log.error("Malformed object name when unregistering",e);
-                    } catch (InstanceNotFoundException e) {
-                        log.error("Object was registered; yet claims that it's not there",e);
-                    } catch (MBeanRegistrationException e) {
-                        log.error("Registration exception while unregistering",e);
+                    } catch( final MalformedObjectNameException e ) {
+                        log.error( "Malformed object name when unregistering", e );
+                    } catch( final InstanceNotFoundException e ) {
+                        log.error( "Object was registered; yet claims that it's not there", e );
+                    } catch( final MBeanRegistrationException e ) {
+                        log.error( "Registration exception while unregistering", e );
                     }
                 }
             }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/SimpleAdminBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/SimpleAdminBean.java
index b1e0ed5..95faf07 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/SimpleAdminBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/SimpleAdminBean.java
@@ -35,12 +35,9 @@ import javax.management.NotCompliantMBeanException;
  *  
  *  @since 2.5.52
  */
-public abstract class SimpleAdminBean extends SimpleMBean implements AdminBean
-{
-    /**
-     *  Provides access to a WikiEngine instance to which this AdminBean
-     *  belongs to.
-     */
+public abstract class SimpleAdminBean extends SimpleMBean implements AdminBean {
+
+    /** Provides access to a Engine instance to which this AdminBean belongs to. */
     protected Engine m_engine;
     
     /**
@@ -48,15 +45,15 @@ public abstract class SimpleAdminBean extends SimpleMBean implements AdminBean
      *  
      *  @throws NotCompliantMBeanException
      */
-    protected SimpleAdminBean() throws NotCompliantMBeanException
-    {
+    protected SimpleAdminBean() throws NotCompliantMBeanException {
         super();
     }
     
     /**
-     *  Initialize the AdminBean by setting up a WikiEngine instance internally.
+     *  Initialize the AdminBean by setting up a Engine instance internally.
      */
-    @Override public void initialize( final Engine engine )
+    @Override
+    public void initialize( final Engine engine )
     {
         m_engine = engine;
     }
@@ -67,38 +64,31 @@ public abstract class SimpleAdminBean extends SimpleMBean implements AdminBean
      *  attribute is read-only, a readonly input widget is created.
      *  The value is determined by the toString() method of the attribute.
      */
-    @Override public String doGet( final WikiContext context)
-    {
+    @Override
+    public String doGet( final WikiContext context ) {
         final MBeanInfo info = getMBeanInfo();
         final MBeanAttributeInfo[] attributes = info.getAttributes();
         final StringBuilder sb = new StringBuilder();
-        
-        for( int i = 0; i < attributes.length; i++ )
-        {
-            sb.append("<div class='block'>\n");
-            
-            sb.append( "<label>"+StringUtils.capitalize( attributes[i].getName() )+"</label>\n");
-            
-            try
-            {
-                final Object value = getAttribute( attributes[i].getName() );
-                if( attributes[i].isWritable() )
-                {
-                    sb.append( "<input type='text' name='question' size='30' value='"+value+"' />\n" );
-                }
-                else
-                {
-                    sb.append( "<input type='text' class='readonly' readonly='true' size='30' value='"+value+"' />\n" );
+
+        for( int i = 0; i < attributes.length; i++ ) {
+            sb.append( "<div class='block'>\n" );
+
+            sb.append( "<label>" + StringUtils.capitalize( attributes[ i ].getName() ) + "</label>\n" );
+
+            try {
+                final Object value = getAttribute( attributes[ i ].getName() );
+                if( attributes[ i ].isWritable() ) {
+                    sb.append( "<input type='text' name='question' size='30' value='" + value + "' />\n" );
+                } else {
+                    sb.append( "<input type='text' class='readonly' readonly='true' size='30' value='" + value + "' />\n" );
                 }
-            }
-            catch( final Exception e )
-            {
-                sb.append("Exception: "+e.getMessage());
+            } catch( final Exception e ) {
+                sb.append( "Exception: " + e.getMessage() );
             }
 
-            sb.append( "<div class='description'>"+attributes[i].getDescription()+"</div>\n");
-            
-            sb.append("</div>\n");
+            sb.append( "<div class='description'>" + attributes[ i ].getDescription() + "</div>\n" );
+
+            sb.append( "</div>\n" );
         }
         return sb.toString();
     }
@@ -106,18 +96,18 @@ public abstract class SimpleAdminBean extends SimpleMBean implements AdminBean
     /**
      *  Not implemented yet.
      */
-    @Override public String doPost( final WikiContext context)
-    {
-        // TODO Auto-generated method stub
+    @Override
+    public String doPost( final WikiContext context) {
         return null;
     }
 
     /**
-     *  By default, this method returns the class name of the bean.  This is
-     *  suitable, if you have a singleton bean.
+     *  By default, this method returns the class name of the bean.  This is suitable, if you have a singleton bean.
      */
-    @Override public String getId()
+    @Override
+    public String getId()
     {
         return getClass().getName();
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java
index aa84a5f..228e50a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java
@@ -33,8 +33,6 @@ import java.util.Collection;
 
 public abstract class ModuleBean extends SimpleAdminBean {
 
-    //protected WikiEngine m_engine; //inherited protected field from SimpleAdminBean
-
     private static final String VER_WARNING = "<span class='warning'>This module is not compatible with this version of JSPWiki.</span>";
 
     public ModuleBean( final Engine engine ) throws NotCompliantMBeanException {
@@ -44,21 +42,24 @@ public abstract class ModuleBean extends SimpleAdminBean {
     /**
      * {@inheritDoc}
      */
-    @Override public String[] getAttributeNames() {
+    @Override
+    public String[] getAttributeNames() {
         return new String[0];
     }
 
     /**
      * {@inheritDoc}
      */
-    @Override public String[] getMethodNames() {
+    @Override
+    public String[] getMethodNames() {
         return new String[0];
     }
 
     /**
      * {@inheritDoc}
      */
-    @Override public String doGet( final WikiContext context ) {
+    @Override
+    public String doGet( final WikiContext context ) {
         final Collection< WikiModuleInfo > filters = modules();
         final Element root = title();
         final Element tb = containerForModuleDetail( root );


[jspwiki] 03/20: JSPWIKI-120: PageFilters use Engine instead of WikiEngine on initialize method.

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 f8e3e5ee137c0d98e970c8233bc40a13caff0fe6
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 13:14:44 2020 +0100

    JSPWIKI-120: PageFilters use Engine instead of WikiEngine on initialize method.
    
    Also, moved methods from BasicPageFilter to PageFilter as default methods where appropiate
---
 .../apache/wiki/api/filters/BasicPageFilter.java   |  71 +++---------
 .../org/apache/wiki/api/filters/PageFilter.java    |  92 +++++++---------
 .../java/org/apache/wiki/filters/CreoleFilter.java |  41 +++----
 .../apache/wiki/filters/PingWeblogsComFilter.java  |  22 ++--
 .../java/org/apache/wiki/filters/SpamFilter.java   | 122 ++++++---------------
 5 files changed, 114 insertions(+), 234 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/filters/BasicPageFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/api/filters/BasicPageFilter.java
index 1234000..1462067 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/filters/BasicPageFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/filters/BasicPageFilter.java
@@ -18,73 +18,28 @@
  */
 package org.apache.wiki.api.filters;
 
+import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.exceptions.FilterException;
+
 import java.util.Properties;
 
-import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
-import org.apache.wiki.api.exceptions.FilterException;
 
 /**
- *  Provides a base implementation of a PageFilter.  None of the callbacks
- *  do anything, so it is a good idea for you to extend from this class
- *  and implement only methods that you need.
- *
+ * Provides a base implementation of a PageFilter.  None of the callbacks do anything, so it is a good idea for you to extend from this
+ * class and implement only methods that you need.
  */
-public class BasicPageFilter
-    implements PageFilter
-{
-    protected WikiEngine m_engine;
-  
-    /**
-     *  If you override this, you should call super.initialize() first.
-     *  
-     *  {@inheritDoc}
-     */
-    public void initialize( WikiEngine engine, Properties properties )
-        throws FilterException
-    {
-        m_engine = engine;
-    }
+public class BasicPageFilter implements PageFilter {
 
-    /**
-     *  {@inheritDoc}
-     */
-    public String preTranslate( WikiContext wikiContext, String content )
-        throws FilterException
-    {
-        return content;
-    }
+    protected Engine m_engine;
 
     /**
-     *  {@inheritDoc}
+     * If you override this, you should call super.initialize() first.
+     *
+     * {@inheritDoc}
      */
-    public String postTranslate( WikiContext wikiContext, String htmlContent )
-        throws FilterException
-    {
-        return htmlContent;
-    }
-
-    /**
-     *  {@inheritDoc}
-     */
-    public String preSave( WikiContext wikiContext, String content )
-        throws FilterException
-    {
-        return content;
+    @Override
+    public void initialize( final Engine engine, final Properties properties ) throws FilterException {
+        m_engine = engine;
     }
 
-    /**
-     *  {@inheritDoc}
-     */
-    public void postSave( WikiContext wikiContext, String content )
-        throws FilterException
-    {
-    }
-    
-    /**
-     *  {@inheritDoc}
-     */
-    public void destroy( WikiEngine engine ) 
-    {
-    }
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java
index 3354240..26d9008 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java
@@ -18,72 +18,62 @@
  */
 package org.apache.wiki.api.filters;
 
-import java.util.Properties;
-
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.FilterException;
 
+import java.util.Properties;
+
+
 /**
- *  Provides a definition for a page filter.  A page filter is a class
- *  that can be used to transform the WikiPage content being saved or
+ *  Provides a definition for a page filter.  A page filter is a class that can be used to transform the WikiPage content being saved or
  *  being loaded at any given time.
  *  <p>
- *  Note that the WikiContext.getPage() method always returns the context
- *  in which text is rendered, i.e. the original request.  Thus the content
- *  may actually be different content than what what the wikiContext.getPage()
- *  implies!  This happens often if you are for example including multiple
- *  pages on the same page.
+ *  Note that the WikiContext.getPage() method always returns the context in which text is rendered, i.e. the original request.  Thus the
+ *  content may actually be different content than what what the wikiContext.getPage() implies!  This happens often if you are for example
+ *  including multiple pages on the same page.
  *  <p>
- *  PageFilters must be thread-safe!  There is only one instance of each PageFilter 
- *  per each WikiEngine invocation.  If you need to store data persistently, use
- *  VariableManager, or WikiContext.
+ *  PageFilters must be thread-safe!  There is only one instance of each PageFilter per each Engine invocation.  If you need to store data
+ *  persistently, use VariableManager, or WikiContext.
  *  <p>
- *  As of 2.5.30, initialize() gains access to the WikiEngine.
- *
+ *  As of 2.5.30, initialize() gains access to the Engine.
  */
-public interface PageFilter
-{
+public interface PageFilter {
+
     /**
-     *  Is called whenever the a new PageFilter is instantiated and
-     *  reset.
+     *  Is called whenever the a new PageFilter is instantiated and reset.
      *  
      *  @param engine The WikiEngine whic owns this PageFilter
      *  @param properties The properties ripped from filters.xml.
-     *  @throws FilterException If the filter could not be initialized. If this is thrown,
-     *                          the filter is not added to the internal queues.
+     *  @throws FilterException If the filter could not be initialized. If this is thrown, the filter is not added to the internal queues.
      */
-    void initialize( WikiEngine engine, Properties properties )
-        throws FilterException;
+    void initialize( Engine engine, Properties properties ) throws FilterException;
 
     /**
-     *  This method is called whenever a page has been loaded from the provider,
-     *  but not yet been sent through the markup-translation process.  Note that you cannot
-     *  do HTML translation here, because it will be escaped.
+     *  This method is called whenever a page has been loaded from the provider, but not yet been sent through the markup-translation
+     *  process.  Note that you cannot do HTML translation here, because it will be escaped.
      *
      *  @param wikiContext The current wikicontext.
-     *  @param content     WikiMarkup.
+     *  @param content WikiMarkup.
      *  @return The modified wikimarkup content.
-     *  @throws FilterException If something goes wrong.  Throwing this causes the entire page
-     *                          processing to be abandoned.
+     *  @throws FilterException If something goes wrong.  Throwing this causes the entire page processing to be abandoned.
      */
-    String preTranslate( WikiContext wikiContext, String content )
-        throws FilterException;
+    default String preTranslate( final WikiContext wikiContext, final String content ) throws FilterException {
+        return content;
+    }
 
     /**
-     *  This method is called after a page has been fed through the translation process,
-     *  so anything you are seeing here is translated content.  If you want to
-     *  do any of your own WikiMarkup2HTML translation, do it here.
+     *  This method is called after a page has been fed through the translation process, so anything you are seeing here is translated
+     *  content.  If you want to do any of your own WikiMarkup2HTML translation, do it here.
      *  
      *  @param wikiContext The WikiContext.
      *  @param htmlContent The translated HTML
      *  @return The modified HTML
-     *  
-     *  @throws FilterException If something goes wrong.  Throwing this causes the entire page
-     *                          processing to be abandoned.
+     *  @throws FilterException If something goes wrong.  Throwing this causes the entire page processing to be abandoned.
      */
-    String postTranslate( WikiContext wikiContext, String htmlContent )
-        throws FilterException;
+    default String postTranslate( final WikiContext wikiContext, final String htmlContent ) throws FilterException {
+        return htmlContent;
+    }
 
     /**
      *  This method is called before the page has been saved to the PageProvider.
@@ -91,35 +81,31 @@ public interface PageFilter
      *  @param wikiContext The WikiContext
      *  @param content The wikimarkup that the user just wanted to save.
      *  @return The modified wikimarkup
-     *  @throws FilterException If something goes wrong.  Throwing this causes the entire page
-     *                          processing to be abandoned.
+     *  @throws FilterException If something goes wrong.  Throwing this causes the entire page processing to be abandoned.
      */
-    String preSave( WikiContext wikiContext, String content )
-        throws FilterException;
+    default String preSave( final WikiContext wikiContext, final String content ) throws FilterException {
+        return content;
+    }
 
     /**
-     *  This method is called after the page has been successfully saved.
-     *  If the saving fails for any reason, then this method will not
+     *  This method is called after the page has been successfully saved. If the saving fails for any reason, then this method will not
      *  be called.
      *  <p>
-     *  Since the result is discarded from this method, this is only useful
-     *  for things like counters, etc.
+     *  Since the result is discarded from this method, this is only useful for things like counters, etc.
      *  
      *  @param wikiContext The WikiContext
      *  @param content The content which was just stored.
-     *  @throws FilterException If something goes wrong.  As the page is already saved,
-     *                          This is just logged.
+     *  @throws FilterException If something goes wrong.  As the page is already saved, This is just logged.
      */
-    void postSave( WikiContext wikiContext, String content )
-        throws FilterException;
+    default void postSave( final WikiContext wikiContext, final String content ) throws FilterException {}
 
     /**
      *  Called for every filter, e.g. on wiki engine shutdown. Use this if you have to 
      *  clean up or close global resources you allocated in the initialize() method.
      * 
-     *  @param engine The WikiEngine which owns this filter.
+     *  @param engine The Engine which owns this filter.
      *  @since 2.5.36
      */
-    void destroy( WikiEngine engine );
+    default void destroy( final Engine engine ) {}
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/CreoleFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/CreoleFilter.java
index 9e8fab4..43b678f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/CreoleFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/CreoleFilter.java
@@ -20,7 +20,7 @@ package org.apache.wiki.filters;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.FilterException;
 import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.wiki.parser.CreoleToJSPWikiTranslator;
@@ -28,26 +28,19 @@ import org.apache.wiki.parser.CreoleToJSPWikiTranslator;
 import java.util.Properties;
 
 /**
- * <p>Provides the Implementation for mixed mode creole: If you activate
- * this filter, it will translate all markup that was saved as creole
- * markup to JSPWiki markup. Therefore the files will be saved 
- * with mixed markup.
+ * <p>Provides the Implementation for mixed mode creole: If you activate this filter, it will translate all markup that was saved as creole
+ * markup to JSPWiki markup. Therefore the files will be saved with mixed markup.
  * <p>
- * <b>WARNING</b>: There's no turning back after installing this
- * filter. Since your wiki pages are saved in Creole markup you can
+ * <b>WARNING</b>: There's no turning back after installing this filter. Since your wiki pages are saved in Creole markup you can
  * not deactivate it afterwards.
  * <p>
- * <b>WARNING</b>: This feature is completely experimental, and is known to be
- * broken.  Use at your own risk.
+ * <b>WARNING</b>: This feature is completely experimental, and is known to be broken.  Use at your own risk.
  * <p>
- * <b>WARNING</b>: The CreoleFilter feature is deprecated.  JSPWiki is likely
- * to implement a non-mixed mode Creole at some point, since turning on
- * Creole will make new pages obsolete.
- * 
- * 
+ * <b>WARNING</b>: The CreoleFilter feature is deprecated.  JSPWiki is likely to implement a non-mixed mode Creole at some point, since
+ * turning on Creole will make new pages obsolete.
+ *
  * @see <a href="http://www.wikicreole.org/wiki/MixedMode">[[WikiCreole:MixedMode]]</a> 
  */
-
 public class CreoleFilter extends BasicPageFilter {
     
     private static final Logger log = Logger.getLogger(CreoleFilter.class);
@@ -55,18 +48,19 @@ public class CreoleFilter extends BasicPageFilter {
     /**
      *  {@inheritDoc}
      */
-    public void initialize(WikiEngine engine, Properties props) throws FilterException {
+    @Override public void initialize( final Engine engine, final Properties props ) throws FilterException {
     }
 
     /**
      *  {@inheritDoc}
      */
-    public String preSave( WikiContext wikiContext, String content ) {
+    @Override
+    public String preSave( final WikiContext wikiContext, final String content ) {
         try {
-            String username=wikiContext.getCurrentUser().getName();
-            Properties prop = wikiContext.getEngine().getWikiProperties();
+            final String username = wikiContext.getCurrentUser().getName();
+            final Properties prop = wikiContext.getEngine().getWikiProperties();
             return new CreoleToJSPWikiTranslator().translateSignature(prop, content,username);
-        } catch(Exception e ) {
+        } catch( final Exception e ) {
             log.error( e.getMessage(), e );
             return e.getMessage();
         }
@@ -75,11 +69,12 @@ public class CreoleFilter extends BasicPageFilter {
     /**
      *  {@inheritDoc}
      */
-    public String preTranslate(WikiContext wikiContext, String content) {
+    @Override
+    public String preTranslate( final WikiContext wikiContext, final String content ) {
         try {
-            Properties prop = wikiContext.getEngine().getWikiProperties();
+            final Properties prop = wikiContext.getEngine().getWikiProperties();
             return new CreoleToJSPWikiTranslator().translate(prop ,content);
-        } catch (Exception e) {
+        } catch( final Exception e ) {
             log.error( e.getMessage(), e );
             return content
                    + "\n \n %%error \n"
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java
index 6e1bfe6..fbfdeb9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/PingWeblogsComFilter.java
@@ -20,7 +20,6 @@ package org.apache.wiki.filters;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.xmlrpc.AsyncCallback;
@@ -53,14 +52,16 @@ public class PingWeblogsComFilter extends BasicPageFilter {
     /**
      *  {@inheritDoc}
      */
-    @Override public void initialize( final WikiEngine engine, final Properties props ) {
+    @Override
+    public void initialize( final Engine engine, final Properties props ) {
         m_pingURL = props.getProperty( PROP_PINGURL, "http://rpc.weblogs.com/RPC2" );
     }
 
     /**
      *  {@inheritDoc}
      */
-    @Override public void postSave( final WikiContext context, final String pagecontent ) {
+    @Override
+    public void postSave( final WikiContext context, final String pagecontent ) {
         String blogName = context.getPage().getName();
         final Engine engine   = context.getEngine();
 
@@ -87,22 +88,24 @@ public class PingWeblogsComFilter extends BasicPageFilter {
 
             xmlrpc.executeAsync("weblogUpdates.ping", params, 
                                 new AsyncCallback() {
-                                    @Override public void handleError( final Exception ex, final URL url, final String method ) {
+                                    @Override
+                                    public void handleError( final Exception ex, final URL url, final String method ) {
                                         log.error( "Unable to execute weblogs.com ping to URL: " + url.toString(), ex );
                                     }
 
-                                    @Override public void handleResult( final Object result, final URL url, final String method ) {
+                                    @Override
+                                    public void handleResult( final Object result, final URL url, final String method ) {
                                         @SuppressWarnings("unchecked")
                                         final Hashtable< String, Object > res = (Hashtable < String, Object > ) result;
 
-                                        final Boolean flerror = (Boolean)res.get("flerror");
-                                        final String  msg     = (String)res.get("message");
+                                        final Boolean flerror = ( Boolean )res.get( "flerror" );
+                                        final String  msg     = ( String )res.get( "message" );
 
                                         if( flerror ) {
-                                            log.error("Failed to ping: "+msg);
+                                            log.error( "Failed to ping: " + msg );
                                         }
 
-                                        log.info("Weblogs.com has been pinged.");
+                                        log.info( "Weblogs.com has been pinged." );
                                     }
                                 }
                                 );
@@ -110,4 +113,5 @@ public class PingWeblogsComFilter extends BasicPageFilter {
             log.error("Malformed URL",e);
         }
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
index 0175d6c..109eb6f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
@@ -30,7 +30,6 @@ import org.apache.oro.text.regex.Perl5Compiler;
 import org.apache.oro.text.regex.Perl5Matcher;
 import org.apache.wiki.InternalWikiException;
 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.core.Engine;
@@ -250,26 +249,20 @@ public class SpamFilter extends BasicPageFilter {
      *  {@inheritDoc}
      */
     @Override
-    public void initialize( final WikiEngine engine, final Properties properties ) {
+    public void initialize( final Engine engine, final Properties properties ) {
         m_forbiddenWordsPage = properties.getProperty( PROP_WORDLIST, m_forbiddenWordsPage );
         m_forbiddenIPsPage = properties.getProperty( PROP_IPLIST, m_forbiddenIPsPage);
         m_pageNameMaxLength = properties.getProperty( PROP_MAX_PAGENAME_LENGTH, m_pageNameMaxLength);
         m_errorPage = properties.getProperty( PROP_ERRORPAGE, m_errorPage );
-        m_limitSinglePageChanges = TextUtil.getIntegerProperty( properties,
-                                                                PROP_PAGECHANGES,
-                                                                m_limitSinglePageChanges );
+        m_limitSinglePageChanges = TextUtil.getIntegerProperty( properties, PROP_PAGECHANGES, m_limitSinglePageChanges );
         
-        m_limitSimilarChanges = TextUtil.getIntegerProperty( properties,
-                                                             PROP_SIMILARCHANGES,
-                                                             m_limitSimilarChanges );
+        m_limitSimilarChanges = TextUtil.getIntegerProperty( properties, PROP_SIMILARCHANGES, m_limitSimilarChanges );
 
         m_maxUrls = TextUtil.getIntegerProperty( properties, PROP_MAXURLS, m_maxUrls );
         m_banTime = TextUtil.getIntegerProperty( properties, PROP_BANTIME, m_banTime );
         m_blacklist = properties.getProperty( PROP_BLACKLIST, m_blacklist );
 
-        m_ignoreAuthenticated = TextUtil.getBooleanProperty( properties,
-                                                             PROP_IGNORE_AUTHENTICATED,
-                                                             m_ignoreAuthenticated );
+        m_ignoreAuthenticated = TextUtil.getBooleanProperty( properties, PROP_IGNORE_AUTHENTICATED, m_ignoreAuthenticated );
 
         m_useCaptcha = properties.getProperty( PROP_CAPTCHA, "" ).equals("asirra");
 
@@ -280,18 +273,11 @@ public class SpamFilter extends BasicPageFilter {
             throw new InternalWikiException( "Faulty pattern." , e);
         }
 
-        m_akismetAPIKey = TextUtil.getStringProperty( properties,
-                                                      PROP_AKISMET_API_KEY,
-                                                      m_akismetAPIKey );
-
-        m_stopAtFirstMatch = TextUtil.getStringProperty( properties,
-                                                         PROP_FILTERSTRATEGY,
-                                                         STRATEGY_EAGER ).equals( STRATEGY_EAGER );
+        m_akismetAPIKey = TextUtil.getStringProperty( properties, PROP_AKISMET_API_KEY, m_akismetAPIKey );
+        m_stopAtFirstMatch = TextUtil.getStringProperty( properties, PROP_FILTERSTRATEGY, STRATEGY_EAGER ).equals( STRATEGY_EAGER );
 
         log.info( "# Spam filter initialized.  Temporary ban time " + m_banTime +
                   " mins, max page changes/minute: " + m_limitSinglePageChanges );
-
-
     }
 
     private static final int REJECT = 0;
@@ -327,7 +313,8 @@ public class SpamFilter extends BasicPageFilter {
     }
 
     /** {@inheritDoc} */
-    @Override public String preSave( final WikiContext context, final String content ) throws RedirectException {
+    @Override
+    public String preSave( final WikiContext context, final String content ) throws RedirectException {
         cleanBanList();
         refreshBlacklists( context );
         final Change change = getChange( context, content );
@@ -473,35 +460,25 @@ public class SpamFilter extends BasicPageFilter {
             for( final Iterator< Host > i = m_lastModifications.iterator(); i.hasNext(); ) {
                 final Host host = i.next();
 
-                //
                 //  Check if this item is invalid
-                //
                 if( host.getAddedTime() < time ) {
                     log.debug( "Removed host " + host.getAddress() + " from modification queue (expired)" );
                     i.remove();
                     continue;
                 }
 
-                //
                 // Check if this IP address has been seen before
-                //
-
                 if( host.getAddress().equals( addr ) ) {
                     hostCounter++;
                 }
 
-                //
                 //  Check, if this change has been seen before
-                //
-
                 if( host.getChange() != null && host.getChange().equals( change ) ) {
                     changeCounter++;
                 }
             }
 
-            //
             //  Now, let's check against the limits.
-            //
             if( hostCounter >= m_limitSinglePageChanges ) {
                 final Host host = new Host( addr, null );
                 m_temporaryBanList.add( host );
@@ -520,11 +497,9 @@ public class SpamFilter extends BasicPageFilter {
                 checkStrategy( context, REASON_SIMILAR_MODIFICATIONS, "Herb says you look like a spammer, and I trust Herb! (Incident code "+uid+")");
             }
 
-            //
             //  Calculate the number of links in the addition.
-            //
             String tstChange  = change.toString();
-            int    urlCounter = 0;
+            int urlCounter = 0;
             while( m_matcher.contains( tstChange,m_urlPattern ) ) {
                 final MatchResult m = m_matcher.getMatch();
                 tstChange = tstChange.substring( m.endOffset(0) );
@@ -540,20 +515,13 @@ public class SpamFilter extends BasicPageFilter {
                 checkStrategy( context, REASON_TOO_MANY_URLS, "Herb says you look like a spammer, and I trust Herb! (Incident code " + uid + ")" );
             }
 
-            //
             //  Check bot trap
-            //
             checkBotTrap( context, change );
 
-            //
             //  Check UTF-8 mangling
-            //
             checkUTF8( context, change );
 
-            //
-            //  Do Akismet check.  This is good to be the last, because this is the most
-            //  expensive operation.
-            //
+            //  Do Akismet check.  This is good to be the last, because this is the most expensive operation.
             checkAkismet( context, change );
 
             m_lastModifications.add( new Host( addr, change ) );
@@ -583,10 +551,7 @@ public class SpamFilter extends BasicPageFilter {
 
             final HttpServletRequest req = context.getHttpRequest();
 
-            //
-            //  Akismet will mark all empty statements as spam, so we'll just
-            //  ignore them.
-            //
+            //  Akismet will mark all empty statements as spam, so we'll just ignore them.
             if( change.m_adds == 0 && change.m_removals > 0 ) {
                 return;
             }
@@ -607,15 +572,15 @@ public class SpamFilter extends BasicPageFilter {
                 final String commentAuthorURL   = null;
 
                 final boolean isSpam = m_akismet.commentCheck( ipAddress,
-                                                         userAgent,
-                                                         referrer,
-                                                         permalink,
-                                                         commentType,
-                                                         commentAuthor,
-                                                         commentAuthorEmail,
-                                                         commentAuthorURL,
-                                                         change.toString(),
-                                                         null );
+                                                               userAgent,
+                                                               referrer,
+                                                               permalink,
+                                                               commentType,
+                                                               commentAuthor,
+                                                               commentAuthorEmail,
+                                                               commentAuthorURL,
+                                                               change.toString(),
+                                                               null );
 
                 sw.stop();
                 log.debug( "Akismet request done in: " + sw );
@@ -650,7 +615,6 @@ public class SpamFilter extends BasicPageFilter {
      */
     private void checkBotTrap( final WikiContext context, final Change change ) throws RedirectException {
         final HttpServletRequest request = context.getHttpRequest();
-
         if( request != null ) {
             final String unspam = request.getParameter( getBotFieldName() );
             if( unspam != null && unspam.length() > 0 ) {
@@ -664,10 +628,8 @@ public class SpamFilter extends BasicPageFilter {
 
     private void checkUTF8( final WikiContext context, final Change change ) throws RedirectException {
         final HttpServletRequest request = context.getHttpRequest();
-
         if( request != null ) {
             final String utf8field = request.getParameter( "encodingcheck" );
-
             if( utf8field != null && !utf8field.equals( "\u3041" ) ) {
                 final String uid = log( context, REJECT, REASON_UTF8_TRAP, change.toString() );
 
@@ -680,7 +642,6 @@ public class SpamFilter extends BasicPageFilter {
     /** Goes through the ban list and cleans away any host which has expired from it. */
     private synchronized void cleanBanList() {
         final long now = System.currentTimeMillis();
-
         for( final Iterator< Host > i = m_temporaryBanList.iterator(); i.hasNext(); ) {
             final Host host = i.next();
 
@@ -723,12 +684,9 @@ public class SpamFilter extends BasicPageFilter {
      */
     private void refreshBlacklists( final WikiContext context ) {
         try {
-
             boolean rebuild = false;
 
-            //
             //  Rebuild, if the spam words page, the attachment or the IP ban page has changed since.
-            //
             final WikiPage sourceSpam = context.getEngine().getManager( PageManager.class ).getPage( m_forbiddenWordsPage );
             if( sourceSpam != null ) {
                 if( m_spamPatterns == null || m_spamPatterns.isEmpty() || sourceSpam.getLastModified().after( m_lastRebuild ) ) {
@@ -750,10 +708,7 @@ public class SpamFilter extends BasicPageFilter {
                 }
             }
 
-            //
-            //  Do the actual rebuilding.  For simplicity's sake, we always rebuild the complete
-            //  filter list regardless of what changed.
-            //
+            //  Do the actual rebuilding.  For simplicity's sake, we always rebuild the complete filter list regardless of what changed.
             if( rebuild ) {
                 m_lastRebuild = new Date();
                 m_spamPatterns = parseWordList( sourceSpam, ( sourceSpam != null ) ? sourceSpam.getAttribute( LISTVAR ) : null );
@@ -788,10 +743,7 @@ public class SpamFilter extends BasicPageFilter {
      *  @throws RedirectException
      */
     private void checkPatternList( final WikiContext context, final String content, final Change change ) throws RedirectException {
-        //
-        //  If we have no spam patterns defined, or we're trying to save
-        //  the page containing the patterns, just return.
-        //
+        // If we have no spam patterns defined, or we're trying to save the page containing the patterns, just return.
         if( m_spamPatterns == null || context.getPage().getName().equals( m_forbiddenWordsPage ) ) {
             return;
         }
@@ -805,9 +757,7 @@ public class SpamFilter extends BasicPageFilter {
             // log.debug("Attempting to match page contents with "+p.getPattern());
 
             if( m_matcher.contains( ch, p ) ) {
-                //
                 //  Spam filter has a match.
-                //
                 final String uid = log( context, REJECT, REASON_REGEXP + "(" + p.getPattern() + ")", ch );
 
                 log.info( "SPAM:Regexp (" + uid + "). Content matches the spam filter '" + p.getPattern() + "'" );
@@ -824,10 +774,7 @@ public class SpamFilter extends BasicPageFilter {
      *  @throws RedirectException
      */
     private void checkIPList( final WikiContext context ) throws RedirectException {
-        //
-        //  If we have no IP patterns defined, or we're trying to save
-        //  the page containing the IP patterns, just return.
-        //
+        //  If we have no IP patterns defined, or we're trying to save the page containing the IP patterns, just return.
         if( m_IPPatterns == null || context.getPage().getName().equals( m_forbiddenIPsPage ) ) {
             return;
         }
@@ -900,19 +847,14 @@ public class SpamFilter extends BasicPageFilter {
             log.error( "Diff failed", e );
         }
 
-        //
         //  Don't forget to include the change note, too
-        //
         final String changeNote = page.getAttribute( WikiPage.CHANGENOTE );
-
         if( changeNote != null ) {
             change.append( "\r\n" );
             change.append( changeNote );
         }
 
-        //
         //  And author as well
-        //
         if( page.getAuthor() != null ) {
             change.append( "\r\n" + page.getAuthor() );
         }
@@ -951,7 +893,6 @@ public class SpamFilter extends BasicPageFilter {
     private static String getUniqueID() {
         final StringBuilder sb = new StringBuilder();
         final Random rand = new Random();
-
         for( int i = 0; i < 6; i++ ) {
             final char x = ( char )( 'A' + rand.nextInt( 26 ) );
             sb.append( x );
@@ -968,7 +909,7 @@ public class SpamFilter extends BasicPageFilter {
      */
     private String getRedirectPage( final WikiContext ctx ) {
         if( m_useCaptcha ) {
-            return ctx.getURL( WikiContext.NONE, "Captcha.jsp", "page="+ctx.getEngine().encodeName( ctx.getPage().getName() ) );
+            return ctx.getURL( WikiContext.NONE, "Captcha.jsp", "page= " +ctx.getEngine().encodeName( ctx.getPage().getName() ) );
         }
 
         return ctx.getURL( WikiContext.VIEW, m_errorPage );
@@ -1060,7 +1001,6 @@ public class SpamFilter extends BasicPageFilter {
      */
     public static final boolean checkHash( final WikiContext context, final PageContext pageContext ) throws IOException {
         final String hashName = getHashFieldName( (HttpServletRequest)pageContext.getRequest() );
-
         if( pageContext.getRequest().getParameter(hashName) == null ) {
             if( pageContext.getAttribute( hashName ) == null ) {
                 final Change change = getChange( context, EditorManager.getEditedText( pageContext ) );
@@ -1099,9 +1039,9 @@ public class SpamFilter extends BasicPageFilter {
      *  @since
      */
     private class Host {
-    	
-        private long   m_addedTime = System.currentTimeMillis();
-        private long   m_releaseTime;
+
+        private long m_addedTime = System.currentTimeMillis();
+        private long m_releaseTime;
         private String m_address;
         private Change m_change;
 
@@ -1123,7 +1063,7 @@ public class SpamFilter extends BasicPageFilter {
 
         public Host( final String ipaddress, final Change change ) {
             m_address = ipaddress;
-            m_change  = change;
+            m_change = change;
             m_releaseTime = System.currentTimeMillis() + m_banTime * 60 * 1000L;
         }
         
@@ -1134,18 +1074,18 @@ public class SpamFilter extends BasicPageFilter {
         public String m_change;
         public int    m_adds;
         public int    m_removals;
-        
+
         @Override public String toString() {
             return m_change;
         }
-        
+
         @Override public boolean equals( final Object o ) {
             if( o instanceof Change ) {
                 return m_change.equals( ( ( Change )o ).m_change );
             }
             return false;
         }
-        
+
         @Override public int hashCode() {
             return m_change.hashCode() + 17;
         }


[jspwiki] 08/20: JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (3)

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 b365691bcccb625e85fd027229f2aced0b92f0bc
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 19:23:02 2020 +0100

    JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (3)
---
 .../org/apache/wiki/rpc/atom/AtomAPIServlet.java   | 214 +++++++--------------
 .../java/org/apache/wiki/rss/RSSGenerator.java     |  29 +--
 .../main/java/org/apache/wiki/rss/RSSThread.java   |  67 ++-----
 3 files changed, 109 insertions(+), 201 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
index 084ecd2..66add1a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rpc/atom/AtomAPIServlet.java
@@ -22,6 +22,7 @@ import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.pages.PageManager;
@@ -35,6 +36,7 @@ import org.intabulas.sandler.elements.Entry;
 import org.intabulas.sandler.elements.Feed;
 import org.intabulas.sandler.elements.Link;
 import org.intabulas.sandler.elements.Person;
+import org.intabulas.sandler.elements.impl.LinkImpl;
 import org.intabulas.sandler.exceptions.FeedMarshallException;
 
 import javax.servlet.ServletConfig;
@@ -45,30 +47,27 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Date;
-import java.util.Iterator;
 
 
 /**
- *  Handles incoming requests for the Atom API.  This class uses the
- *  "sandler" Atom API implementation.
+ *  Handles incoming requests for the Atom API.  This class uses the "sandler" Atom API implementation.
  *
  *  @since 2.1.97
  */
 // FIXME: Rewrite using some other library
-public class AtomAPIServlet extends HttpServlet
-{
-    static final Logger log = Logger.getLogger( AtomAPIServlet.class );
+public class AtomAPIServlet extends HttpServlet {
+
+    private static final Logger log = Logger.getLogger( AtomAPIServlet.class );
 
     private static final long serialVersionUID = 0L;
 
-    private WikiEngine       m_engine;
+    private Engine m_engine;
 
     /**
      *  {@inheritDoc}
      */
-    @Override public void init( final ServletConfig config )
-        throws ServletException
-    {
+    @Override
+    public void init( final ServletConfig config ) throws ServletException {
         m_engine = WikiEngine.getInstance( config );
     }
 
@@ -77,22 +76,15 @@ public class AtomAPIServlet extends HttpServlet
      *  The initial slash is also removed.  If there is no page,
      *  returns null.
      */
-    private String getPageName( final HttpServletRequest request )
-    {
+    private String getPageName( final HttpServletRequest request ) {
         String name = request.getPathInfo();
-
-        if( name == null || name.length() <= 1 )
-        {
+        if( name == null || name.length() <= 1 ) {
             return null;
-        }
-        else if( name.charAt(0) == '/' )
-        {
-            name = name.substring(1);
+        } else if( name.charAt( 0 ) == '/' ) {
+            name = name.substring( 1 );
         }
 
-        name = TextUtil.urlDecodeUTF8( name );
-
-        return name;
+        return TextUtil.urlDecodeUTF8( name );
     }
 
     /**
@@ -104,61 +96,43 @@ public class AtomAPIServlet extends HttpServlet
      *   <li>Assumes that incoming code is plain text or WikiMarkup, not html.
      *  </ul>
      *  
-     *  @param request {@inheritDoc}
-     *  @param response {@inheritDoc}
-     *  @throws ServletException {@inheritDoc}
+     *  {@inheritDoc}
      */
-    @Override public void doPost( final HttpServletRequest request, final HttpServletResponse response )
-        throws ServletException
-    {
-        log.debug("Received POST to AtomAPIServlet");
+    @Override
+    public void doPost( final HttpServletRequest request, final HttpServletResponse response ) throws ServletException {
+        log.debug( "Received POST to AtomAPIServlet" );
 
-        try
-        {
+        try {
             final String blogid = getPageName( request );
-
-            final WikiPage page    = m_engine.getManager( PageManager.class ).getPage( blogid );
-
-            if( page == null )
-            {
-                throw new ServletException("Page "+blogid+" does not exist, cannot add blog post.");
+            final WikiPage page = m_engine.getManager( PageManager.class ).getPage( blogid );
+            if( page == null ) {
+                throw new ServletException( "Page " + blogid + " does not exist, cannot add blog post." );
             }
 
-            //FIXME: Do authentication here
+            // FIXME: Do authentication here
             final Entry entry = Sandler.unmarshallEntry( request.getInputStream() );
 
-            //
             //  Fetch the obligatory parts of the content.
-            //
-            final Content title   = entry.getTitle();
-            final Content content = entry.getContent(0);
-
-            final Person  author  = entry.getAuthor();
-
-            //FIXME: Sandler 0.5 does not support generator
+            final Content title = entry.getTitle();
+            final Content content = entry.getContent( 0 );
+            final Person author = entry.getAuthor();
 
-            //
-            //  Generate new blog entry.
-            //
+            // FIXME: Sandler 0.5 does not support generator
+            // Generate new blog entry.
             final WeblogEntryPlugin plugin = new WeblogEntryPlugin();
-
             final String pageName = plugin.getNewEntryPage( m_engine, blogid );
             final String username = author.getName();
-
             final WikiPage entryPage = new WikiPage( m_engine, pageName );
             entryPage.setAuthor( username );
 
             final WikiContext context = new WikiContext( m_engine, request, entryPage );
-
             final StringBuilder text = new StringBuilder();
-            text.append( "!" + title.getBody() );
-            text.append( "\n\n" );
-            text.append( content.getBody() );
-
-            log.debug("Writing entry: "+text);
-
+            text.append( "!" )
+                .append( title.getBody() )
+                .append( "\n\n" )
+                .append( content.getBody() );
+            log.debug( "Writing entry: " + text );
             m_engine.getManager( PageManager.class ).saveText( context, text.toString() );
-
         } catch( final FeedMarshallException e ) {
             log.error("Received faulty Atom entry",e);
             throw new ServletException("Faulty Atom entry",e);
@@ -177,71 +151,53 @@ public class AtomAPIServlet extends HttpServlet
      *  
      *  {@inheritDoc}
      */
-    @Override public void doGet( final HttpServletRequest request, final HttpServletResponse response )
-        throws ServletException
-    {
-        log.debug("Received HTTP GET to AtomAPIServlet");
-
+    @Override
+    public void doGet( final HttpServletRequest request, final HttpServletResponse response ) throws ServletException {
+        log.debug( "Received HTTP GET to AtomAPIServlet" );
         final String blogid = getPageName( request );
-
-        log.debug("Requested page "+blogid);
-
-        try
-        {
-            if( blogid == null )
-            {
+        log.debug( "Requested page " + blogid );
+        try {
+            if( blogid == null ) {
                 final Feed feed = listBlogs();
-
-                response.setContentType("application/x.atom+xml; charset=UTF-8");
-                response.getWriter().println( Sandler.marshallFeed(feed) );
-
-                response.getWriter().flush();
-            }
-            else
-            {
+                response.setContentType( "application/x.atom+xml; charset=UTF-8" );
+                response.getWriter().println( Sandler.marshallFeed( feed ) );
+            } else {
                 final Entry entry = getBlogEntry( blogid );
-
-                response.setContentType("application/x.atom+xml; charset=UTF-8");
-                response.getWriter().println( Sandler.marshallEntry(entry) );
-
-                response.getWriter().flush();
+                response.setContentType( "application/x.atom+xml; charset=UTF-8" );
+                response.getWriter().println( Sandler.marshallEntry( entry ) );
             }
+            response.getWriter().flush();
+        } catch( final Exception e ) {
+            log.error( "Unable to generate response", e );
+            throw new ServletException( "Internal problem - whack Janne on the head to get a better error report", e );
         }
-        catch( final Exception e )
-        {
-            log.error("Unable to generate response",e);
-            throw new ServletException("Internal problem - whack Janne on the head to get a better error report",e);
-        }
-
     }
 
     private Entry getBlogEntry( final String entryid ) {
         final WikiPage page = m_engine.getManager( PageManager.class ).getPage( entryid );
         final WikiPage firstVersion = m_engine.getManager( PageManager.class ).getPage( entryid, 1 );
-
         final Entry entry = SyndicationFactory.newSyndicationEntry();
-
         final String pageText = m_engine.getManager( PageManager.class ).getText(page.getName());
-        String title = "";
         final int firstLine = pageText.indexOf('\n');
 
-        if( firstLine > 0 )
-        {
+        String title = "";
+        if( firstLine > 0 ) {
             title = pageText.substring( 0, firstLine );
         }
 
-        if( title.trim().length() == 0 ) title = page.getName();
+        if( title.trim().length() == 0 ) {
+            title = page.getName();
+        }
 
         // Remove wiki formatting
-        while( title.startsWith("!") ) title = title.substring(1);
+        while( title.startsWith("!") ) {
+            title = title.substring(1);
+        }
 
         entry.setTitle( title );
         entry.setCreated( firstVersion.getLastModified() );
         entry.setModified( page.getLastModified() );
-        entry.setAuthor( SyndicationFactory.createPerson( page.getAuthor(),
-                                                          null,
-                                                          null ) );
-
+        entry.setAuthor( SyndicationFactory.createPerson( page.getAuthor(), null, null ) );
         entry.addContent( SyndicationFactory.createEscapedContent(pageText) );
 
         return entry;
@@ -252,46 +208,25 @@ public class AtomAPIServlet extends HttpServlet
      */
     private Feed listBlogs() throws ProviderException {
         final Collection< WikiPage > pages = m_engine.getManager( PageManager.class ).getAllPages();
-
         final Feed feed = SyndicationFactory.newSyndicationFeed();
         feed.setTitle("List of blogs at this site");
         feed.setModified( new Date() );
 
-        for( final Iterator< WikiPage > i = pages.iterator(); i.hasNext(); )
-        {
-            final WikiPage p = i.next();
-
-            //
+        for( final WikiPage p : pages ) {
             //  List only weblogs
-            //  FIXME: Unfortunately, a weblog is not known until it has
-            //         been executed once, because plugins are off during
-            //         the initial startup phase.
-            //
-
-            log.debug( p.getName()+" = "+p.getAttribute(WeblogPlugin.ATTR_ISWEBLOG)) ;
+            //  FIXME: Unfortunately, a weblog is not known until it has een executed once, because plugins are off during the initial startup phase.
+            log.debug( p.getName() + " = " + p.getAttribute( WeblogPlugin.ATTR_ISWEBLOG ) );
 
-            if( !("true".equals(p.getAttribute(WeblogPlugin.ATTR_ISWEBLOG)) ) ) {
+            if( !( "true".equals( p.getAttribute( WeblogPlugin.ATTR_ISWEBLOG ) ) ) ) {
                 continue;
             }
 
             final String encodedName = TextUtil.urlEncodeUTF8( p.getName() );
-
             final WikiContext context = new WikiContext( m_engine, p );
-
-            final String title = TextUtil.replaceEntities(org.apache.wiki.rss.Feed.getSiteName(context));
-
-            final Link postlink = createLink( "service.post",
-                                        m_engine.getBaseURL()+"atom/"+encodedName,
-                                        title );
-
-            final Link editlink = createLink( "service.edit",
-                                        m_engine.getBaseURL()+"atom/"+encodedName,
-                                        title );
-
-            final Link feedlink = createLink( "service.feed",
-                                        m_engine.getBaseURL()+"atom.jsp?page="+encodedName,
-                                        title );
-
+            final String title = TextUtil.replaceEntities( org.apache.wiki.rss.Feed.getSiteName( context ) );
+            final Link postlink = createLink( "service.post", m_engine.getBaseURL() + "atom/" + encodedName, title );
+            final Link editlink = createLink( "service.edit", m_engine.getBaseURL() + "atom/" + encodedName, title );
+            final Link feedlink = createLink( "service.feed", m_engine.getBaseURL() + "atom.jsp?page=" + encodedName, title );
 
             feed.addLink( postlink );
             feed.addLink( feedlink );
@@ -301,12 +236,8 @@ public class AtomAPIServlet extends HttpServlet
         return feed;
     }
 
-    private Link createLink( final String rel,
-                             final String href,
-                             final String title )
-    {
-        final org.intabulas.sandler.elements.impl.LinkImpl link = new org.intabulas.sandler.elements.impl.LinkImpl();
-
+    private Link createLink( final String rel, final String href, final String title ) {
+        final LinkImpl link = new LinkImpl();
         link.setRelationship( rel );
         link.setTitle( title );
         link.setType( "application/x.atom+xml" );
@@ -318,14 +249,17 @@ public class AtomAPIServlet extends HttpServlet
     /**
      *  {@inheritDoc}
      */
-    @Override public void doDelete( final HttpServletRequest request, final HttpServletResponse response ) {
-        log.debug("Received HTTP DELETE");
+    @Override
+    public void doDelete( final HttpServletRequest request, final HttpServletResponse response ) {
+        log.debug( "Received HTTP DELETE" );
     }
 
     /**
      *  {@inheritDoc}
      */
-    @Override public void doPut( final HttpServletRequest request, final HttpServletResponse response ) {
-        log.debug("Received HTTP PUT");
+    @Override
+    public void doPut( final HttpServletRequest request, final HttpServletResponse response ) {
+        log.debug( "Received HTTP PUT" );
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
index cb48eb9..44730a8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
@@ -20,16 +20,19 @@ package org.apache.wiki.rss;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.diff.DifferenceManager;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.pages.PageTimeComparator;
+import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.util.TextUtil;
+import org.apache.wiki.variables.VariableManager;
 
 import java.util.Iterator;
 import java.util.List;
@@ -55,7 +58,7 @@ import java.util.Set;
 public class RSSGenerator {
 
     private static final Logger log = Logger.getLogger( RSSGenerator.class );
-    private WikiEngine m_engine;
+    private Engine m_engine;
 
     private String m_channelDescription = "";
     private String m_channelLanguage = "en-us";
@@ -121,12 +124,12 @@ public class RSSGenerator {
     private static final int MAX_CHARACTERS = Integer.MAX_VALUE-1;
 
     /**
-     *  Initialize the RSS generator for a given WikiEngine.
+     *  Initialize the RSS generator for a given Engine.
      *
-     *  @param engine The WikiEngine.
+     *  @param engine The Engine.
      *  @param properties The properties.
      */
-    public RSSGenerator( final WikiEngine engine, final Properties properties ) {
+    public RSSGenerator( final Engine engine, final Properties properties ) {
         m_engine = engine;
         m_channelDescription = properties.getProperty( PROP_CHANNEL_DESCRIPTION, m_channelDescription );
         m_channelLanguage = properties.getProperty( PROP_CHANNEL_LANGUAGE, m_channelLanguage );
@@ -190,7 +193,7 @@ public class RSSGenerator {
             buf.append( diff );
         } else {
             buf.append( author ).append( " created this page on " ).append( page.getLastModified() ).append( ":<br /><hr /><br />" );
-            buf.append( m_engine.getRenderingManager().getHTML( page.getName() ) );
+            buf.append( m_engine.getManager( RenderingManager.class ).getHTML( page.getName() ) );
         }
 
         return buf.toString();
@@ -321,7 +324,7 @@ public class RSSGenerator {
             final WikiPage page = i.next();
 
             //  Check if the anonymous user has view access to this page.
-            if( !m_engine.getAuthorizationManager().checkPermission(session, new PagePermission(page,PagePermission.VIEW_ACTION) ) ) {
+            if( !m_engine.getManager( AuthorizationManager.class ).checkPermission(session, new PagePermission(page,PagePermission.VIEW_ACTION) ) ) {
                 // No permission, skip to the next one.
                 continue;
             }
@@ -357,14 +360,14 @@ public class RSSGenerator {
     protected String generateWikiPageRSS( final WikiContext wikiContext, final List< WikiPage > changed, final Feed feed ) {
         feed.setChannelTitle( m_engine.getApplicationName()+": "+wikiContext.getPage().getName() );
         feed.setFeedURL( wikiContext.getViewURL( wikiContext.getPage().getName() ) );
-        final String language = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
+        final String language = m_engine.getManager( VariableManager.class ).getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
 
         if( language != null ) {
             feed.setChannelLanguage( language );
         } else {
             feed.setChannelLanguage( m_channelLanguage );
         }
-        final String channelDescription = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
+        final String channelDescription = m_engine.getManager( VariableManager.class ).getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
 
         if( channelDescription != null ) {
             feed.setChannelDescription( channelDescription );
@@ -412,7 +415,7 @@ public class RSSGenerator {
             log.debug( "Generating RSS for blog, size=" + changed.size() );
         }
 
-        final String ctitle = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_TITLE );
+        final String ctitle = m_engine.getManager( VariableManager.class ).getVariable( wikiContext, PROP_CHANNEL_TITLE );
         if( ctitle != null ) {
             feed.setChannelTitle( ctitle );
         } else {
@@ -421,14 +424,14 @@ public class RSSGenerator {
 
         feed.setFeedURL( wikiContext.getViewURL( wikiContext.getPage().getName() ) );
 
-        final String language = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
+        final String language = m_engine.getManager( VariableManager.class ).getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
         if( language != null ) {
             feed.setChannelLanguage( language );
         } else {
             feed.setChannelLanguage( m_channelLanguage );
         }
 
-        final String channelDescription = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
+        final String channelDescription = m_engine.getManager( VariableManager.class ).getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
         if( channelDescription != null ) {
             feed.setChannelDescription( channelDescription );
         }
@@ -477,7 +480,7 @@ public class RSSGenerator {
                 if( maxlen > MAX_CHARACTERS ) {
                     maxlen = MAX_CHARACTERS;
                 }
-                pageText = m_engine.getRenderingManager().textToHTML( wikiContext, pageText.substring( firstLine + 1, maxlen ).trim() );
+                pageText = m_engine.getManager( RenderingManager.class ).textToHTML( wikiContext, pageText.substring( firstLine + 1, maxlen ).trim() );
                 if( maxlen == MAX_CHARACTERS ) {
                     pageText += "...";
                 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSThread.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSThread.java
index 9707314..1168f84 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSThread.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSThread.java
@@ -18,11 +18,10 @@
  */
 package org.apache.wiki.rss;
 
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WatchDog;
 import org.apache.wiki.WikiBackgroundThread;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.util.FileUtil;
 
 import java.io.BufferedWriter;
@@ -33,31 +32,30 @@ import java.io.OutputStreamWriter;
 import java.io.Reader;
 import java.io.StringReader;
 import java.io.Writer;
+import java.nio.charset.StandardCharsets;
+
 
 /**
  *  Runs the RSS generation thread.
  *  FIXME: MUST be somewhere else, this is not a good place.
  */
-public class RSSThread extends WikiBackgroundThread
-{
-    static Logger              log = Logger.getLogger( RSSThread.class );
-        
+public class RSSThread extends WikiBackgroundThread {
+
+    private static final Logger log = Logger.getLogger( RSSThread.class );
     private final File m_rssFile;
     private final RSSGenerator m_generator;
-        
     private WatchDog m_watchdog;
     
     /**
      *  Create a new RSS thread.
      *  
-     *  @param engine A WikiEngine to own this thread.
+     *  @param engine A Engine to own this thread.
      *  @param rssFile A File to write the RSS data to.
      *  @param rssInterval How often the RSS should be generated.
      */
-    public RSSThread( final WikiEngine engine, final File rssFile, final int rssInterval )
-    {
+    public RSSThread( final Engine engine, final File rssFile, final int rssInterval ) {
         super( engine, rssInterval );
-        m_generator = engine.getRSSGenerator();
+        m_generator = engine.getManager( RSSGenerator.class );
         m_rssFile = rssFile;
         setName("JSPWiki RSS Generator");
         log.debug( "RSS file will be at "+m_rssFile.getAbsolutePath() );
@@ -81,47 +79,20 @@ public class RSSThread extends WikiBackgroundThread
      * @throws Exception All exceptions are thrown upwards.
      */
     @Override
-    public void backgroundTask() throws Exception
-    {
-        if ( m_generator.isEnabled() )
-        {
-            Writer out = null;
-            Reader in  = null;
-
+    public void backgroundTask() throws Exception {
+        if( m_generator.isEnabled() ) {
             m_watchdog.enterState( "Generating RSS feed", 60 );
-            
-            try
-            {
-                //
-                //  Generate RSS file, output it to
-                //  default "rss.rdf".
-                //
-                log.debug("Regenerating RSS feed to "+m_rssFile);
-
-                final String feed = m_generator.generate();
-
-                in  = new StringReader(feed);
-                out = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( m_rssFile ), "UTF-8") );
+            final String feed = m_generator.generate();
+            log.debug( "Regenerating RSS feed to " + m_rssFile );
 
+            // Generate RSS file, output it to default "rss.rdf".
+            try( final Reader in  = new StringReader( feed );
+                 final Writer out = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( m_rssFile ), StandardCharsets.UTF_8 ) ) ) {
                 FileUtil.copyContents( in, out );
-            }
-            catch( final IOException e )
-            {
-                log.error("Cannot generate RSS feed to "+m_rssFile.getAbsolutePath(), e );
+            } catch( final IOException e ) {
+                log.error( "Cannot generate RSS feed to " + m_rssFile.getAbsolutePath(), e );
                 m_generator.setEnabled( false );
-            }
-            finally
-            {
-                try
-                {
-                    if( in != null )  in.close();
-                    if( out != null ) out.close();
-                }
-                catch( final IOException e )
-                {
-                    log.fatal("Could not close I/O for RSS", e );
-                    m_generator.setEnabled( false );
-                }
+            } finally {
                 m_watchdog.exitState();
             }
 


[jspwiki] 04/20: JSPWIKI-120: use Engine instead of WikiEngine

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

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

commit 6d7dbc36c0664b9763ed35076d6c2f3e6ee4b24b
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 13:16:07 2020 +0100

    JSPWIKI-120: use Engine instead of WikiEngine
---
 .../wiki/ajax/WikiAjaxDispatcherServlet.java       |   3 +-
 .../main/java/org/apache/wiki/api/core/Engine.java |  10 +-
 .../apache/wiki/attachment/AttachmentManager.java  |   2 +-
 .../apache/wiki/attachment/AttachmentServlet.java  | 177 ++++++++-------------
 .../apache/wiki/attachment/DynamicAttachment.java  |  49 +++---
 .../wiki/attachment/DynamicAttachmentProvider.java |  22 ++-
 .../org/apache/wiki/auth/SecurityVerifier.java     |  31 ++--
 .../java/org/apache/wiki/auth/SessionMonitor.java  |  35 ++--
 .../java/org/apache/wiki/auth/UserManager.java     |   2 +-
 .../java/org/apache/wiki/auth/acl/AclManager.java  |  35 ++--
 .../apache/wiki/auth/acl/DefaultAclManager.java    |  89 ++++-------
 .../login/CookieAuthenticationLoginModule.java     |  13 +-
 .../auth/login/WebContainerCallbackHandler.java    |   2 +-
 .../wiki/auth/login/WikiCallbackHandler.java       |   2 +-
 .../apache/wiki/diff/DefaultDifferenceManager.java |  18 ++-
 .../org/apache/wiki/event/WikiEngineEvent.java     |  19 ++-
 .../org/apache/wiki/event/WikiEventManager.java    |  18 +--
 .../wiki/i18n/InternationalizationManager.java     |  44 ++---
 .../java/org/apache/wiki/pages/PageManager.java    |   2 +-
 .../java/org/apache/wiki/pages/PageSorter.java     |  12 +-
 .../org/apache/wiki/plugin/WeblogEntryPlugin.java  |   2 +-
 .../java/org/apache/wiki/plugin/WeblogPlugin.java  |   2 +-
 22 files changed, 245 insertions(+), 344 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
index 41d11ba..d931181 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
@@ -23,6 +23,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.auth.AuthorizationManager;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.util.TextUtil;
@@ -53,7 +54,7 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
     private static final Map< String, AjaxServletContainer > ajaxServlets = new ConcurrentHashMap<>();
     private static final Logger log = Logger.getLogger( WikiAjaxDispatcherServlet.class.getName() );
     private String PATH_AJAX = "/ajax/";
-    private WikiEngine m_engine;
+    private Engine m_engine;
 
     /**
      * {@inheritDoc}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
index d51cb0d..345f9e1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/core/Engine.java
@@ -44,7 +44,7 @@ import java.util.Properties;
  *  This is the main interface through which everything should go.
  *
  *  <p>
- *  There's basically only a single Engine for each web application, and you should always get it using the {@code WikiEngine.getInstance(..)}
+ *  There's basically only a single Engine for each web application, and you should always get it using the {@code Engine.getInstance(..)}
  *  method.
  */
 public interface Engine {
@@ -121,14 +121,14 @@ public interface Engine {
     < T > T getManager( Class< T > manager );
 
     /**
-     * check if the WikiEngine has been configured.
+     * check if the Engine has been configured.
      *
      * @return {@code true} if it has, {@code false} otherwise.
      */
     boolean isConfigured();
 
     /**
-     *  Returns the set of properties that the WikiEngine was initialized with.  Note that this method returns a direct reference, so it's
+     *  Returns the set of properties that the Engine was initialized with.  Note that this method returns a direct reference, so it's
      *  possible to manipulate the properties.  However, this is not advised unless you really know what you're doing.
      *
      *  @return The wiki properties
@@ -201,7 +201,7 @@ public interface Engine {
     String getFrontPage();
 
     /**
-     *  Returns the ServletContext that this particular WikiEngine was initialized with. <strong>It may return {@code null}</strong>,
+     *  Returns the ServletContext that this particular Engine was initialized with. <strong>It may return {@code null}</strong>,
      *  if the Engine is not running inside a servlet container!
      *
      *  @since 1.7.10
@@ -305,7 +305,7 @@ public interface Engine {
     String getApplicationName();
 
     /**
-     *  Returns the root path.  The root path is where the WikiEngine is located in the file system.
+     *  Returns the root path.  The root path is where the Engine is located in the file system.
      *
      *  @since 2.2
      *  @return A path to where the Wiki is installed in the local filesystem.
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 07dd4a5..31fb09a 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
@@ -39,7 +39,7 @@ import java.util.List;
  *  Provides facilities for handling attachments.  All attachment handling goes through this class.
  *  <p>
  *  The AttachmentManager provides a facade towards the current WikiAttachmentProvider that is in use.
- *  It is created by the WikiEngine as a singleton object, and can be requested through the WikiEngine.
+ *  It is created by the Engine as a singleton object, and can be requested through the Engine.
  *
  *  @since 1.9.28
  */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
index 9abea2d..366666b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
@@ -30,6 +30,7 @@ import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.WikiSession;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.RedirectException;
 import org.apache.wiki.api.exceptions.WikiException;
@@ -38,6 +39,7 @@ import org.apache.wiki.auth.permissions.PermissionFactory;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.ui.progress.ProgressItem;
+import org.apache.wiki.ui.progress.ProgressManager;
 import org.apache.wiki.util.HttpUtil;
 import org.apache.wiki.util.TextUtil;
 
@@ -77,7 +79,7 @@ public class AttachmentServlet extends HttpServlet {
 
     private static final long serialVersionUID = 3257282552187531320L;
 
-    private WikiEngine m_engine;
+    private Engine m_engine;
     private static final Logger log = Logger.getLogger( AttachmentServlet.class );
 
     private static final String HDR_VERSION     = "version";
@@ -107,50 +109,36 @@ public class AttachmentServlet extends HttpServlet {
 
     /**
      *  Initializes the servlet from WikiEngine properties.
-     *
      */
-    @Override public void init( final ServletConfig config ) throws ServletException {
-        final String tmpDir;
-
-        m_engine         = WikiEngine.getInstance( config );
+    @Override
+    public void init( final ServletConfig config ) throws ServletException {
+        m_engine = WikiEngine.getInstance( config );
         final Properties props = m_engine.getWikiProperties();
+        final String tmpDir = m_engine.getWorkDir() + File.separator + "attach-tmp";
+        final String allowed = TextUtil.getStringProperty( props, AttachmentManager.PROP_ALLOWEDEXTENSIONS, null );
+        m_maxSize = TextUtil.getIntegerProperty( props, AttachmentManager.PROP_MAXSIZE, Integer.MAX_VALUE );
 
-        tmpDir         = m_engine.getWorkDir()+File.separator+"attach-tmp";
-
-        m_maxSize        = TextUtil.getIntegerProperty( props,
-                AttachmentManager.PROP_MAXSIZE,
-                Integer.MAX_VALUE );
-
-        final String allowed = TextUtil.getStringProperty( props,
-                AttachmentManager.PROP_ALLOWEDEXTENSIONS,
-                null );
-
-        if( allowed != null && allowed.length() > 0 )
-            m_allowedPatterns = allowed.toLowerCase().split("\\s");
-        else
-            m_allowedPatterns = new String[0];
-
-        final String forbidden = TextUtil.getStringProperty( props,
-                AttachmentManager.PROP_FORBIDDENEXTENSIONS,
-                null );
+        if( allowed != null && allowed.length() > 0 ) {
+            m_allowedPatterns = allowed.toLowerCase().split( "\\s" );
+        } else {
+            m_allowedPatterns = new String[ 0 ];
+        }
 
-        if( forbidden != null && forbidden.length() > 0 )
+        final String forbidden = TextUtil.getStringProperty( props, AttachmentManager.PROP_FORBIDDENEXTENSIONS,null );
+        if( forbidden != null && forbidden.length() > 0 ) {
             m_forbiddenPatterns = forbidden.toLowerCase().split("\\s");
-        else
+        } else {
             m_forbiddenPatterns = new String[0];
+        }
 
         final File f = new File( tmpDir );
-        if( !f.exists() )
-        {
+        if( !f.exists() ) {
             f.mkdirs();
-        }
-        else if( !f.isDirectory() )
-        {
-            log.fatal("A file already exists where the temporary dir is supposed to be: "+tmpDir+".  Please remove it.");
+        } else if( !f.isDirectory() ) {
+            log.fatal( "A file already exists where the temporary dir is supposed to be: " + tmpDir + ".  Please remove it." );
         }
 
-        log.debug( "UploadServlet initialized. Using " +
-                tmpDir + " for temporary storage." );
+        log.debug( "UploadServlet initialized. Using " + tmpDir + " for temporary storage." );
     }
 
     private boolean isTypeAllowed( String name )
@@ -181,8 +169,8 @@ public class AttachmentServlet extends HttpServlet {
      *  @param res The servlet response
      */
 
-    @Override protected void doOptions( final HttpServletRequest req, final HttpServletResponse res )
-    {
+    @Override
+    protected void doOptions( final HttpServletRequest req, final HttpServletResponse res ) {
         res.setHeader( "Allow", "GET, PUT, POST, OPTIONS, PROPFIND, PROPPATCH, MOVE, COPY, DELETE");
         res.setStatus( HttpServletResponse.SC_OK );
     }
@@ -193,11 +181,11 @@ public class AttachmentServlet extends HttpServlet {
      *
      */
     // FIXME: Messages would need to be localized somehow.
-    @Override public void doGet( final HttpServletRequest  req, final HttpServletResponse res ) throws IOException {
+    @Override
+    public void doGet( final HttpServletRequest  req, final HttpServletResponse res ) throws IOException {
         final WikiContext context = new WikiContext( m_engine, req, WikiContext.ATTACH );
         final AttachmentManager mgr = m_engine.getManager( AttachmentManager.class );
-        final AuthorizationManager authmgr = m_engine.getAuthorizationManager();
-
+        final AuthorizationManager authmgr = m_engine.getManager( AuthorizationManager.class );
         final String version = req.getParameter( HDR_VERSION );
         final String nextPage = req.getParameter( "nextpage" );
         final String page = context.getPage().getName();
@@ -209,8 +197,7 @@ public class AttachmentServlet extends HttpServlet {
             return;
         }
 
-        final OutputStream out = res.getOutputStream();
-        try {
+        try( final OutputStream out = res.getOutputStream() ) {
             log.debug("Attempting to download att "+page+", version "+version);
             if( version != null ) {
                 ver = Integer.parseInt( version );
@@ -309,18 +296,6 @@ public class AttachmentServlet extends HttpServlet {
             //
             log.debug( "I/O exception during download", ioe );
             sendError( res, "Error: " + ioe.getMessage() );
-        } finally {
-            //
-            //  Quite often, aggressive clients close the connection when they have received the last bits.
-            //  Therefore, we close the output, but ignore any exception that might come out of it.
-            //
-            try {
-                if( out != null ) {
-                    out.close();
-                }
-            } catch( final IOException ioe ) {
-                // ignore
-            }
         }
     }
 
@@ -339,23 +314,19 @@ public class AttachmentServlet extends HttpServlet {
      * @param fileName The name to check for.
      * @return A valid mime type, or application/binary, if not recognized
      */
-    private static String getMimeType( final WikiContext ctx, final String fileName )
-    {
+    private static String getMimeType( final WikiContext ctx, final String fileName ) {
         String mimetype = null;
 
         final HttpServletRequest req = ctx.getHttpRequest();
-        if( req != null )
-        {
+        if( req != null ) {
             final ServletContext s = req.getSession().getServletContext();
 
-            if( s != null )
-            {
+            if( s != null ) {
                 mimetype = s.getMimeType( fileName.toLowerCase() );
             }
         }
 
-        if( mimetype == null )
-        {
+        if( mimetype == null ) {
             mimetype = "application/binary";
         }
 
@@ -373,7 +344,8 @@ public class AttachmentServlet extends HttpServlet {
      * content of the file.
      *
      */
-    @Override public void doPost( final HttpServletRequest req, final HttpServletResponse res ) throws IOException {
+    @Override
+    public void doPost( final HttpServletRequest req, final HttpServletResponse res ) throws IOException {
         try {
             final String nextPage = upload( req );
             req.getSession().removeAttribute("msg");
@@ -391,15 +363,10 @@ public class AttachmentServlet extends HttpServlet {
      *  Validates the next page to be on the same server as this webapp.
      *  Fixes [JSPWIKI-46].
      */
-    private String validateNextPage( String nextPage, final String errorPage )
-    {
-        if( nextPage.indexOf("://") != -1 )
-        {
-            // It's an absolute link, so unless it starts with our address, we'll
-            // log an error.
-
-            if( !nextPage.startsWith( m_engine.getBaseURL() ) )
-            {
+    private String validateNextPage( String nextPage, final String errorPage ) {
+        if( nextPage.contains( "://" ) ) {
+            // It's an absolute link, so unless it starts with our address, we'll log an error.
+            if( !nextPage.startsWith( m_engine.getBaseURL() ) ) {
                 log.warn("Detected phishing attempt by redirecting to an unsecure location: "+nextPage);
                 nextPage = errorPage;
             }
@@ -415,10 +382,9 @@ public class AttachmentServlet extends HttpServlet {
      *  @return The page to which we should go next.
      *  @throws RedirectException If there's an error and a redirection is needed
      *  @throws IOException If upload fails
-     * @throws FileUploadException
      */
     protected String upload( final HttpServletRequest req ) throws RedirectException, IOException {
-        String msg     = "";
+        final String msg;
         final String attName = "(unknown)";
         final String errorPage = m_engine.getURL( WikiContext.ERROR, "", null ); // If something bad happened, Upload should be able to take care of most stuff
         String nextPage = errorPage;
@@ -436,7 +402,7 @@ public class AttachmentServlet extends HttpServlet {
             final WikiContext context = new WikiContext( m_engine, req, WikiContext.ATTACH );
             final UploadListener pl = new UploadListener();
 
-            m_engine.getProgressManager().startProgress( pl, progressId );
+            m_engine.getManager( ProgressManager.class ).startProgress( pl, progressId );
 
             final ServletFileUpload upload = new ServletFileUpload( factory );
             upload.setHeaderEncoding( "UTF-8" );
@@ -453,22 +419,24 @@ public class AttachmentServlet extends HttpServlet {
 
             for( final FileItem item : items ) {
                 if( item.isFormField() ) {
-                    if( item.getFieldName().equals("page") ) {
-                        //
+                    switch( item.getFieldName() ) {
+                    case "page":
                         // FIXME: Kludge alert.  We must end up with the parent page name, if this is an upload of a new revision
-                        //
-
-                        wikipage = item.getString("UTF-8");
-                        final int x = wikipage.indexOf("/");
-
-                        if( x != -1 ) wikipage = wikipage.substring(0,x);
-                    } else if( item.getFieldName().equals("changenote") ) {
-                        changeNote = item.getString("UTF-8");
-                        if (changeNote != null) {
-                            changeNote = TextUtil.replaceEntities(changeNote);
+                        wikipage = item.getString( "UTF-8" );
+                        final int x = wikipage.indexOf( "/" );
+                        if( x != -1 ) {
+                            wikipage = wikipage.substring( 0, x );
                         }
-                    } else if( item.getFieldName().equals( "nextpage" ) ) {
-                        nextPage = validateNextPage( item.getString("UTF-8"), errorPage );
+                        break;
+                    case "changenote":
+                        changeNote = item.getString( "UTF-8" );
+                        if( changeNote != null ) {
+                            changeNote = TextUtil.replaceEntities( changeNote );
+                        }
+                        break;
+                    case "nextpage":
+                        nextPage = validateNextPage( item.getString( "UTF-8" ), errorPage );
+                        break;
                     }
                 } else {
                     fileItems.add( item );
@@ -506,7 +474,7 @@ public class AttachmentServlet extends HttpServlet {
 
             throw new IOException( msg, e );
         } finally {
-            m_engine.getProgressManager().stopProgress( progressId );
+            m_engine.getManager( ProgressManager.class ).stopProgress( progressId );
             // FIXME: In case of exceptions should absolutely remove the uploaded file.
         }
 
@@ -532,9 +500,7 @@ public class AttachmentServlet extends HttpServlet {
                                      String filename, final String errorPage,
                                      final String parentPage, final String changenote,
                                      final long contentLength )
-            throws RedirectException,
-            IOException, ProviderException
-    {
+            throws RedirectException, IOException, ProviderException {
         boolean created = false;
 
         try {
@@ -573,31 +539,20 @@ public class AttachmentServlet extends HttpServlet {
             throw new RedirectException("File could not be opened.", errorPage);
         }
 
-        //
-        //  Check whether we already have this kind of a page.
-        //  If the "page" parameter already defines an attachment
-        //  name for an update, then we just use that file.
-        //  Otherwise we create a new attachment, and use the
-        //  filename given.  Incidentally, this will also mean
-        //  that if the user uploads a file with the exact
-        //  same name than some other previous attachment,
-        //  then that attachment gains a new version.
-        //
-
+        //  Check whether we already have this kind of a page. If the "page" parameter already defines an attachment
+        //  name for an update, then we just use that file. Otherwise we create a new attachment, and use the
+        //  filename given.  Incidentally, this will also mean that if the user uploads a file with the exact
+        //  same name than some other previous attachment, then that attachment gains a new version.
         Attachment att = mgr.getAttachmentInfo( context.getPage().getName() );
-
         if( att == null ) {
             att = new Attachment( m_engine, parentPage, filename );
             created = true;
         }
         att.setSize( contentLength );
 
-        //
         //  Check if we're allowed to do this?
-        //
-
         final Permission permission = PermissionFactory.getPagePermission( att, "upload" );
-        if( m_engine.getAuthorizationManager().checkPermission( context.getWikiSession(), permission ) ) {
+        if( m_engine.getManager( AuthorizationManager.class ).checkPermission( context.getWikiSession(), permission ) ) {
             if( user != null ) {
                 att.setAuthor( user.getName() );
             }
@@ -630,12 +585,14 @@ public class AttachmentServlet extends HttpServlet {
         public long m_currentBytes;
         public long m_totalBytes;
 
-        @Override public void update( final long recvdBytes, final long totalBytes, final int item) {
+        @Override
+        public void update( final long recvdBytes, final long totalBytes, final int item) {
             m_currentBytes = recvdBytes;
             m_totalBytes   = totalBytes;
         }
 
-        @Override public int getProgress() {
+        @Override
+        public int getProgress() {
             return ( int )( ( ( float )m_currentBytes / m_totalBytes ) * 100 + 0.5 );
         }
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachment.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachment.java
index 7936643..796d96f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachment.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachment.java
@@ -18,31 +18,27 @@
  */
 package org.apache.wiki.attachment;
 
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
+
 
 /**
- *  A DynamicAttachment is an attachment which does not really exist, but is
- *  created dynamically by a JSPWiki component.
+ *  A DynamicAttachment is an attachment which does not really exist, but is created dynamically by a JSPWiki component.
  *  <p>
- *  Note that a DynamicAttachment might not be available before it is actually
- *  created by a component (e.g. plugin), and therefore trying to access it
- *  before that component has been invoked, might result in a surprising 404.
+ *  Note that a DynamicAttachment might not be available before it is actually created by a component (e.g. plugin), and therefore trying
+ *  to access it before that component has been invoked, might result in a surprising 404.
  *  <p>
- *  DynamicAttachments are not listed among regular attachments in the current
- *  version.
+ *  DynamicAttachments are not listed among regular attachments in the current version.
  *  <p>
  *  Usage:
  *
  *  <pre>
  *
- *  class MyDynamicComponent implements DynamicAttachmentProvider
- *  {
+ *  class MyDynamicComponent implements DynamicAttachmentProvider {
  *  ...
  *
  *     DynamicAttachment destatt = mgr.getDynamicAttachment( destattname );
  *
- *     if( destatt == null )
- *     {
+ *     if( destatt == null ) {
  *         destatt = new DynamicAttachment( context.getEngine(),
  *                                          context.getPage().getName(),
  *                                          destfilename,
@@ -50,28 +46,24 @@ import org.apache.wiki.WikiEngine;
  *         destatt.setCacheable( false );
  *     }
  *
- *     // This is used to check whether the attachment is modified or not
- *     // so don't forget to update this if your attachment source changes!
+ *     // This is used to check whether the attachment is modified or not so don't forget to update this if your attachment source changes!
  *     // Else JSPWiki will be serving 304s to anyone who asks...
  *
  *     destatt.setLastModified( context.getPage().getLastModified() );
  *     mgr.storeDynamicAttachment( context,  destatt );
  *  ...
  *
- *      public InputStream getAttachmentData( WikiContext context, Attachment att )
- *          throws IOException
- *      {
+ *      public InputStream getAttachmentData( WikiContext context, Attachment att ) throws IOException {
  *          byte[] bytes = "This is a test".getBytes();
- *
  *          return new ByteArrayInputStream( bytes );
  *      }
  *  </pre>
  *
  *  @since 2.5.34
  */
-public class DynamicAttachment extends Attachment
-{
-    private DynamicAttachmentProvider m_provider  = null;
+public class DynamicAttachment extends Attachment {
+
+    private final DynamicAttachmentProvider m_provider;
 
     /**
      *  Creates a DynamicAttachment.
@@ -81,12 +73,11 @@ public class DynamicAttachment extends Attachment
      *  @param fileName The filename of the attachment
      *  @param provider The provider which will be used to generate the attachment.
      */
-    public DynamicAttachment(WikiEngine engine,
-                             String parentPage,
-                             String fileName,
-                             DynamicAttachmentProvider provider)
-    {
-        super(engine, parentPage, fileName);
+    public DynamicAttachment( final Engine engine,
+                              final String parentPage,
+                              final String fileName,
+                              final DynamicAttachmentProvider provider ) {
+        super( engine, parentPage, fileName );
         m_provider = provider;
     }
 
@@ -95,8 +86,8 @@ public class DynamicAttachment extends Attachment
      *
      *  @return A Provider component for this attachment.
      */
-    public DynamicAttachmentProvider getProvider()
-    {
+    public DynamicAttachmentProvider getProvider() {
         return m_provider;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachmentProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachmentProvider.java
index c6d9ba9..a005cad 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachmentProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DynamicAttachmentProvider.java
@@ -18,27 +18,25 @@
  */
 package org.apache.wiki.attachment;
 
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.exceptions.ProviderException;
+
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.apache.wiki.WikiContext;
-import org.apache.wiki.api.exceptions.ProviderException;
 
 /**
- *  Provides the data for an attachment.  Please note that there will
- *  be a strong reference retained for the provider for each Attachment
- *  it provides, so do try to keep the object light.  Also, reuse objects
- *  if possible.
+ *  Provides the data for an attachment.  Please note that there will be a strong reference retained for the provider for each Attachment
+ *  it provides, so do try to keep the object light.  Also, reuse objects if possible.
  *  <p>
  *  The Provider needs to be thread-safe.
  *
  *  @since  2.5.34
  */
-public interface DynamicAttachmentProvider
-{
+public interface DynamicAttachmentProvider {
+
     /**
-     *  Returns a stream of data for this attachment.  The stream will be
-     *  closed by AttachmentServlet.
+     *  Returns a stream of data for this attachment.  The stream will be closed by AttachmentServlet.
      *
      *  @param context A Wiki Context
      *  @param att The Attachment for which the data should be received.
@@ -46,6 +44,6 @@ public interface DynamicAttachmentProvider
      *  @throws ProviderException If something goes wrong internally
      *  @throws IOException If something goes wrong when reading the data
      */
-    InputStream getAttachmentData( WikiContext context, Attachment att )
-        throws ProviderException, IOException;
+    InputStream getAttachmentData( WikiContext context, Attachment att ) throws ProviderException, IOException;
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/SecurityVerifier.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/SecurityVerifier.java
index fbe727d..dfc4a20 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/SecurityVerifier.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/SecurityVerifier.java
@@ -55,8 +55,8 @@ import java.util.List;
 import java.util.Set;
 
 /**
- * Helper class for verifying JSPWiki's security configuration. Invoked by
- * <code>admin/SecurityConfig.jsp</code>.
+ * Helper class for verifying JSPWiki's security configuration. Invoked by <code>admin/SecurityConfig.jsp</code>.
+ *
  * @since 2.4
  */
 public final class SecurityVerifier {
@@ -120,13 +120,23 @@ public final class SecurityVerifier {
     /** Message topic for JAAS information messages. */
     public static final String    INFO_JAAS                    = "Info.Jaas";
 
-    private static final String[] CONTAINER_ACTIONS            = new String[]
-                                                               { "View pages", "Comment on existing pages",
-            "Edit pages", "Upload attachments", "Create a new group", "Rename an existing page", "Delete pages" };
-
-    private static final String[] CONTAINER_JSPS               = new String[]
-                                                               { "/Wiki.jsp", "/Comment.jsp", "/Edit.jsp",
-            "/Upload.jsp", "/NewGroup.jsp", "/Rename.jsp", "/Delete.jsp" };
+    private static final String[] CONTAINER_ACTIONS            = new String[] { "View pages",
+                                                                                "Comment on existing pages",
+                                                                                "Edit pages",
+                                                                                "Upload attachments",
+                                                                                "Create a new group",
+                                                                                "Rename an existing page",
+                                                                                "Delete pages"
+                                                                              };
+
+    private static final String[] CONTAINER_JSPS               = new String[] { "/Wiki.jsp",
+                                                                                "/Comment.jsp",
+                                                                                "/Edit.jsp",
+                                                                                "/Upload.jsp",
+                                                                                "/NewGroup.jsp",
+                                                                                "/Rename.jsp",
+                                                                                "/Delete.jsp"
+                                                                              };
 
     private static final String   BG_GREEN                     = "bgcolor=\"#c0ffc0\"";
 
@@ -135,7 +145,8 @@ public final class SecurityVerifier {
     private static final Logger LOG                          = Logger.getLogger( SecurityVerifier.class.getName() );
 
     /**
-     * Constructs a new SecurityVerifier for a supplied WikiEngine and WikiSession.
+     * Constructs a new SecurityVerifier for a supplied Engine and WikiSession.
+     *
      * @param engine the wiki engine
      * @param session the wiki session (typically, that of an administrator)
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
index 4972c90..be81313 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/SessionMonitor.java
@@ -32,13 +32,12 @@ import java.security.Principal;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
 
 /**
- *  <p>Manages WikiSession's for different WikiEngine's.</p>
+ *  <p>Manages WikiSession's for different Engine's.</p>
  *  <p>The WikiSession's are stored both in the remote user HttpSession and in the SessionMonitor for the WikeEngine.
  *  This class must be configured as a session listener in the web.xml for the wiki web application.
  *  </p>
@@ -47,7 +46,7 @@ public class SessionMonitor implements HttpSessionListener {
 
     private static final Logger log = Logger.getLogger( SessionMonitor.class );
 
-    /** Map with WikiEngines as keys, and SessionMonitors as values. */
+    /** Map with Engines as keys, and SessionMonitors as values. */
     private static ConcurrentHashMap< Engine, SessionMonitor > c_monitors = new ConcurrentHashMap<>();
 
     /** Weak hashmap with HttpSessions as keys, and WikiSessions as values. */
@@ -58,12 +57,12 @@ public class SessionMonitor implements HttpSessionListener {
     private final PrincipalComparator m_comparator = new PrincipalComparator();
 
     /**
-     * Returns the instance of the SessionMonitor for this wiki.
-     * Only one SessionMonitor exists per WikiEngine.
+     * Returns the instance of the SessionMonitor for this wiki. Only one SessionMonitor exists per Engine.
+     *
      * @param engine the wiki engine
      * @return the session monitor
      */
-    public static final SessionMonitor getInstance( final Engine engine ) {
+    public static SessionMonitor getInstance( final Engine engine ) {
         if( engine == null )
         {
             throw new IllegalArgumentException( "Engine cannot be null." );
@@ -253,26 +252,16 @@ public class SessionMonitor implements HttpSessionListener {
      * @param se the HTTP session event
      */
     @Override
-    public void sessionDestroyed( final HttpSessionEvent se )
-    {
+    public void sessionDestroyed( final HttpSessionEvent se ) {
         final HttpSession session = se.getSession();
-        final Iterator<SessionMonitor> it = c_monitors.values().iterator();
-        while( it.hasNext() )
-        {
-            final SessionMonitor monitor = it.next();
-
-            final WikiSession storedSession = monitor.findSession(session);
-
-            monitor.remove(session);
-
+        for( final SessionMonitor monitor : c_monitors.values() ) {
+            final WikiSession storedSession = monitor.findSession( session );
+            monitor.remove( session );
             log.debug( "Removed session " + session.getId() + "." );
-
-            if( storedSession != null )
-            {
-                fireEvent( WikiSecurityEvent.SESSION_EXPIRED,
-                           storedSession.getLoginPrincipal(),
-                           storedSession );
+            if( storedSession != null ) {
+                fireEvent( WikiSecurityEvent.SESSION_EXPIRED, storedSession.getLoginPrincipal(), storedSession );
             }
         }
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java
index c59130b..f68dda1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/UserManager.java
@@ -54,7 +54,7 @@ public interface UserManager {
     void initialize( final Engine engine, final Properties props );
 
     /**
-     * Returns the UserDatabase employed by this WikiEngine. The UserDatabase is lazily initialized by this method, if it does
+     * Returns the UserDatabase employed by this Engine. The UserDatabase is lazily initialized by this method, if it does
      * not exist yet. If the initialization fails, this method will use the inner class DummyUserDatabase as a default (which
      * is enough to get JSPWiki running).
      *
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclManager.java
index 646d320..17ae713 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/AclManager.java
@@ -18,33 +18,33 @@
  */
 package org.apache.wiki.auth.acl;
 
-import java.util.Properties;
-
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.auth.WikiSecurityException;
 
+import java.util.Properties;
+
 /**
  *  Specifies how to parse and return ACLs from wiki pages.
+ *
  *  @since 2.3
  */
-public interface AclManager
-{
+public interface AclManager {
 
     /**
      * Initializes the AclManager with a supplied wiki engine and properties.
+     *
      * @param engine the wiki engine
      * @param props the initialization properties
      */
-    void initialize( WikiEngine engine, Properties props );
+    void initialize( Engine engine, Properties props );
 
     /**
-     * A helper method for parsing textual AccessControlLists. The line is in
-     * form "(ALLOW) <permission><principal>, <principal>, <principal>". This
-     * method was moved from Authorizer.
-     * @param page The current wiki page. If the page already has an ACL, it
-     *            will be used as a basis for this ACL in order to avoid the
-     *            creation of a new one.
+     * A helper method for parsing textual AccessControlLists. The line is in form
+     * "(ALLOW) <permission><principal>, <principal>, <principal>". This method was moved from Authorizer.
+     *
+     * @param page The current wiki page. If the page already has an ACL, it will be used as a basis for this ACL in order to avoid the
+     *             creation of a new one.
      * @param ruleLine The rule line, as described above.
      * @return A valid Access Control List. May be empty.
      * @throws WikiSecurityException if the ruleLine was faulty somehow.
@@ -53,11 +53,10 @@ public interface AclManager
     Acl parseAcl( WikiPage page, String ruleLine ) throws WikiSecurityException;
 
     /**
-     * Returns the access control list for the page.
-     * If the ACL has not been parsed yet, it is done
-     * on-the-fly. If the page has a parent page, then that is tried also.
-     * This method was moved from Authorizer;
-     * it was consolidated with some code from AuthorizationManager.
+     * Returns the access control list for the page. If the ACL has not been parsed yet, it is done on-the-fly. If the page has a
+     * parent page, then that is tried also. This method was moved from Authorizer; it was consolidated with some code from
+     * AuthorizationManager.
+     *
      * @param page the wiki page
      * @since 2.2.121
      * @return the Acl representing permissions for the page
@@ -66,10 +65,12 @@ public interface AclManager
 
     /**
      * Sets the access control list for the page and persists it.
+     *
      * @param page the wiki page
      * @param acl the access control list
      * @since 2.5
      * @throws WikiSecurityException if the ACL cannot be set or persisted
      */
     void setPermissions( WikiPage page, Acl acl ) throws WikiSecurityException;
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
index 29b593f..f847444 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/acl/DefaultAclManager.java
@@ -20,8 +20,8 @@ package org.apache.wiki.auth.acl;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.auth.AuthorizationManager;
@@ -31,6 +31,7 @@ import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.auth.permissions.PermissionFactory;
 import org.apache.wiki.pages.PageLock;
 import org.apache.wiki.pages.PageManager;
+import org.apache.wiki.render.RenderingManager;
 
 import java.security.Permission;
 import java.security.Principal;
@@ -55,15 +56,16 @@ public class DefaultAclManager implements AclManager {
     private static final Logger log = Logger.getLogger(DefaultAclManager.class);
 
     private AuthorizationManager m_auth = null;
-    private WikiEngine m_engine = null;
-    private static final String PERM_REGEX = "(" +
-            PagePermission.COMMENT_ACTION + "|" +
-            PagePermission.DELETE_ACTION + "|" +
-            PagePermission.EDIT_ACTION + "|" +
-            PagePermission.MODIFY_ACTION + "|" +
-            PagePermission.RENAME_ACTION + "|" +
-            PagePermission.UPLOAD_ACTION + "|" +
-            PagePermission.VIEW_ACTION + ")";
+    private Engine m_engine = null;
+    private static final String PERM_REGEX = "("
+                                              + PagePermission.COMMENT_ACTION + "|"
+                                              + PagePermission.DELETE_ACTION  + "|"
+                                              + PagePermission.EDIT_ACTION    + "|"
+                                              + PagePermission.MODIFY_ACTION  + "|"
+                                              + PagePermission.RENAME_ACTION  + "|"
+                                              + PagePermission.UPLOAD_ACTION  + "|"
+                                              + PagePermission.VIEW_ACTION    +
+                                             ")";
     private static final String ACL_REGEX = "\\[\\{\\s*ALLOW\\s+" + PERM_REGEX + "\\s*(.*?)\\s*\\}\\]";
 
     /**
@@ -73,30 +75,16 @@ public class DefaultAclManager implements AclManager {
      */
     public static final Pattern ACL_PATTERN = Pattern.compile( ACL_REGEX );
 
-    /**
-     * Initializes the AclManager with a supplied wiki engine and properties.
-     *
-     * @param engine the wiki engine
-     * @param props  the initialization properties
-     * @see org.apache.wiki.auth.acl.AclManager#initialize(org.apache.wiki.WikiEngine, java.util.Properties)
-     */
-    @Override public void initialize( final WikiEngine engine, final Properties props ) {
-        m_auth = engine.getAuthorizationManager();
+    /** {@inheritDoc} */
+    @Override
+    public void initialize( final Engine engine, final Properties props ) {
+        m_auth = engine.getManager( AuthorizationManager.class );
         m_engine = engine;
     }
 
-    /**
-     * A helper method for parsing textual AccessControlLists. The line is in form
-     * {@code ALLOW <permission> <principal>, <principal>, <principal>}. This method was moved from Authorizer.
-     *
-     * @param page The current wiki page. If the page already has an ACL, it will be used as a basis for this ACL in order to avoid the
-     *             creation of a new one.
-     * @param ruleLine The rule line, as described above.
-     * @return A valid Access Control List. May be empty.
-     * @throws WikiSecurityException if the ruleLine was faulty somehow.
-     * @since 2.1.121
-     */
-    @Override public Acl parseAcl( final WikiPage page, final String ruleLine ) throws WikiSecurityException {
+    /** {@inheritDoc} */
+    @Override
+    public Acl parseAcl( final WikiPage page, final String ruleLine ) throws WikiSecurityException {
         Acl acl = page.getAcl();
         if (acl == null) {
             acl = new AclImpl();
@@ -138,19 +126,9 @@ public class DefaultAclManager implements AclManager {
     }
 
 
-    /**
-     * Returns the access control list for the page.
-     * If the ACL has not been parsed yet, it is done
-     * on-the-fly. If the page has a parent page, then that is tried also.
-     * This method was moved from Authorizer;
-     * it was consolidated with some code from AuthorizationManager.
-     * This method is guaranteed to return a non-<code>null</code> Acl.
-     *
-     * @param page the page
-     * @return the Acl representing permissions for the page
-     * @since 2.2.121
-     */
-    @Override public Acl getPermissions( final WikiPage page ) {
+    /** {@inheritDoc} */
+    @Override
+    public Acl getPermissions( final WikiPage page ) {
         //  Does the page already have cached ACLs?
         Acl acl = page.getAcl();
         log.debug( "page=" + page.getName() + "\n" + acl );
@@ -164,7 +142,7 @@ public class DefaultAclManager implements AclManager {
                 //  Or, try parsing the page
                 final WikiContext ctx = new WikiContext( m_engine, page );
                 ctx.setVariable( WikiContext.VAR_EXECUTE_PLUGINS, Boolean.FALSE );
-                m_engine.getRenderingManager().getHTML(ctx, page);
+                m_engine.getManager( RenderingManager.class ).getHTML(ctx, page);
 
                 if (page.getAcl() == null) {
                     page.setAcl( new AclImpl() );
@@ -176,19 +154,9 @@ public class DefaultAclManager implements AclManager {
         return acl;
     }
 
-    /**
-     * Sets the access control list for the page and persists it by prepending
-     * it to the wiki page markup and saving the page. When this method is
-     * called, all other ACL markup in the page is removed. This method will forcibly
-     * expire locks on the wiki page if they exist. Any ProviderExceptions will be
-     * re-thrown as WikiSecurityExceptions.
-     *
-     * @param page the wiki page
-     * @param acl  the access control list
-     * @throws WikiSecurityException of the Acl cannot be set
-     * @since 2.5
-     */
-    @Override public void setPermissions( final WikiPage page, final Acl acl ) throws WikiSecurityException {
+    /** {@inheritDoc} */
+    @Override
+    public void setPermissions( final WikiPage page, final Acl acl ) throws WikiSecurityException {
         final PageManager pageManager = m_engine.getManager( PageManager.class );
 
         // Forcibly expire any page locks
@@ -210,9 +178,8 @@ public class DefaultAclManager implements AclManager {
     }
 
     /**
-     * Generates an ACL string for inclusion in a wiki page, based on a supplied Acl object.
-     * All of the permissions in this Acl are assumed to apply to the same page scope.
-     * The names of the pages are ignored; only the actions and principals matter.
+     * Generates an ACL string for inclusion in a wiki page, based on a supplied Acl object. All of the permissions in this Acl are
+     * assumed to apply to the same page scope. The names of the pages are ignored; only the actions and principals matter.
      *
      * @param acl the ACL
      * @return the ACL string
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
index c5facb7..92b7057 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
@@ -19,7 +19,6 @@
 package org.apache.wiki.auth.login;
 
 import org.apache.log4j.Logger;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.auth.WikiPrincipal;
 import org.apache.wiki.util.FileUtil;
@@ -64,7 +63,7 @@ import java.util.UUID;
  *  <ol>
  *  <li>{@link HttpRequestCallback}- supplies the cookie, which should contain
  *      an unique id for fetching the UID.</li>
- *  <li>{@link WikiEngineCallback} - allows access to the WikiEngine itself.
+ *  <li>{@link WikiEngineCallback} - allows access to the Engine itself.
  *  </ol>
  * <p>
  * After authentication, a generic WikiPrincipal based on the username will be
@@ -159,7 +158,7 @@ public class CookieAuthenticationLoginModule extends AbstractLoginModule {
     /**
      * Attempts to locate the cookie file.
      *
-     * @param engine WikiEngine
+     * @param engine Engine
      * @param uid    An unique ID fetched from the user cookie
      * @return A File handle, or null, if there was a problem.
      */
@@ -210,11 +209,11 @@ public class CookieAuthenticationLoginModule extends AbstractLoginModule {
      * Sets a login cookie based on properties set by the user.  This method also
      * creates the cookie uid-username mapping in the work directory.
      *
-     * @param engine   The WikiEngine
+     * @param engine   The Engine
      * @param response The HttpServletResponse
      * @param username The username for whom to create the cookie.
      */
-    public static void setLoginCookie( final WikiEngine engine, final HttpServletResponse response, final String username ) {
+    public static void setLoginCookie( final Engine engine, final HttpServletResponse response, final String username ) {
         final UUID uid = UUID.randomUUID();
         final int days = TextUtil.getIntegerProperty( engine.getWikiProperties(), PROP_LOGIN_EXPIRY_DAYS, DEFAULT_EXPIRY_DAYS );
         final Cookie userId = getLoginCookie( uid.toString() );
@@ -240,11 +239,11 @@ public class CookieAuthenticationLoginModule extends AbstractLoginModule {
     /**
      * Clears away the login cookie, and removes the uid-username mapping file as well.
      *
-     * @param engine   WikiEngine
+     * @param engine   Engine
      * @param request  Servlet request
      * @param response Servlet response
      */
-    public static void clearLoginCookie( final WikiEngine engine, final HttpServletRequest request, final HttpServletResponse response ) {
+    public static void clearLoginCookie( final Engine engine, final HttpServletRequest request, final HttpServletResponse response ) {
         final Cookie userId = getLoginCookie( "" );
         userId.setMaxAge( 0 );
         response.addCookie( userId );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/WebContainerCallbackHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/WebContainerCallbackHandler.java
index 4836b58..c217551 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/WebContainerCallbackHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/WebContainerCallbackHandler.java
@@ -41,7 +41,7 @@ public final class WebContainerCallbackHandler implements CallbackHandler {
     /**
      * Create a new handler.
      *
-     * @param engine  The WikiEngine
+     * @param engine  The Engine
      * @param request The request to look into
      */
     public WebContainerCallbackHandler( final Engine engine, final HttpServletRequest request ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/WikiCallbackHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/WikiCallbackHandler.java
index 682ca99..4938bce 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/WikiCallbackHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/WikiCallbackHandler.java
@@ -48,7 +48,7 @@ public class WikiCallbackHandler implements CallbackHandler {
     /**
      *  Create a new callback handler.
      *
-     * @param engine the WikiEngine
+     * @param engine the Engine
      * @param request the user's HTTP request. If passed as <code>null</code>, later requests for {@link HttpRequestCallback} will return an UnsupportedCallbackException
      * @param username the username
      * @param password the password
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
index 859aed6..2e10917 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
@@ -21,7 +21,7 @@ package org.apache.wiki.diff;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.providers.WikiPageProvider;
@@ -47,7 +47,7 @@ public class DefaultDifferenceManager implements DifferenceManager {
      * @param engine The WikiEngine.
      * @param props  A set of properties.
      */
-    public DefaultDifferenceManager( final WikiEngine engine, final Properties props ) {
+    public DefaultDifferenceManager( final Engine engine, final Properties props ) {
         loadProvider( props );
         initializeProvider( engine, props );
 
@@ -69,11 +69,11 @@ public class DefaultDifferenceManager implements DifferenceManager {
     }
 
 
-    private void initializeProvider( final WikiEngine engine, final Properties props ) {
+    private void initializeProvider( final Engine engine, final Properties props ) {
         try {
-            m_provider.initialize(engine, props);
-        } catch( final NoRequiredPropertyException | IOException e1 ) {
-            log.warn("Failed initializing DiffProvider, will use NullDiffProvider.", e1);
+            m_provider.initialize( engine, props );
+        } catch( final NoRequiredPropertyException | IOException e ) {
+            log.warn( "Failed initializing DiffProvider, will use NullDiffProvider.", e );
             m_provider = new DiffProvider.NullDiffProvider(); //doesn't need init'd
         }
     }
@@ -86,7 +86,8 @@ public class DefaultDifferenceManager implements DifferenceManager {
      * @param secondWikiText the new text
      * @return XHTML, or empty string, if no difference detected.
      */
-    @Override public String makeDiff( final WikiContext context, final String firstWikiText, final String secondWikiText ) {
+    @Override
+    public String makeDiff( final WikiContext context, final String firstWikiText, final String secondWikiText ) {
         String diff;
         try {
             diff = m_provider.makeDiffHtml( context, firstWikiText, secondWikiText );
@@ -112,7 +113,8 @@ public class DefaultDifferenceManager implements DifferenceManager {
      *
      *  @return A HTML-ized difference between two pages.  If there is no difference, returns an empty string.
      */
-    @Override public String getDiff( final WikiContext context, final int version1, final int version2 ) {
+    @Override
+    public String getDiff( final WikiContext context, final int version1, final int version2 ) {
         final String page = context.getPage().getName();
         String page1 = context.getEngine().getManager( PageManager.class ).getPureText( page, version1 );
         final String page2 = context.getEngine().getManager( PageManager.class ).getPureText( page, version2 );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
index 65d1ef7..0339313 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
@@ -19,7 +19,7 @@
 package org.apache.wiki.event;
 
 /**
-  * WikiEngineEvent indicates a change in the state of the WikiEngine.
+  * WikiEngineEvent indicates a change in the state of the Engine.
   * 
   * @see     org.apache.wiki.event.WikiEvent
   * @since   2.4.20
@@ -28,26 +28,26 @@ public class WikiEngineEvent extends WikiEvent {
 
     private static final long serialVersionUID = 1829433967558773970L;
 
-    /** Indicates a WikiEngine initialization event, fired as the  wiki service is being initialized (in progress). */
+    /** Indicates a Engine initialization event, fired as the  wiki service is being initialized (in progress). */
     public static final int INITIALIZING   = -1;
 
-    /** Indicates a WikiEngine initialized event, fired after the  wiki service is fully available. */
+    /** Indicates a Engine initialized event, fired after the  wiki service is fully available. */
     public static final int INITIALIZED    = 0;
 
-    /** Indicates a WikiEngine closing event, fired as a signal that the wiki service is shutting down. */
+    /** Indicates a Engine closing event, fired as a signal that the wiki service is shutting down. */
     public static final int SHUTDOWN       = 1;
 
     /**
-     * Indicates a WikiEngine stopped event, fired after halting the wiki service.
-     * A WikiEngine in this state is not expected to provide further services.
+     * Indicates a Engine stopped event, fired after halting the wiki service. A Engine in this state is not expected to provide further
+     * services.
      */
     public static final int STOPPED        = 2;
 
      /**
       *  Constructs an instance of this event.
       *
-      * @param eventSource  the Object that is the source of the event, which <b>must</b> be the WikiEngine. If it is not, this
-      * method thows a ClassCastException
+      * @param eventSource the Object that is the source of the event, which <b>must</b> be the Engine. If it is not, this method thows
+      *                    a ClassCastException
       * @param type the event type
       */
     public WikiEngineEvent( final Object eventSource, final int type ) {
@@ -59,6 +59,7 @@ public class WikiEngineEvent extends WikiEvent {
      *
      * @param type the type of this WikiEngineEvent.
      */
+    @Override
     protected void setType( final int type ) {
         if( type >= INITIALIZING && type <= STOPPED ) {
             super.setType( type );
@@ -82,6 +83,7 @@ public class WikiEngineEvent extends WikiEvent {
      *
      * @return a String representation of the type
      */
+    @Override
     public final String eventName() {
         switch ( getType() ) {
             case INITIALIZING: return "INITIALIZING";
@@ -97,6 +99,7 @@ public class WikiEngineEvent extends WikiEvent {
      *
      * @return a String description of the type
      */
+    @Override
     public final String getTypeDescription() {
         switch ( getType() ) {
             case INITIALIZING: return "wiki engine initializing";
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventManager.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventManager.java
index 9709004..dc069e9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEventManager.java
@@ -37,7 +37,7 @@ import java.util.Vector;
  *  A singleton class that manages the addition and removal of WikiEvent listeners to a event source, as well as the firing of events
  *  to those listeners. An "event source" is the object delegating its event handling to an inner delegating class supplied by this
  *  manager. The class being serviced is considered a "client" of the delegate. The WikiEventManager operates across any number of
- *  simultaneously-existing WikiEngines since it manages all delegation on a per-object basis. Anything that might fire a WikiEvent
+ *  simultaneously-existing Engines since it manages all delegation on a per-object basis. Anything that might fire a WikiEvent
  *  (or any of its subclasses) can be a client.
  *  </p>
  *
@@ -242,14 +242,12 @@ public final class WikiEventManager {
         final Map< Object, WikiEventDelegate > sources = mgr.getDelegates();
         synchronized( sources ) {
             // get an iterator over the Map.Enty objects in the map
-            final Iterator< Map.Entry< Object, WikiEventDelegate > > it = sources.entrySet().iterator();
-            while( it.hasNext() ) {
-                final Map.Entry< Object, WikiEventDelegate > entry = it.next();
+            for( final Map.Entry< Object, WikiEventDelegate > entry : sources.entrySet() ) {
                 // the entry value is the delegate
                 final WikiEventDelegate delegate = entry.getValue();
 
                 // now see if we can remove the listener from the delegate (delegate may be null because this is a weak reference)
-                if( delegate != null && delegate.removeWikiEventListener(listener) ) {
+                if( delegate != null && delegate.removeWikiEventListener( listener ) ) {
                     return true; // was removed
                 }
             }
@@ -375,8 +373,8 @@ public final class WikiEventManager {
         public Set< WikiEventListener > getWikiEventListeners() {
             synchronized( m_listenerList ) {
                 final TreeSet< WikiEventListener > set = new TreeSet<>( new WikiEventListenerComparator() );
-                for( final Iterator< WeakReference< WikiEventListener > >  i = m_listenerList.iterator(); i.hasNext(); ) {
-                    final WikiEventListener l = i.next().get();
+                for( final WeakReference< WikiEventListener > wikiEventListenerWeakReference : m_listenerList ) {
+                    final WikiEventListener l = wikiEventListenerWeakReference.get();
                     if( l != null ) {
                         set.add( l );
                     }
@@ -434,12 +432,12 @@ public final class WikiEventManager {
             boolean needsCleanup = false;
             try {
                 synchronized( m_listenerList ) {
-                    for( int i = 0; i < m_listenerList.size(); i++ ) {
-                        final WikiEventListener listener = m_listenerList.get( i ).get();
+                    for( final WeakReference< WikiEventListener > wikiEventListenerWeakReference : m_listenerList ) {
+                        final WikiEventListener listener = wikiEventListenerWeakReference.get();
                         if( listener != null ) {
                             listener.actionPerformed( event );
                         } else {
-                            needsCleanup  = true;
+                            needsCleanup = true;
                         }
                     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/i18n/InternationalizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/i18n/InternationalizationManager.java
index 799c6e1..6d2e07d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/i18n/InternationalizationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/i18n/InternationalizationManager.java
@@ -18,13 +18,13 @@
  */
 package org.apache.wiki.i18n;
 
+import org.apache.wiki.api.core.Engine;
+
 import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
-import org.apache.wiki.WikiEngine;
-
 
 /**
  *  Manages all internationalization in JSPWiki.
@@ -33,14 +33,10 @@ import org.apache.wiki.WikiEngine;
  */
 public class InternationalizationManager {
 
-    /** The name of the ResourceBundle which contains any and all JSPWiki core
-     *  resource strings.  It's value is {@value}.
-     */
+    /** The name of the ResourceBundle which contains any and all JSPWiki core resource strings.  It's value is {@value}. */
     public static final String CORE_BUNDLE = "CoreResources";
     
-    /** The name of the ResourceBundle which contains any and all JSPWiki default templates
-     *  resource strings.  It's value is {@value}.
-     */
+    /** The name of the ResourceBundle which contains any and all JSPWiki default templates resource strings.  It's value is {@value}. */
     public static final String DEF_TEMPLATE = "templates.default";
     // public static final String JSPWIKI_BUNDLE = "jspwiki";
     // public static final String PLUGINS_BUNDLE = "plugins";
@@ -50,20 +46,17 @@ public class InternationalizationManager {
      *
      *  @param engine To which engine this belongs to
      */
-    public InternationalizationManager( WikiEngine engine )
-    {
+    public InternationalizationManager( final Engine engine ) {
     }
 
     /**
-     *  Returns a String from the CORE_BUNDLE using English as the default
-     *  locale.
+     *  Returns a String from the CORE_BUNDLE using English as the default locale.
      *
      *  @param key Key to find
      *  @return The English string
      *  @throws MissingResourceException If there is no such key
      */
-    public String get( String key ) throws MissingResourceException
-    {
+    public String get( final String key ) throws MissingResourceException {
         return get( CORE_BUNDLE, Locale.ENGLISH, key );
     }
     
@@ -75,34 +68,30 @@ public class InternationalizationManager {
      *  @return A localized string
      *  @throws MissingResourceException If the key cannot be located at all, even from the default locale.
      */
-    public ResourceBundle getBundle( String bundle, Locale locale ) throws MissingResourceException
-    {
-        if( locale == null )
-        {
+    public ResourceBundle getBundle( final String bundle, Locale locale ) throws MissingResourceException {
+        if( locale == null ) {
             locale = Locale.getDefault();
         }
 
-        ResourceBundle b = ResourceBundle.getBundle( bundle, locale );
-
-        return b;
+        return ResourceBundle.getBundle( bundle, locale );
     }
 
     /**
-     *  If you are too lazy to open your own bundle, use this method
-     *  to get a string simply from a bundle.
+     *  If you are too lazy to open your own bundle, use this method to get a string simply from a bundle.
+     *
      *  @param bundle Which bundle the string is in
      *  @param locale Locale to use - null for default
      *  @param key    Which key to use.
      *  @return A localized string (or from the default language, if not found)
      *  @throws MissingResourceException If the key cannot be located at all, even from the default locale.
      */
-    public String get( String bundle, Locale locale, String key ) throws MissingResourceException
-    {
+    public String get( final String bundle, final Locale locale, final String key ) throws MissingResourceException {
         return getBundle( bundle, locale ).getString( key );
     }
 
     /**
      *  Obtain a parameterized String from the bundle.
+     *
      *  @param bundle Which bundle the string is in
      *  @param locale Locale to use - null for default
      *  @param key    Which key to use.
@@ -110,9 +99,8 @@ public class InternationalizationManager {
      *  @return A localized string (or from the default language, if not found)
      *  @throws MissingResourceException If the key cannot be located at all, even from the default locale.
      */
-    public String get( String bundle, Locale locale, String key, Object... args ) throws MissingResourceException
-    {
-        MessageFormat mf = new MessageFormat( get( bundle, locale, key ), locale );
+    public String get( final String bundle, final Locale locale, final String key, final Object... args ) throws MissingResourceException {
+        final MessageFormat mf = new MessageFormat( get( bundle, locale, key ), locale );
         return mf.format( args );
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
index 80ddfc1..a35fce9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageManager.java
@@ -155,7 +155,7 @@ public interface PageManager extends WikiEventListener {
 
     /**
      * Puts the page text into the repository.  Note that this method does NOT update
-     * JSPWiki internal data structures, and therefore you should always use WikiEngine.saveText()
+     * JSPWiki internal data structures, and therefore you should always use saveText()
      *
      * @param page    Page to save
      * @param content Wikimarkup to save
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java
index 42df456..43df364 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/pages/PageSorter.java
@@ -82,12 +82,10 @@ public class PageSorter implements Comparator< String > {
     }
 
     /**
-     * Called by WikiEngine to initialise this instance. Tries to use class
-     * given by the PROP_PAGE_NAME_COMPARATOR property as the page name
-     * comparator. Uses a default comparator if this property is not set or
-     * there is any problem loading the specified class.
+     * Called by Engine to initialise this instance. Tries to use class given by the PROP_PAGE_NAME_COMPARATOR property as the page name
+     * comparator. Uses a default comparator if this property is not set or there is any problem loading the specified class.
      * 
-     * @param props this WikiEngine's properties.
+     * @param props this Engine's properties.
      */
     @SuppressWarnings( "unchecked" )
     public void initialize( final Properties props ) {
@@ -113,9 +111,7 @@ public class PageSorter implements Comparator< String > {
     }
 
     /**
-     * Sorts the specified array into ascending order based on the
-     * PageNameComparator. The actual sort is done using
-     * <code>Arrays.sort()</code>.
+     * Sorts the specified array into ascending order based on the PageNameComparator. The actual sort is done using {@code Arrays.sort()}.
      * 
      * @param nameArray the page names to be sorted
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.java
index 706b53f..1ad6022 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogEntryPlugin.java
@@ -71,7 +71,7 @@ public class WeblogEntryPlugin implements WikiPlugin {
     /**
      * Returns a new page name for entries.  It goes through the list of all blog pages, and finds out the next in line.
      *
-     * @param engine   A WikiEngine
+     * @param engine   A Engine
      * @param blogName The page (or blog) name.
      * @return A new name.
      * @throws ProviderException If something goes wrong.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
index 8c377de..0127e48 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/WeblogPlugin.java
@@ -390,7 +390,7 @@ public class WeblogPlugin implements WikiPlugin, ParserStagePlugin {
      *  Attempts to locate all pages that correspond to the
      *  blog entry pattern.  Will only consider the days on the dates; not the hours and minutes.
      *
-     *  @param engine WikiEngine which is used to get the pages
+     *  @param engine Engine which is used to get the pages
      *  @param baseName The basename (e.g. "Main" if you want "Main_blogentry_xxxx")
      *  @param start The date which is the first to be considered
      *  @param end   The end date which is the last to be considered


[jspwiki] 07/20: JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (2)

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 acd537319929aacbf18174141384d5e9743793ca
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 19:21:21 2020 +0100

    JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (2)
---
 .../org/apache/wiki/modules/ModuleManager.java     |  2 +-
 .../org/apache/wiki/pages/DefaultPageManager.java  | 13 ++++-----
 .../apache/wiki/parser/LinkParsingOperations.java  |  2 +-
 .../apache/wiki/plugin/DefaultPluginManager.java   | 11 ++++---
 .../wiki/providers/AbstractFileProvider.java       |  7 ++---
 .../org/apache/wiki/providers/CachingProvider.java |  2 +-
 .../wiki/providers/VersioningFileProvider.java     |  5 ++--
 .../wiki/references/DefaultReferenceManager.java   | 34 ++++++++++++----------
 .../wiki/render/DefaultRenderingManager.java       | 33 +++++++++++----------
 .../org/apache/wiki/render/RenderingManager.java   |  4 +--
 10 files changed, 59 insertions(+), 54 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java b/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java
index a59e401..d3f6f7d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/modules/ModuleManager.java
@@ -42,7 +42,7 @@ public abstract class ModuleManager {
     /**
      *  Constructs the ModuleManager.
      *
-     *  @param engine The WikiEngine which owns this manager.
+     *  @param engine The Engine which owns this manager.
      */
     public ModuleManager( final Engine engine ) {
         m_engine = engine;
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 fbbedc7..3fb8d83 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
@@ -22,7 +22,6 @@ import org.apache.commons.lang3.ArrayUtils;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiBackgroundThread;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.core.Engine;
@@ -104,9 +103,9 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
     /**
      * Creates a new PageManager.
      *
-     * @param engine WikiEngine instance
+     * @param engine Engine instance
      * @param props  Properties to use for initialization
-     * @throws NoSuchElementException {@value #PROP_PAGEPROVIDER} property not found on WikiEngine properties
+     * @throws NoSuchElementException {@value #PROP_PAGEPROVIDER} property not found on Engine properties
      * @throws WikiException If anything goes wrong, you get this.
      */
     public DefaultPageManager(final Engine engine, final Properties props) throws NoSuchElementException, WikiException {
@@ -234,7 +233,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
 
         // Check if creation of empty pages is allowed; bail if not
         final boolean allowEmpty = TextUtil.getBooleanProperty( m_engine.getWikiProperties(),
-                                                                WikiEngine.PROP_ALLOW_CREATION_OF_EMPTY_PAGES,
+                                                                Engine.PROP_ALLOW_CREATION_OF_EMPTY_PAGES,
                                                          false );
         if ( !allowEmpty && !wikiPageExists( page ) && text.trim().equals( "" ) ) {
             return;
@@ -272,9 +271,9 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
     }
 
     /**
-     * Returns the WikiEngine to which this PageManager belongs to.
+     * Returns the Engine to which this PageManager belongs to.
      *
-     * @return The WikiEngine object.
+     * @return The Engine object.
      */
     protected Engine getEngine() {
         return m_engine;
@@ -637,7 +636,7 @@ public class DefaultPageManager extends ModuleManager implements PageManager {
         /**
          * Create a LockReaper for a given engine.
          *
-         * @param engine WikiEngine to own this thread.
+         * @param engine Engine to own this thread.
          */
         public LockReaper( final Engine engine) {
             super( engine, 60 );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
index 63cb21c..8102e73 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/LinkParsingOperations.java
@@ -37,7 +37,7 @@ import java.util.List;
  */
 public class LinkParsingOperations {
 
-    private static Logger log = Logger.getLogger( LinkParsingOperations.class );
+    private static final Logger log = Logger.getLogger( LinkParsingOperations.class );
     private final WikiContext wikiContext;
 
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
index 55b6d6b..f07950f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
@@ -31,7 +31,6 @@ import org.apache.oro.text.regex.Perl5Compiler;
 import org.apache.oro.text.regex.Perl5Matcher;
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
 import org.apache.wiki.ajax.WikiAjaxServlet;
 import org.apache.wiki.api.core.Engine;
@@ -69,7 +68,7 @@ import java.util.StringTokenizer;
 
 /**
  *  Manages plugin classes.  There exists a single instance of PluginManager
- *  per each instance of WikiEngine, that is, each JSPWiki instance.
+ *  per each instance of Engine, that is, each JSPWiki instance.
  *  <P>
  *  A plugin is defined to have three parts:
  *  <OL>
@@ -146,7 +145,7 @@ import java.util.StringTokenizer;
  *      called once for this class
  *      before any actual execute() methods are called.  You should use the initialize() for e.g.
  *      precalculating things.  But notice that this method is really called only once during the
- *      entire WikiEngine lifetime.  The InitializablePlugin is available from 2.5.30 onwards.</li>
+ *      entire Engine lifetime.  The InitializablePlugin is available from 2.5.30 onwards.</li>
  *  <li>ParserStagePlugin: If you implement this interface, the executeParse() method is called
  *      when JSPWiki is forming the DOM tree.  You will receive an incomplete DOM tree, as well
  *      as the regular parameters.  However, since JSPWiki caches the DOM tree to speed up later
@@ -182,10 +181,10 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
     /**
      *  Create a new PluginManager.
      *
-     *  @param engine WikiEngine which owns this manager.
+     *  @param engine Engine which owns this manager.
      *  @param props Contents of a "jspwiki.properties" file.
      */
-    public DefaultPluginManager( final WikiEngine engine, final Properties props ) {
+    public DefaultPluginManager( final Engine engine, final Properties props ) {
         super( engine );
         final String packageNames = props.getProperty( PROP_SEARCHPATH );
 
@@ -612,7 +611,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
          *  If the plugin extends {@link HttpServlet} it will automatically
          *  register it as AJAX using {@link WikiAjaxDispatcherServlet#registerServlet(String, WikiAjaxServlet)}.
          *
-         *  @param engine The WikiEngine
+         *  @param engine The Engine
          *  @param searchPath A List of Strings, containing different package names.
          *  @param externalJars the list of external jars to search
          */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java
index 4ab94fc..fd5beb1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/providers/AbstractFileProvider.java
@@ -21,7 +21,6 @@ package org.apache.wiki.providers;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
 import org.apache.wiki.InternalWikiException;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.core.Engine;
@@ -140,7 +139,7 @@ public abstract class AbstractFileProvider implements WikiPageProvider {
         }
 
         m_engine = engine;
-        m_encoding = properties.getProperty( WikiEngine.PROP_ENCODING, DEFAULT_ENCODING );
+        m_encoding = properties.getProperty( Engine.PROP_ENCODING, DEFAULT_ENCODING );
         final String os = System.getProperty( "os.name" ).toLowerCase();
         if( os.startsWith( "windows" ) || os.equals( "nt" ) ) {
             m_windowsHackNeeded = true;
@@ -182,8 +181,8 @@ public abstract class AbstractFileProvider implements WikiPageProvider {
 
         if( m_windowsHackNeeded ) {
             final String pn = pagename.toLowerCase();
-            for( int i = 0; i < WINDOWS_DEVICE_NAMES.length; i++ ) {
-                if( WINDOWS_DEVICE_NAMES[i].equals(pn) ) {
+            for( final String windowsDeviceName : WINDOWS_DEVICE_NAMES ) {
+                if( windowsDeviceName.equals( pn ) ) {
                     pagename = "$$$" + pagename;
                 }
             }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/providers/CachingProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/providers/CachingProvider.java
index d4088db..a2d18fb 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/providers/CachingProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/providers/CachingProvider.java
@@ -71,7 +71,7 @@ public class CachingProvider implements WikiPageProvider {
     private CacheManager m_cacheManager = CacheManager.getInstance();
 
     private WikiPageProvider m_provider;
-    // FIXME: Find another way to the search engine to use instead of from WikiEngine?
+    // FIXME: Find another way to the search engine to use instead of from Engine?
     private Engine m_engine;
 
     private Cache m_cache;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/providers/VersioningFileProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/providers/VersioningFileProvider.java
index 5faea43..6f72f29 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/providers/VersioningFileProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/providers/VersioningFileProvider.java
@@ -726,11 +726,12 @@ public class VersioningFileProvider extends AbstractFileProvider {
         Properties m_props;
         long m_lastModified;
 
-        /*
+        /**
          * Because a Constructor is inherently synchronised, there is no need to synchronise the arguments.
          *
-         * @param engine WikiEngine instance
+         * @param pageName page name
          * @param props  Properties to use for initialization
+         * @param lastModified last modified date
          */
         public CachedProperties( final String pageName, final Properties props, final long lastModified ) {
             if ( pageName == null ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java
index e01de27..358958b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/references/DefaultReferenceManager.java
@@ -23,17 +23,19 @@ 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.core.Engine;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.providers.WikiPageProvider;
+import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.util.TextUtil;
 
 import java.io.BufferedInputStream;
@@ -75,7 +77,7 @@ import java.util.TreeSet;
    A word about synchronizing:
 
    I expect this object to be accessed in three situations:
-   - when a WikiEngine is created and it scans its wikipages
+   - when a Engine 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.
 
@@ -145,13 +147,13 @@ public class DefaultReferenceManager extends BasicPageFilter implements Referenc
     /**
      *  Builds a new ReferenceManager.
      *
-     *  @param engine The WikiEngine to which this is managing references to.
+     *  @param engine The Engine to which this is managing references to.
      */
-    public DefaultReferenceManager( final WikiEngine engine ) {
+    public DefaultReferenceManager( final Engine engine ) {
         m_refersTo = new HashMap<>();
         m_referredBy = new HashMap<>();
         m_engine = engine;
-        m_matchEnglishPlurals = TextUtil.getBooleanProperty( engine.getWikiProperties(), WikiEngine.PROP_MATCHPLURALS, false );
+        m_matchEnglishPlurals = TextUtil.getBooleanProperty( engine.getWikiProperties(), Engine.PROP_MATCHPLURALS, false );
 
         //
         //  Create two maps that contain unmutable versions of the two basic maps.
@@ -167,7 +169,7 @@ public class DefaultReferenceManager extends BasicPageFilter implements Referenc
         final String content = m_engine.getManager( PageManager.class ).getPageText( page.getName(), WikiPageProvider.LATEST_VERSION );
         final Collection< String > links = scanWikiLinks( page, content );
         final TreeSet< String > res = new TreeSet<>( links );
-        final List< Attachment > attachments = m_engine.getAttachmentManager().listAttachments( page );
+        final List< Attachment > attachments = m_engine.getManager( AttachmentManager.class ).listAttachments( page );
         for( final Attachment att : attachments ) {
             res.add( att.getName() );
         }
@@ -427,15 +429,16 @@ public class DefaultReferenceManager extends BasicPageFilter implements Referenc
      *  @param pagedata The page contents
      *  @return a Collection of Strings
      */
-    @Override public Collection< String > scanWikiLinks( final WikiPage page, final String pagedata ) {
+    @Override
+    public Collection< String > scanWikiLinks( final WikiPage page, final String pagedata ) {
         final LinkCollector localCollector = new LinkCollector();
-        m_engine.getRenderingManager().textToHTML( new WikiContext( m_engine, page ),
-                                                   pagedata,
-                                                   localCollector,
-                                                   null,
-                                                   localCollector,
-                                                   false,
-                                                   true );
+        m_engine.getManager( RenderingManager.class ).textToHTML( new WikiContext( m_engine, page ),
+                                                                  pagedata,
+                                                                  localCollector,
+                                                                  null,
+                                                                  localCollector,
+                                                                  false,
+                                                                  true );
 
         return localCollector.getLinks();
     }
@@ -449,7 +452,8 @@ public class DefaultReferenceManager extends BasicPageFilter implements Referenc
      *
      *  @param page Name of the page to remove from the maps.
      */
-    @Override public synchronized void pageRemoved( final WikiPage page ) {
+    @Override
+    public synchronized void pageRemoved( final WikiPage page ) {
         pageRemoved( page.getName() );
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java b/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
index bf7d9d3..e0e8979 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/DefaultRenderingManager.java
@@ -25,12 +25,14 @@ import org.apache.commons.lang3.time.StopWatch;
 import org.apache.log4j.Logger;
 import org.apache.wiki.StringTransmutator;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.FilterException;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
@@ -40,6 +42,7 @@ import org.apache.wiki.parser.JSPWikiMarkupParser;
 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.util.ClassUtil;
 import org.apache.wiki.util.TextUtil;
 import org.apache.wiki.variables.VariableManager;
@@ -53,7 +56,7 @@ 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.
+ *  instead of the ones in Engine, 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.
@@ -76,7 +79,7 @@ public class DefaultRenderingManager implements RenderingManager {
     /** The name of the default WYSIWYG renderer. */
     private static final String DEFAULT_WYSIWYG_RENDERER = WysiwygEditingRenderer.class.getName();
 
-    private WikiEngine m_engine;
+    private Engine m_engine;
 
     private boolean m_useCache = true;
     private final CacheManager m_cacheManager = CacheManager.getInstance();
@@ -96,7 +99,7 @@ public class DefaultRenderingManager implements RenderingManager {
      *  {@inheritDoc}
      */
     @Override
-    public void initialize( final WikiEngine engine, final Properties properties ) throws WikiException {
+    public void initialize( final Engine 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() ) ) {
@@ -128,7 +131,7 @@ public class DefaultRenderingManager implements RenderingManager {
 
         log.info( "Rendering content with " + renderImplName + "." );
 
-        WikiEventManager.getInstance().addWikiEventListener( m_engine.getFilterManager(),this );
+        WikiEventManager.getInstance().addWikiEventListener( m_engine.getManager( FilterManager.class ),this );
     }
 
     private Constructor< ? > initRenderer( final String renderImplName, final Class< ? >[] rendererParams ) throws WikiException {
@@ -156,7 +159,7 @@ public class DefaultRenderingManager implements RenderingManager {
     public String beautifyTitle( final String title ) {
         if( m_beautifyTitle ) {
             try {
-                final Attachment att = m_engine.getAttachmentManager().getAttachmentInfo( title );
+                final Attachment att = m_engine.getManager( AttachmentManager.class ).getAttachmentInfo( title );
                 if( att == null ) {
                     return TextUtil.beautifyString( title );
                 }
@@ -298,19 +301,19 @@ public class DefaultRenderingManager implements RenderingManager {
     public String textToHTML( final WikiContext context, String pagedata ) {
         String result = "";
 
-        final boolean runFilters = "true".equals( m_engine.getVariableManager().getValue( context,VariableManager.VAR_RUNFILTERS,"true" ) );
+        final boolean runFilters = "true".equals( m_engine.getManager( VariableManager.class ).getValue( context,VariableManager.VAR_RUNFILTERS,"true" ) );
 
         final StopWatch sw = new StopWatch();
         sw.start();
         try {
             if( runFilters ) {
-                pagedata = m_engine.getFilterManager().doPreTranslateFiltering( context, pagedata );
+                pagedata = m_engine.getManager( FilterManager.class ).doPreTranslateFiltering( context, pagedata );
             }
 
             result = getHTML( context, pagedata );
 
             if( runFilters ) {
-                result = m_engine.getFilterManager().doPostTranslateFiltering( context, result );
+                result = m_engine.getManager( FilterManager.class ).doPostTranslateFiltering( context, result );
             }
         } catch( final FilterException e ) {
             log.error( "page filter threw exception: ", e );
@@ -342,14 +345,14 @@ public class DefaultRenderingManager implements RenderingManager {
             return null;
         }
 
-        final boolean runFilters = "true".equals( m_engine.getVariableManager().getValue( context, VariableManager.VAR_RUNFILTERS,"true" ) );
+        final boolean runFilters = "true".equals( m_engine.getManager( VariableManager.class ).getValue( context, VariableManager.VAR_RUNFILTERS,"true" ) );
 
         try {
             final StopWatch sw = new StopWatch();
             sw.start();
 
-            if( runFilters && m_engine.getFilterManager() != null ) {
-                pagedata = m_engine.getFilterManager().doPreTranslateFiltering( context, pagedata );
+            if( runFilters && m_engine.getManager( FilterManager.class ) != null ) {
+                pagedata = m_engine.getManager( FilterManager.class ).doPreTranslateFiltering( context, pagedata );
             }
 
             final MarkupParser mp = getParser( context, pagedata );
@@ -367,8 +370,8 @@ public class DefaultRenderingManager implements RenderingManager {
             if( !justParse ) {
                 result = getHTML( context, doc );
 
-                if( runFilters && m_engine.getFilterManager() != null ) {
-                    result = m_engine.getFilterManager().doPostTranslateFiltering( context, result );
+                if( runFilters && m_engine.getManager( FilterManager.class ) != null ) {
+                    result = m_engine.getManager( FilterManager.class ).doPostTranslateFiltering( context, result );
                 }
             }
 
@@ -430,7 +433,7 @@ public class DefaultRenderingManager implements RenderingManager {
                 if( m_documentCache != null ) {
                     final String pageName = ( ( WikiPageEvent ) event ).getPageName();
                     m_documentCache.remove( pageName );
-                    final Collection< String > referringPages = m_engine.getReferenceManager().findReferrers( pageName );
+                    final Collection< String > referringPages = m_engine.getManager( ReferenceManager.class ).findReferrers( pageName );
 
                     //
                     //  Flush also those pages that refer to this page (if an nonexistent page
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 fabfaaa..a459c16 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
@@ -21,8 +21,8 @@ package org.apache.wiki.render;
 import org.apache.log4j.Logger;
 import org.apache.wiki.StringTransmutator;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.modules.InternalModule;
@@ -70,7 +70,7 @@ public interface RenderingManager extends WikiEventListener, InternalModule {
      *  @param properties A list of properties to get parameters from.
      *  @throws WikiException If the manager could not be initialized.
      */
-    void initialize( WikiEngine engine, Properties properties ) throws WikiException;
+    void initialize( Engine engine, Properties properties ) throws WikiException;
 
     /**
      *  Beautifies the title of the page by appending spaces in suitable places, if the user has so decreed in the properties when


[jspwiki] 12/20: small refactor move parsePageFromURL( HttpServletRequest, Charset ) from DefaultURLConstructor to URLConstructor

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 c6a58f79353b1d6dd689e0070b3326f20902ebe4
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 19:35:37 2020 +0100

    small refactor move parsePageFromURL( HttpServletRequest, Charset ) from DefaultURLConstructor to URLConstructor
---
 .../src/main/java/org/apache/wiki/WikiServlet.java |  3 +-
 .../java/org/apache/wiki/ui/WikiJSPFilter.java     |  8 ++--
 .../org/apache/wiki/url/DefaultURLConstructor.java | 43 +++++-----------------
 .../org/apache/wiki/url/ShortURLConstructor.java   |  2 +-
 .../java/org/apache/wiki/url/URLConstructor.java   | 22 +++++++++++
 5 files changed, 37 insertions(+), 41 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
index a2dcdaa..d401dd4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
@@ -21,7 +21,6 @@ package org.apache.wiki;
 import net.sf.ehcache.CacheManager;
 import org.apache.log4j.Logger;
 import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.url.DefaultURLConstructor;
 import org.apache.wiki.url.URLConstructor;
 
 import javax.servlet.RequestDispatcher;
@@ -83,7 +82,7 @@ public class WikiServlet extends HttpServlet {
      */
     @Override
     public void doGet( final HttpServletRequest req, final HttpServletResponse res ) throws IOException, ServletException {
-        String pageName = DefaultURLConstructor.parsePageFromURL( req, m_engine.getContentEncoding() );
+        String pageName = URLConstructor.parsePageFromURL( req, m_engine.getContentEncoding() );
 
         log.info( "Request for page: " + pageName );
         if( pageName == null ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
index 3924000..a3f9139 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
@@ -26,7 +26,7 @@ import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
-import org.apache.wiki.url.DefaultURLConstructor;
+import org.apache.wiki.url.URLConstructor;
 import org.apache.wiki.util.TextUtil;
 
 import javax.servlet.FilterChain;
@@ -94,15 +94,13 @@ public class WikiJSPFilter extends WikiServletFilter {
             final HttpServletResponseWrapper responseWrapper = new JSPWikiServletResponseWrapper( ( HttpServletResponse )response, m_wiki_encoding, useEncoding );
 
             // fire PAGE_REQUESTED event
-            final String pagename = DefaultURLConstructor.parsePageFromURL( ( HttpServletRequest )request,
-                                                                            Charset.forName( response.getCharacterEncoding() ) );
+            final String pagename = URLConstructor.parsePageFromURL( ( HttpServletRequest )request, Charset.forName( response.getCharacterEncoding() ) );
             fireEvent( WikiPageEvent.PAGE_REQUESTED, pagename );
             super.doFilter( request, responseWrapper, chain );
 
             // The response is now complete. Lets replace the markers now.
 
-            // WikiContext is only available after doFilter! (That is after
-            //   interpreting the jsp)
+            // WikiContext is only available after doFilter! (That is after interpreting the jsp)
 
             try {
                 w.enterState( "Delivering response", 30 );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java
index f127c06..370b6c4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java
@@ -40,16 +40,15 @@ public class DefaultURLConstructor implements URLConstructor {
 
     protected Engine m_engine;
 
-    /**
-     *  Contains the absolute path of the JSPWiki Web application without the actual servlet (which is the m_urlPrefix).
-     */
+    /** Contains the absolute path of the JSPWiki Web application without the actual servlet (which is the m_urlPrefix). */
     protected String m_pathPrefix = "";
 
     /**
      *
      * {@inheritDoc}
      */
-    @Override public void initialize( final Engine engine, final Properties properties ) {
+    @Override
+    public void initialize( final Engine engine, final Properties properties ) {
         m_engine = engine;
         m_pathPrefix = engine.getBaseURL() + "/";
     }
@@ -125,7 +124,8 @@ public class DefaultURLConstructor implements URLConstructor {
      *
      *  {@inheritDoc}
      */
-    @Override public String makeURL( final String context, final String name, String parameters ) {
+    @Override
+    public String makeURL( final String context, final String name, String parameters ) {
         if( parameters != null && parameters.length() > 0 ) {
             if( context.equals( WikiContext.ATTACH ) ) {
                 parameters = "?" + parameters;
@@ -145,47 +145,24 @@ public class DefaultURLConstructor implements URLConstructor {
      *
      *  {@inheritDoc}
      */
-    @Override public String parsePage( final String context, final HttpServletRequest request, final Charset encoding ) {
+    @Override
+    public String parsePage( final String context, final HttpServletRequest request, final Charset encoding ) {
         String pagereq = request.getParameter( "page" );
         if( context.equals(WikiContext.ATTACH) ) {
-            pagereq = parsePageFromURL( request, encoding );
+            pagereq = URLConstructor.parsePageFromURL( request, encoding );
         }
 
         return pagereq;
     }
 
     /**
-     *  Takes the name of the page from the request URI. The initial slash is also removed.  If there is no page, returns null.
-     *
-     *  @param request The request to parse
-     *  @param encoding The encoding to use
-     *
-     *  @return a parsed page name, or null, if it cannot be found
-     */
-    public static String parsePageFromURL( final HttpServletRequest request, final Charset encoding ) {
-        final String name = request.getPathInfo();
-        if( name == null || name.length() <= 1 ) {
-            return null;
-        } else if( name.charAt(0) == '/' ) {
-            return name.substring(1);
-        }
-
-        //
-        //  This is required, because by default all URLs are handled as Latin1, even if they are really UTF-8.
-        //
-        // name = TextUtil.urlDecode( name, encoding );
-
-        return name;
-    }
-
-
-    /**
      *  This method is not needed for the DefaultURLConstructor.
      *
      * @param request The HTTP Request that was used to end up in this page.
      * @return "Wiki.jsp", "PageInfo.jsp", etc.  Just return the name, JSPWiki will figure out the page.
      */
-    @Override public String getForwardPage( final HttpServletRequest request ) {
+    @Override
+    public String getForwardPage( final HttpServletRequest request ) {
         return "Wiki.jsp";
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
index 69530db..b94a7bf 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
@@ -144,7 +144,7 @@ public class ShortURLConstructor extends DefaultURLConstructor {
     public String parsePage( final String context, final HttpServletRequest request, final Charset encoding ) {
         final String pagereq = request.getParameter( "page" );
         if( pagereq == null ) {
-            return parsePageFromURL( request, encoding );
+            return URLConstructor.parsePageFromURL( request, encoding );
         }
 
         return pagereq;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
index a0ac40f..862e275 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
@@ -77,4 +77,26 @@ public interface URLConstructor {
      */
     String getForwardPage( HttpServletRequest request );
 
+    /**
+     *  Takes the name of the page from the request URI. The initial slash is also removed.  If there is no page, returns null.
+     *
+     *  @param request The request to parse
+     *  @param encoding The encoding to use
+     *
+     *  @return a parsed page name, or null, if it cannot be found
+     */
+    static String parsePageFromURL( final HttpServletRequest request, final Charset encoding ) {
+        final String name = request.getPathInfo();
+        if( name == null || name.length() <= 1 ) {
+            return null;
+        } else if( name.charAt(0) == '/' ) {
+            return name.substring(1);
+        }
+
+        //  This is required, because by default all URLs are handled as Latin1, even if they are really UTF-8.
+        // name = TextUtil.urlDecode( name, encoding );
+
+        return name;
+    }
+
 }


[jspwiki] 13/20: move static UserProfile newProfile( UserDatabase db ) from DefaultUserProfile into AbstractUserDatabase to break a cycle between those two classes

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 a35b48eaed05996b7031283f711ef43ad275ea34
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 19:48:33 2020 +0100

    move static UserProfile newProfile( UserDatabase db ) from DefaultUserProfile into AbstractUserDatabase to break a cycle between those two classes
---
 .../wiki/auth/user/AbstractUserDatabase.java       |  79 ++++-----
 .../apache/wiki/auth/user/DefaultUserProfile.java  | 176 +++++++++------------
 .../org/apache/wiki/auth/user/UserDatabase.java    |   1 +
 3 files changed, 117 insertions(+), 139 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/AbstractUserDatabase.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/AbstractUserDatabase.java
index 78b030d..e4d79da 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/AbstractUserDatabase.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/AbstractUserDatabase.java
@@ -48,15 +48,15 @@ public abstract class AbstractUserDatabase implements UserDatabase {
     protected static final String SSHA_PREFIX = "{SSHA}";
 
     /**
-     * Looks up and returns the first {@link UserProfile}in the user database
-     * that whose login name, full name, or wiki name matches the supplied
-     * string. This method provides a "forgiving" search algorithm for resolving
-     * principal names when the exact profile attribute that supplied the name
-     * is unknown.
+     * Looks up and returns the first {@link UserProfile} in the user database that whose login name, full name, or wiki name matches the
+     * supplied string. This method provides a "forgiving" search algorithm for resolving principal names when the exact profile attribute
+     * that supplied the name is unknown.
+     *
      * @param index the login name, full name, or wiki name
      * @see org.apache.wiki.auth.user.UserDatabase#find(java.lang.String)
      */
-    @Override public UserProfile find( final String index ) throws NoSuchPrincipalException {
+    @Override
+    public UserProfile find( final String index ) throws NoSuchPrincipalException {
         UserProfile profile = null;
 
         // Try finding by full name
@@ -93,25 +93,29 @@ public abstract class AbstractUserDatabase implements UserDatabase {
      * {@inheritDoc}
      * @see org.apache.wiki.auth.user.UserDatabase#findByEmail(java.lang.String)
      */
-    @Override public abstract UserProfile findByEmail( String index ) throws NoSuchPrincipalException;
+    @Override
+    public abstract UserProfile findByEmail( String index ) throws NoSuchPrincipalException;
 
     /**
      * {@inheritDoc}
      * @see org.apache.wiki.auth.user.UserDatabase#findByFullName(java.lang.String)
      */
-    @Override public abstract UserProfile findByFullName( String index ) throws NoSuchPrincipalException;
+    @Override
+    public abstract UserProfile findByFullName( String index ) throws NoSuchPrincipalException;
 
     /**
      * {@inheritDoc}
      * @see org.apache.wiki.auth.user.UserDatabase#findByLoginName(java.lang.String)
      */
-    @Override public abstract UserProfile findByLoginName( String index ) throws NoSuchPrincipalException;
+    @Override
+    public abstract UserProfile findByLoginName( String index ) throws NoSuchPrincipalException;
 
     /**
      * {@inheritDoc}
      * @see org.apache.wiki.auth.user.UserDatabase#findByWikiName(java.lang.String)
      */
-    @Override public abstract UserProfile findByWikiName( String index ) throws NoSuchPrincipalException;
+    @Override
+    public abstract UserProfile findByWikiName( String index ) throws NoSuchPrincipalException;
 
     /**
      * <p>Looks up the Principals representing a user from the user database. These
@@ -126,50 +130,50 @@ public abstract class AbstractUserDatabase implements UserDatabase {
      *            {@link UserProfile#getLoginName()}method.
      * @return the array of Principals representing the user
      * @see org.apache.wiki.auth.user.UserDatabase#getPrincipals(java.lang.String)
-     * @throws NoSuchPrincipalException {@inheritDoc}
+     * @throws NoSuchPrincipalException If the user database does not contain user with the supplied identifier
      */
-    @Override public Principal[] getPrincipals( final String identifier ) throws NoSuchPrincipalException
-    {
-        try {
-            final UserProfile profile = findByLoginName( identifier );
-            final ArrayList< Principal > principals = new ArrayList<>();
-            if( profile.getLoginName() != null && profile.getLoginName().length() > 0 ) {
-                principals.add( new WikiPrincipal( profile.getLoginName(), WikiPrincipal.LOGIN_NAME ) );
-            }
-            if( profile.getFullname() != null && profile.getFullname().length() > 0 ) {
-                principals.add( new WikiPrincipal( profile.getFullname(), WikiPrincipal.FULL_NAME ) );
-            }
-            if( profile.getWikiName() != null && profile.getWikiName().length() > 0 ) {
-                principals.add( new WikiPrincipal( profile.getWikiName(), WikiPrincipal.WIKI_NAME ) );
-            }
-            return principals.toArray( new Principal[ principals.size() ] );
-        } catch( final NoSuchPrincipalException e ) {
-            throw e;
+    @Override
+    public Principal[] getPrincipals( final String identifier ) throws NoSuchPrincipalException {
+        final UserProfile profile = findByLoginName( identifier );
+        final ArrayList< Principal > principals = new ArrayList<>();
+        if( profile.getLoginName() != null && profile.getLoginName().length() > 0 ) {
+            principals.add( new WikiPrincipal( profile.getLoginName(), WikiPrincipal.LOGIN_NAME ) );
+        }
+        if( profile.getFullname() != null && profile.getFullname().length() > 0 ) {
+            principals.add( new WikiPrincipal( profile.getFullname(), WikiPrincipal.FULL_NAME ) );
         }
+        if( profile.getWikiName() != null && profile.getWikiName().length() > 0 ) {
+            principals.add( new WikiPrincipal( profile.getWikiName(), WikiPrincipal.WIKI_NAME ) );
+        }
+        return principals.toArray( new Principal[ principals.size() ] );
     }
 
     /**
      * {@inheritDoc}
+     *
      * @see org.apache.wiki.auth.user.UserDatabase#initialize(org.apache.wiki.api.core.Engine, java.util.Properties)
      */
-    @Override public abstract void initialize( Engine engine, Properties props ) throws NoRequiredPropertyException, WikiSecurityException;
+    @Override
+    public abstract void initialize( Engine engine, Properties props ) throws NoRequiredPropertyException, WikiSecurityException;
 
     /**
-     * Factory method that instantiates a new DefaultUserProfile with a new, distinct
-     * unique identifier.
+     * Factory method that instantiates a new DefaultUserProfile with a new, distinct unique identifier.
      * 
      * @return A new, empty profile.
      */
-    @Override public UserProfile newProfile()
-    {
-        return DefaultUserProfile.newProfile( this );
+    @Override
+    public UserProfile newProfile() {
+        final UserProfile profile = new DefaultUserProfile();
+        profile.setUid( AbstractUserDatabase.generateUid( this ) );
+        return profile;
     }
 
     /**
      * {@inheritDoc}
      * @see org.apache.wiki.auth.user.UserDatabase#save(org.apache.wiki.auth.user.UserProfile)
      */
-    @Override public abstract void save( UserProfile profile ) throws WikiSecurityException;
+    @Override
+    public abstract void save( UserProfile profile ) throws WikiSecurityException;
 
     /**
      * Validates the password for a given user. If the user does not exist in the user database, this method always returns
@@ -181,7 +185,8 @@ public abstract class AbstractUserDatabase implements UserDatabase {
      * @return <code>true</code> if the supplied user password matches the stored password
      * @see org.apache.wiki.auth.user.UserDatabase#validatePassword(java.lang.String, java.lang.String)
      */
-    @Override public boolean validatePassword( final String loginName, final String password ) {
+    @Override
+    public boolean validatePassword( final String loginName, final String password ) {
         final String hashedPassword;
         try {
             final UserProfile profile = findByLoginName( loginName );
@@ -286,7 +291,7 @@ public abstract class AbstractUserDatabase implements UserDatabase {
      */
     protected long parseLong( final String value ) {
         if( NumberUtils.isParsable( value ) ) {
-            return Long.valueOf( value );
+            return Long.parseLong( value );
         } else {
             return 0L;
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java
index ae2df73..416cca4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java
@@ -27,88 +27,63 @@ import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 
+
 /**
- * Default implementation for representing wiki user information, such as the
- * login name, full name, wiki name, and e-mail address.
+ * Default implementation for representing wiki user information, such as the login name, full name, wiki name, and e-mail address.
+ *
  * @since 2.3
  */
+public final class DefaultUserProfile implements UserProfile {
 
-public final class DefaultUserProfile implements UserProfile
-{
     private static final long serialVersionUID = -5600466893735300647L;
-
     private static final String EMPTY_STRING = "";
-
     private static final String WHITESPACE = "\\s";
-    
-    private Map<String,Serializable> attributes = new HashMap<>();
 
-    private Date     created   = null;
-
-    private String   email     = null;
-
-    private String   fullname  = null;
-    
+    private Map< String, Serializable > attributes = new HashMap<>();
+    private Date created = null;
+    private String email = null;
+    private String fullname = null;
     private Date lockExpiry = null;
-
-    private String   loginName = null;
-
-    private Date     modified  = null;
-
-    private String   password  = null;
-    
+    private String loginName = null;
+    private Date modified = null;
+    private String password = null;
     private String uid = null;
-
-    private String   wikiname  = null;
+    private String wikiname = null;
 
     /**
-     * Private constructor to prevent direct instantiation.
+     * Package constructor to allow direct instantiation only from package related classes (i.e., AbstractUserDatabase).
      */
-    private DefaultUserProfile() {}
-
-    /**
-     * Static factory method that creates a new DefaultUserProfile
-     * and sets a unique identifier (uid) for the supplied UserDatabase.
-     * @param db the UserDatabase for which the uid should be
-     * created
-     * @return the new profile
-     */
-    protected static UserProfile newProfile( UserDatabase db )
-    {
-        UserProfile profile = new DefaultUserProfile();
-        profile.setUid( AbstractUserDatabase.generateUid( db ) );
-        return profile;
-    }
+    DefaultUserProfile() {}
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public boolean equals( Object o )
-    {
-        if ( ( o != null ) && ( o instanceof UserProfile ) )
-        {
-            DefaultUserProfile u = (DefaultUserProfile) o;
-            return  same( fullname, u.fullname ) && same( password, u.password )
-                    && same( loginName, u.loginName ) && same(StringUtils.lowerCase( email ), StringUtils.lowerCase( u.email ) ) && same( wikiname,
-                    u.wikiname );
+    public boolean equals( final Object o ) {
+        if ( o instanceof UserProfile ) {
+            final DefaultUserProfile u = ( DefaultUserProfile )o;
+            return  same( fullname, u.fullname ) &&
+                    same( password, u.password ) &&
+                    same( loginName, u.loginName ) &&
+                    same( StringUtils.lowerCase( email ), StringUtils.lowerCase( u.email ) ) &&
+                    same( wikiname, u.wikiname );
         }
 
         return false;
     }
 
     @Override
-    public int hashCode()
-    {
-        return (fullname  != null ? fullname.hashCode()  : 0) ^
-               (password  != null ? password.hashCode()  : 0) ^
-               (loginName != null ? loginName.hashCode() : 0) ^
-               (wikiname  != null ? wikiname.hashCode()  : 0) ^
-               (email     != null ? StringUtils.lowerCase( email ).hashCode()     : 0);
+    public int hashCode() {
+        return ( fullname  != null ? fullname.hashCode()  : 0 ) ^
+               ( password  != null ? password.hashCode()  : 0 ) ^
+               ( loginName != null ? loginName.hashCode() : 0 ) ^
+               ( wikiname  != null ? wikiname.hashCode()  : 0 ) ^
+               ( email     != null ? StringUtils.lowerCase( email ).hashCode() : 0 );
     }
 
     /**
      * Returns the creation date
+     *
      * @return the creation date
      * @see org.apache.wiki.auth.user.UserProfile#getCreated()
      */
@@ -120,6 +95,7 @@ public final class DefaultUserProfile implements UserProfile
 
     /**
      * Returns the user's e-mail address.
+     *
      * @return the e-mail address
      */
     @Override
@@ -130,6 +106,7 @@ public final class DefaultUserProfile implements UserProfile
 
     /**
      * Returns the user's full name.
+     *
      * @return the full name
      */
     @Override
@@ -140,6 +117,7 @@ public final class DefaultUserProfile implements UserProfile
 
     /**
      * Returns the last-modified date.
+     *
      * @return the last-modified date
      * @see org.apache.wiki.auth.user.UserProfile#getLastModified()
      */
@@ -160,12 +138,10 @@ public final class DefaultUserProfile implements UserProfile
     }
 
     /**
-     * Returns the user password for use with custom authentication. Note that
-     * the password field is not meaningful for container authentication; the
-     * user's private credentials are generally stored elsewhere. While it
-     * depends on the {@link UserDatabase}implementation, in most cases the
-     * value returned by this method will be a password hash, not the password
-     * itself.
+     * Returns the user password for use with custom authentication. Note that the password field is not meaningful for container
+     * authentication; the user's private credentials are generally stored elsewhere. While it depends on the {@link UserDatabase}
+     * implementation, in most cases the value returned by this method will be a password hash, not the password itself.
+     *
      * @return the password
      */
     @Override
@@ -176,6 +152,7 @@ public final class DefaultUserProfile implements UserProfile
 
     /**
      * Returns the user's wiki name.
+     *
      * @return the wiki name.
      */
     @Override
@@ -185,10 +162,9 @@ public final class DefaultUserProfile implements UserProfile
     }
 
     /**
-     * Returns <code>true</code> if the user profile is
-     * new. This implementation checks whether
-     * {@link #getLastModified()} returns <code>null</code>
-     * to determine the status.
+     * Returns <code>true</code> if the user profile is new. This implementation checks whether {@link #getLastModified()} returns
+     * <code>null</code> to determine the status.
+     *
      * @see org.apache.wiki.auth.user.UserProfile#isNew()
      */
     @Override
@@ -202,80 +178,80 @@ public final class DefaultUserProfile implements UserProfile
      * @see org.apache.wiki.auth.user.UserProfile#setCreated(java.util.Date)
      */
     @Override
-    public void setCreated(Date date)
+    public void setCreated( final Date date )
     {
         created = date;
     }
 
     /**
      * Sets the user's e-mail address.
+     *
      * @param email the e-mail address
      */
     @Override
-    public void setEmail( String email )
+    public void setEmail( final String email )
     {
     	this.email = email;
     }
 
     /**
      * Sets the user's full name. For example, "Janne Jalkanen."
+     *
      * @param arg the full name
      */
     @Override
-    public void setFullname( String arg )
-    {
+    public void setFullname( final String arg ) {
         fullname = arg;
 
         // Compute wiki name
-        if ( fullname != null )
-        {
-            wikiname = fullname.replaceAll(WHITESPACE, EMPTY_STRING);
+        if ( fullname != null ) {
+            wikiname = fullname.replaceAll( WHITESPACE, EMPTY_STRING );
         }
     }
 
     /**
      * Sets the last-modified date.
+     *
      * @param date the last-modified date
      * @see org.apache.wiki.auth.user.UserProfile#setLastModified(java.util.Date)
      */
     @Override
-    public void setLastModified( Date date )
+    public void setLastModified( final Date date )
     {
         modified = date;
     }
 
     /**
-     * Sets the name by which the user logs in. The login name is used as the
-     * username for custom authentication (see
+     * Sets the name by which the user logs in. The login name is used as the username for custom authentication (see
      * {@link org.apache.wiki.auth.AuthenticationManager#login(WikiSession,HttpServletRequest, String, String)}).
-     * The login name is typically a short name ("jannej"). In contrast, the
-     * wiki name is typically of type FirstnameLastName ("JanneJalkanen").
+     * The login name is typically a short name ("jannej"). In contrast, the wiki name is typically of type
+     * FirstnameLastName ("JanneJalkanen").
+     *
      * @param name the login name
      */
     @Override
-    public void setLoginName( String name )
+    public void setLoginName( final String name )
     {
         loginName = name;
     }
 
     /**
-     * Sets the user's password for use with custom authentication. It is
-     * <em>not</em> the responsibility of implementing classes to hash the
-     * password; that responsibility is borne by the UserDatabase implementation
-     * during save operations (see {@link UserDatabase#save(UserProfile)}).
-     * Note that the password field is not meaningful for container
-     * authentication; the user's private credentials are generally stored
-     * elsewhere.
+     * Sets the user's password for use with custom authentication. It is <em>not</em> the responsibility of implementing classes to hash
+     * the password; that responsibility is borne by the UserDatabase implementation during save operations (see
+     * {@link UserDatabase#save(UserProfile)}). Note that the password field is not meaningful for container authentication; the user's
+     * private credentials are generally stored elsewhere.
+     *
      * @param arg the password
      */
     @Override
-    public void setPassword( String arg )
+    public void setPassword( final String arg )
     {
         password = arg;
     }
 
     /**
      * Returns a string representation of this user profile.
+     *
      * @return the string
      */
     @Override
@@ -285,20 +261,17 @@ public final class DefaultUserProfile implements UserProfile
     }
 
     /**
-     * Private method that compares two objects and determines whether they are
-     * equal. Two nulls are considered equal.
+     * Private method that compares two objects and determines whether they are equal. Two nulls are considered equal.
+     *
      * @param arg1 the first object
      * @param arg2 the second object
      * @return the result of the comparison
      */
-    private boolean same( Object arg1, Object arg2 )
-    {
-        if ( arg1 == null && arg2 == null )
-        {
+    private boolean same( final Object arg1, final Object arg2 ) {
+        if( arg1 == null && arg2 == null ) {
             return true;
         }
-        if ( arg1 == null || arg2 == null )
-        {
+        if( arg1 == null || arg2 == null ) {
             return false;
         }
         return arg1.equals( arg2 );
@@ -310,7 +283,7 @@ public final class DefaultUserProfile implements UserProfile
      * {@inheritDoc}
      */
     @Override
-    public Map<String,Serializable> getAttributes()
+    public Map< String, Serializable > getAttributes()
     {
         return attributes;
     }
@@ -337,23 +310,21 @@ public final class DefaultUserProfile implements UserProfile
      * {@inheritDoc}
      */
     @Override
-    public boolean isLocked()
-    {
-        boolean locked =  lockExpiry != null && System.currentTimeMillis() < lockExpiry.getTime();
-
+    public boolean isLocked() {
+        final boolean locked = lockExpiry != null && System.currentTimeMillis() < lockExpiry.getTime();
         // Clear the lock if it's expired already
-        if ( !locked && lockExpiry != null )
-        {
+        if( !locked && lockExpiry != null ) {
             lockExpiry = null;
         }
         return locked;
+
     }
 
     /**
      * {@inheritDoc}
      */
     @Override
-    public void setLockExpiry( Date expiry )
+    public void setLockExpiry( final Date expiry )
     {
     	this.lockExpiry = expiry;
     }
@@ -362,8 +333,9 @@ public final class DefaultUserProfile implements UserProfile
      * {@inheritDoc}
      */
     @Override
-    public void setUid( String uid )
+    public void setUid( final String uid )
     {
         this.uid = uid;
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserDatabase.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserDatabase.java
index c8928cc..906c54b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserDatabase.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserDatabase.java
@@ -59,6 +59,7 @@ public interface UserDatabase {
      *
      * @param identifier the name of the user to retrieve; this corresponds to value returned by the user profile's {@link UserProfile#getLoginName()} method.
      * @return the array of Principals representing the user's identities
+     * @throws NoSuchPrincipalException If the user database does not contain user with the supplied identifier
      */
     Principal[] getPrincipals( String identifier ) throws NoSuchPrincipalException;
 


[jspwiki] 06/20: JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (1)

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 d127551e953d368d2ad23cf2c669246130456d4b
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 19:07:09 2020 +0100

    JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (1)
---
 .../src/main/java/org/apache/wiki/WatchDog.java         |  4 ++--
 .../main/java/org/apache/wiki/WikiBackgroundThread.java | 13 ++++++-------
 .../src/main/java/org/apache/wiki/WikiPage.java         |  2 +-
 .../src/main/java/org/apache/wiki/WikiProvider.java     |  2 +-
 .../src/main/java/org/apache/wiki/WikiServlet.java      | 17 ++++++++---------
 .../java/org/apache/wiki/api/filters/PageFilter.java    |  2 +-
 .../org/apache/wiki/api/plugin/InitializablePlugin.java |  2 +-
 .../org/apache/wiki/attachment/AttachmentServlet.java   |  2 +-
 .../org/apache/wiki/auth/AuthenticationManager.java     | 16 ++++++++--------
 .../apache/wiki/auth/DefaultAuthenticationManager.java  |  2 +-
 .../auth/login/CookieAuthenticationLoginModule.java     |  3 ++-
 .../org/apache/wiki/diff/DefaultDifferenceManager.java  |  2 +-
 .../org/apache/wiki/filters/DefaultFilterManager.java   |  5 +++--
 13 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WatchDog.java b/jspwiki-main/src/main/java/org/apache/wiki/WatchDog.java
index ad261bd..07b6ac1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WatchDog.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WatchDog.java
@@ -60,7 +60,7 @@ public final class WatchDog {
      *  Returns the current watchdog for the current thread. This is the preferred method of getting you a Watchdog, since it
      *  keeps an internal list of Watchdogs for you so that there won't be more than one watchdog per thread.
      *
-     *  @param engine The WikiEngine to which the Watchdog should be bonded to.
+     *  @param engine The Engine to which the Watchdog should be bonded to.
      *  @return A usable WatchDog object.
      */
     public static WatchDog getCurrentWatchDog( final Engine engine ) {
@@ -102,7 +102,7 @@ public final class WatchDog {
     /**
      *  Creates a new WatchDog for a Thread.  The Thread is wrapped in a Watchable wrapper for this purpose.
      *
-     *  @param engine The WikiEngine
+     *  @param engine The Engine
      *  @param thread A Thread for watching.
      */
     public WatchDog( final Engine engine, final Thread thread ) {
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 8bda0fa..b878173 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiBackgroundThread.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiBackgroundThread.java
@@ -28,8 +28,7 @@ import org.apache.wiki.event.WikiEventListener;
 /**
  * Abstract Thread subclass that operates in the background; when it detects the {@link WikiEngineEvent#SHUTDOWN} event,
  * it terminates itself. Subclasses of this method need only implement the method {@link #backgroundTask()}, instead of
- * the normal {@link Thread#run()}, and provide a constructor that passes the WikiEngine and sleep interval. This 
- * class is thread-safe.
+ * the normal {@link Thread#run()}, and provide a constructor that passes the Engine and sleep interval. This class is thread-safe.
  */
 public abstract class WikiBackgroundThread extends Thread implements WikiEventListener {
 	
@@ -78,7 +77,7 @@ public abstract class WikiBackgroundThread extends Thread implements WikiEventLi
     public abstract void backgroundTask() throws Exception;
     
     /**
-     * Returns the WikiEngine that created this background thread.
+     * Returns the Engine that created this background thread.
      * 
      * @return the wiki engine
      */
@@ -104,7 +103,8 @@ public abstract class WikiBackgroundThread extends Thread implements WikiEventLi
      * 
      * @see java.lang.Thread#run()
      */
-    @Override public final void run() {
+    @Override
+    public final void run() {
         try {
             // Perform the initial startup task
             final String name = getName();
@@ -154,9 +154,8 @@ public abstract class WikiBackgroundThread extends Thread implements WikiEventLi
     }
     
     /**
-     * Executes a task just after the thread's {@link Thread#run()} method starts, but before the 
-     * {@link #backgroundTask()} task executes. By default, this method does nothing; override it to implement 
-     * custom functionality.
+     * Executes a task just after the thread's {@link Thread#run()} method starts, but before the {@link #backgroundTask()} task executes.
+     * By default, this method does nothing; override it to implement custom functionality.
      * 
      * @throws Exception Any exception can be thrown.
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
index b69b240..9dbc46b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
@@ -74,7 +74,7 @@ public class WikiPage implements Cloneable, Comparable< WikiPage > {
     /**
      *  Create a new WikiPage using a given engine and name.
      *  
-     *  @param engine The WikiEngine that owns this page.
+     *  @param engine The Engine that owns this page.
      *  @param name   The name of the page.
      */
     public WikiPage( final Engine engine, final String name ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java
index c401dae..a001f7f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiProvider.java
@@ -38,7 +38,7 @@ public interface WikiProvider {
     /**
      *  Initializes the page provider.
      *
-     *  @param engine WikiEngine to own this provider
+     *  @param engine Engine to own this provider
      *  @param properties A set of properties used to initialize this provider
      *  @throws NoRequiredPropertyException If the provider needs a property which is not found in the property set
      *  @throws IOException If there is an IO problem
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
index 45c5f2f..a2dcdaa 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiServlet.java
@@ -20,7 +20,9 @@ package org.apache.wiki;
 
 import net.sf.ehcache.CacheManager;
 import org.apache.log4j.Logger;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.url.DefaultURLConstructor;
+import org.apache.wiki.url.URLConstructor;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletConfig;
@@ -32,16 +34,15 @@ import java.io.IOException;
 
 
 /**
- * This provides a master servlet for dealing with short urls.  It mostly does
- * redirects to the proper JSP pages. It also intercepts the servlet
- * shutdown events and uses it to signal wiki shutdown.
+ * This provides a master servlet for dealing with short urls.  It mostly does redirects to the proper JSP pages. It also intercepts the
+ * servlet shutdown events and uses it to signal wiki shutdown.
  *
  * @since 2.2
  */
 public class WikiServlet extends HttpServlet {
 
     private static final long serialVersionUID = 3258410651167633973L;
-    private WikiEngine m_engine;
+    private Engine m_engine;
     private static final Logger log = Logger.getLogger( WikiServlet.class.getName() );
 
     /**
@@ -55,10 +56,8 @@ public class WikiServlet extends HttpServlet {
     }
 
     /**
-     * Destroys the WikiServlet; called by the servlet container
-     * when shutting down the webapp. This method calls the
-     * protected method {@link WikiEngine#shutdown()}, which
-     * sends {@link org.apache.wiki.event.WikiEngineEvent#SHUTDOWN}
+     * Destroys the WikiServlet; called by the servlet container when shutting down the webapp. This method calls the
+     * protected method {@link WikiEngine#shutdown()}, which sends {@link org.apache.wiki.event.WikiEngineEvent#SHUTDOWN}
      * events to registered listeners.
      *
      * @see javax.servlet.GenericServlet#destroy()
@@ -91,7 +90,7 @@ public class WikiServlet extends HttpServlet {
             pageName = m_engine.getFrontPage(); // FIXME: Add special pages as well
         }
 
-        final String jspPage = m_engine.getURLConstructor().getForwardPage( req );
+        final String jspPage = m_engine.getManager( URLConstructor.class ).getForwardPage( req );
         final RequestDispatcher dispatcher = req.getRequestDispatcher( "/" + jspPage + "?page=" +
                                                                        m_engine.encodeName( pageName ) + "&" + req.getQueryString() );
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java
index 26d9008..36c906d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/filters/PageFilter.java
@@ -43,7 +43,7 @@ public interface PageFilter {
     /**
      *  Is called whenever the a new PageFilter is instantiated and reset.
      *  
-     *  @param engine The WikiEngine whic owns this PageFilter
+     *  @param engine The Engine which owns this PageFilter
      *  @param properties The properties ripped from filters.xml.
      *  @throws FilterException If the filter could not be initialized. If this is thrown, the filter is not added to the internal queues.
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java
index 1f4d33e..bb7a68a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/api/plugin/InitializablePlugin.java
@@ -33,7 +33,7 @@ public interface InitializablePlugin {
     /**
      *  Called whenever the plugin is being instantiated for the first time.
      *  
-     *  @param engine The WikiEngine.
+     *  @param engine The Engine.
      *  @throws PluginException If something goes wrong.
      */
     void initialize( Engine engine ) throws PluginException;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
index 366666b..1a1e0c4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/AttachmentServlet.java
@@ -108,7 +108,7 @@ public class AttachmentServlet extends HttpServlet {
     //private final DateFormat rfcDateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
 
     /**
-     *  Initializes the servlet from WikiEngine properties.
+     *  Initializes the servlet from Engine properties.
      */
     @Override
     public void init( final ServletConfig config ) throws ServletException {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
index b1a01a2..e2c349b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
@@ -37,7 +37,7 @@ import java.util.Set;
 
 
 /**
- * Manages authentication activities for a WikiEngine: user login, logout, and credential refreshes. This class uses JAAS to determine how
+ * Manages authentication activities for a Engine: user login, logout, and credential refreshes. This class uses JAAS to determine how
  * users log in.
  * <p>
  * The login procedure is protected in addition by a mechanism which prevents a hacker to try and force-guess passwords by slowing down
@@ -68,7 +68,7 @@ public interface AuthenticationManager {
     String PROP_LOGIN_MODULE = "jspwiki.loginModule.class";
 
     /**
-     * Creates an AuthenticationManager instance for the given WikiEngine and
+     * Creates an AuthenticationManager instance for the given Engine and
      * the specified set of properties. All initialization for the modules is
      * done here.
      * @param engine the wiki engine
@@ -78,7 +78,7 @@ public interface AuthenticationManager {
     void initialize( Engine engine, Properties props ) throws WikiException;
 
     /**
-     * Returns true if this WikiEngine uses container-managed authentication. This method is used primarily for cosmetic purposes in the
+     * Returns true if this Engine uses container-managed authentication. This method is used primarily for cosmetic purposes in the
      * JSP tier, and performs no meaningful security function per se. Delegates to
      * {@link org.apache.wiki.auth.authorize.WebContainerAuthorizer#isContainerAuthorized()},
      * if used as the external authorizer; otherwise, returns <code>false</code>.
@@ -117,7 +117,7 @@ public interface AuthenticationManager {
     
     /**
      * Attempts to perform a WikiSession login for the given username/password combination using JSPWiki's custom authentication mode. In
-     * order to log in, the JAAS LoginModule supplied by the WikiEngine property {@link #PROP_LOGIN_MODULE} will be instantiated, and its
+     * order to log in, the JAAS LoginModule supplied by the Engine property {@link #PROP_LOGIN_MODULE} will be instantiated, and its
      * {@link javax.security.auth.spi.LoginModule#initialize(Subject, CallbackHandler, Map, Map)} method will be invoked. By default,
      * the {@link org.apache.wiki.auth.login.UserDatabaseLoginModule} class will be used. When the LoginModule's <code>initialize</code>
      * method is invoked, an options Map populated by properties keys prefixed by {@link #PREFIX_LOGIN_MODULE_OPTIONS} will be passed as a
@@ -143,16 +143,16 @@ public interface AuthenticationManager {
     void logout( HttpServletRequest request );
 
     /**
-     * Determines whether this WikiEngine allows users to assert identities using cookies instead of passwords. This is determined by inspecting
-     * the WikiEngine property {@link #PROP_ALLOW_COOKIE_ASSERTIONS}.
+     * Determines whether this Engine allows users to assert identities using cookies instead of passwords. This is determined by inspecting
+     * the Engine property {@link #PROP_ALLOW_COOKIE_ASSERTIONS}.
      *
      * @return <code>true</code> if cookies are allowed
      */
     boolean allowsCookieAssertions();
 
     /**
-     * Determines whether this WikiEngine allows users to authenticate using cookies instead of passwords. This is determined by inspecting
-     * the WikiEngine property {@link #PROP_ALLOW_COOKIE_AUTH}.
+     * Determines whether this Engine allows users to authenticate using cookies instead of passwords. This is determined by inspecting
+     * the Engine property {@link #PROP_ALLOW_COOKIE_AUTH}.
      *
      *  @return <code>true</code> if cookies are allowed for authentication
      *  @since 2.5.62
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
index ce76804..a5a9f13 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthenticationManager.java
@@ -400,7 +400,7 @@ public class DefaultAuthenticationManager implements AuthenticationManager {
      * firing appropriate authentication events.
      *
      * @param session the user's current WikiSession
-     * @param authorizer the WikiEngine's configured Authorizer
+     * @param authorizer the Engine's configured Authorizer
      * @param request the user's HTTP session, which may be <code>null</code>
      */
     private void injectAuthorizerRoles( final WikiSession session, final Authorizer authorizer, final HttpServletRequest request ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
index 92b7057..9d93be4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAuthenticationLoginModule.java
@@ -103,7 +103,8 @@ public class CookieAuthenticationLoginModule extends AbstractLoginModule {
      * @see javax.security.auth.spi.LoginModule#login()
      * {@inheritDoc}
      */
-    @Override public boolean login() throws LoginException {
+    @Override
+    public boolean login() throws LoginException {
         // Otherwise, let's go and look for the cookie!
         final HttpRequestCallback hcb = new HttpRequestCallback();
         final WikiEngineCallback wcb = new WikiEngineCallback();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java b/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
index 2e10917..c4645ca 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/diff/DefaultDifferenceManager.java
@@ -44,7 +44,7 @@ public class DefaultDifferenceManager implements DifferenceManager {
     /**
      * Creates a new DifferenceManager for the given engine.
      *
-     * @param engine The WikiEngine.
+     * @param engine The Engine.
      * @param props  A set of properties.
      */
     public DefaultDifferenceManager( final Engine engine, final Properties props ) {
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 b0004ef..619a7e7 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
@@ -96,7 +96,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
     /**
      *  Constructs a new FilterManager object.
      *
-     *  @param engine The WikiEngine which owns the FilterManager
+     *  @param engine The Engine which owns the FilterManager
      *  @param props Properties to initialize the FilterManager with
      *  @throws WikiException If something goes wrong.
      */
@@ -116,7 +116,8 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *  @param priority The priority in which position to add it in.
      *  @throws IllegalArgumentException If the PageFilter is null or invalid.
      */
-    @Override public void addPageFilter( final PageFilter f, final int priority ) throws IllegalArgumentException {
+    @Override
+    public void addPageFilter( final PageFilter f, final int priority ) throws IllegalArgumentException {
         if( f == null ) {
             throw new IllegalArgumentException("Attempt to provide a null filter - this should never happen.  Please check your configuration (or if you're a developer, check your own code.)");
         }


[jspwiki] 20/20: 2.11.0-M7-git-10

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 d680e47f1f054e42cde89cf85d8aa3911f855646
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Feb 27 16:04:46 2020 +0100

    2.11.0-M7-git-10
---
 ChangeLog.md                                            | 14 ++++++++++++++
 jspwiki-main/src/main/java/org/apache/wiki/Release.java |  2 +-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index 3c4aca1..8668f04 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -19,6 +19,20 @@ under the License.
 
 **2020-02-24  Juan Pablo Santos (juanpablo AT apache DOT org)**
 
+* _2.11.0-M7-git-10_
+
+* Finally, finished [JSPWIKI-120](https://issues.apache.org/jira/browse/JSPWIKI-120):
+    * Use `Engine` instead of `WikiEngine` throughout the code as much as possible. 
+    * `URLConstructor#initialize(..)` receives an `Engine` instead of a `WikiEngine`.
+    * `InitializablePlugin` and implementing classes receive an `Engine` instead of a `WikiEngine`.
+    * `PageFilter`s receive an `Engine` instead of a `WikiEngine` on `initialize` method.
+    * Rename + extract interfaces from `EditorManager`, `InternationalizationManager`, `SearchManager`, 
+    and `TemplateManager`.
+
+* Updated Flexmark to 0.60.2
+
+**2020-02-24  Juan Pablo Santos (juanpablo AT apache DOT org)**
+
 * _2.11.0-M7-git-09_
 
 * [JSPWIKI-120](https://issues.apache.org/jira/browse/JSPWIKI-120):
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 05e2f55..c568b0e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/Release.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
@@ -69,7 +69,7 @@ public final class Release {
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "git-09";
+    public static final String     BUILD         = "git-10";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of


[jspwiki] 16/20: register TemplateManager modules as mbeans

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 b1f6b041434f566d427ed36434a41e47e0e8f7f9
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 21:43:30 2020 +0100

    register TemplateManager modules as mbeans
---
 .../wiki/ui/admin/DefaultAdminBeanManager.java     | 29 +++++++++++-----------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
index 8fc3500..6045a15 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
@@ -29,6 +29,7 @@ import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.ui.EditorManager;
+import org.apache.wiki.ui.TemplateManager;
 import org.apache.wiki.ui.admin.beans.CoreBean;
 import org.apache.wiki.ui.admin.beans.FilterBean;
 import org.apache.wiki.ui.admin.beans.PluginBean;
@@ -58,10 +59,10 @@ import java.util.List;
 public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanManager {
 
     private Engine m_engine;
-    private ArrayList< AdminBean >  m_allBeans;
+    private ArrayList< AdminBean > m_allBeans;
     private MBeanServer m_mbeanServer;
 
-    private static final Logger log = Logger.getLogger(DefaultAdminBeanManager.class);
+    private static final Logger log = Logger.getLogger( DefaultAdminBeanManager.class );
 
     public DefaultAdminBeanManager( final Engine engine ) {
         log.info("Using JDK 1.5 Platform MBeanServer");
@@ -78,9 +79,7 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
         initialize();
     }
 
-    /* (non-Javadoc)
-	 * @see org.apache.wiki.ui.admin.AdminBeanManager#initialize()
-	 */
+    /** {@inheritDoc} */
     @Override
 	public void initialize() {
         reload();
@@ -110,7 +109,6 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
         try {
             if( ab instanceof DynamicMBean && m_mbeanServer != null ) {
                 final ObjectName name = getObjectName( ab );
-
                 if( !m_mbeanServer.isRegistered( name ) ) {
                     m_mbeanServer.registerMBean( ab, name );
                 }
@@ -118,29 +116,29 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
 
             m_allBeans.add( ab );
 
-            log.info("Registered new admin bean "+ab.getTitle());
+            log.info( "Registered new admin bean " + ab.getTitle() );
         } catch( final InstanceAlreadyExistsException e ) {
-            log.error("Admin bean already registered to JMX",e);
+            log.error( "Admin bean already registered to JMX", e );
         } catch( final MBeanRegistrationException e ) {
-            log.error("Admin bean cannot be registered to JMX",e);
+            log.error( "Admin bean cannot be registered to JMX", e );
         } catch( final NotCompliantMBeanException e ) {
-            log.error("Your admin bean is not very good",e);
+            log.error( "Your admin bean is not very good", e );
         } catch( final MalformedObjectNameException e ) {
-            log.error("Your admin bean name is not very good",e);
+            log.error( "Your admin bean name is not very good", e );
         } catch( final NullPointerException e ) {
-            log.error("Evil NPE occurred",e);
+            log.error( "Evil NPE occurred", e );
         }
     }
 
     private ObjectName getObjectName( final AdminBean ab ) throws MalformedObjectNameException {
         final String component = getJMXTitleString( ab.getType() );
         final String title     = ab.getTitle();
-        return new ObjectName( Release.APPNAME + ":component="+component+",name="+title );
+        return new ObjectName( Release.APPNAME + ":component=" + component + ",name=" + title );
     }
 
     /**
-     *  Registers all the beans from a collection of WikiModuleInfos.  If some of the beans
-     *  fail, logs the message and keeps going to the next bean.
+     *  Registers all the beans from a collection of WikiModuleInfos.  If some of the beans fail, logs the message and keeps going to the
+     *  next bean.
      *
      *  @param c Collection of WikiModuleInfo instances
      */
@@ -176,6 +174,7 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
         registerBeans( m_engine.getManager( EditorManager.class ).modules() );
         registerBeans( m_engine.getManager( PluginManager.class ).modules() );
         registerBeans( m_engine.getManager( FilterManager.class ).modules() );
+        registerBeans( m_engine.getManager( TemplateManager.class ).modules() );
     }
 
     /* (non-Javadoc)


[jspwiki] 09/20: JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (4)

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 d6c25ea2523e499eb70ea7d60a9c3ee5cac98023
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 19:23:31 2020 +0100

    JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (4)
---
 .../apache/wiki/search/LuceneSearchProvider.java   |  2 +-
 .../java/org/apache/wiki/search/SearchManager.java | 11 ++++++-----
 .../main/java/org/apache/wiki/tags/IncludeTag.java | 17 +++++++---------
 .../main/java/org/apache/wiki/tags/LinkTag.java    | 23 ++++++++++++----------
 .../org/apache/wiki/variables/VariableManager.java |  2 +-
 5 files changed, 28 insertions(+), 27 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
index 30fbed8..6a7555b 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/LuceneSearchProvider.java
@@ -175,7 +175,7 @@ public class LuceneSearchProvider implements SearchProvider {
     /**
      *  Returns the handling engine.
      *
-     *  @return Current WikiEngine
+     *  @return Current Engine
      */
     protected Engine getEngine()
     {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
index 53e1c5d..dcc0eae 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
@@ -22,11 +22,11 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.time.StopWatch;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.ajax.AjaxUtil;
 import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
 import org.apache.wiki.ajax.WikiAjaxServlet;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.FilterException;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.api.exceptions.ProviderException;
@@ -38,6 +38,7 @@ import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.modules.InternalModule;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.parser.MarkupParser;
+import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.util.ClassUtil;
 
 import javax.servlet.ServletException;
@@ -75,11 +76,11 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
     /**
      *  Creates a new SearchManager.
      *
-     *  @param engine The WikiEngine that owns this SearchManager.
+     *  @param engine The Engine that owns this SearchManager.
      *  @param properties The list of Properties.
      *  @throws FilterException If it cannot be instantiated.
      */
-    public SearchManager( final WikiEngine engine, final Properties properties ) throws FilterException {
+    public SearchManager( final Engine engine, final Properties properties ) throws FilterException {
         initialize( engine, properties );
         WikiEventManager.getInstance().addWikiEventListener( m_engine.getManager( PageManager.class ), this );
 
@@ -163,7 +164,7 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
 
                 final String cleanWikiName = MarkupParser.cleanLink(wikiName).toLowerCase() + filename;
                 final String oldStyleName = MarkupParser.wikifyLink(wikiName).toLowerCase() + filename;
-                final Set< String > allPages = m_engine.getReferenceManager().findCreated();
+                final Set< String > allPages = m_engine.getManager( ReferenceManager.class ).findCreated();
 
                 int counter = 0;
                 for( final Iterator< String > i = allPages.iterator(); i.hasNext() && counter < maxLength; ) {
@@ -236,7 +237,7 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
      * @throws FilterException if the search provider failed to initialize
      */
     @Override
-    public void initialize( final WikiEngine engine, final Properties properties ) throws FilterException {
+    public void initialize( final Engine engine, final Properties properties ) throws FilterException {
         m_engine = engine;
         loadSearchProvider(properties);
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/IncludeTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/IncludeTag.java
index 8332c63..9d1d67e 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/IncludeTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/IncludeTag.java
@@ -28,8 +28,7 @@ import javax.servlet.jsp.JspException;
 import java.io.IOException;
 
 /**
- *  Includes an another JSP page, making sure that we actually pass
- *  the WikiContext correctly.
+ *  Includes an another JSP page, making sure that we actually pass the WikiContext correctly.
  *
  *  @since 2.0
  */
@@ -41,7 +40,8 @@ public class IncludeTag extends WikiTagBase {
     
     protected String m_page;
 
-    @Override public void initTag() {
+    @Override
+    public void initTag() {
         super.initTag();
         m_page = null;
     }
@@ -56,16 +56,13 @@ public class IncludeTag extends WikiTagBase {
         return m_page;
     }
 
-    @Override public final int doWikiStartTag()
-        throws IOException,
-               ProviderException
-    {
-        // WikiEngine engine = m_wikiContext.getEngine();
-
+    @Override
+    public final int doWikiStartTag() throws IOException, ProviderException {
         return SKIP_BODY;
     }
 
-    @Override public final int doEndTag() throws JspException {
+    @Override
+    public final int doEndTag() throws JspException {
         try {
             final String page = m_wikiContext.getEngine().getManager( TemplateManager.class ).findJSP( pageContext,
                                                                                                  m_wikiContext.getTemplate(),
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java
index c4609ed..b5badf2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/LinkTag.java
@@ -41,7 +41,7 @@ import java.util.Map;
 /**
  *  Provides a generic link tag for all kinds of linking purposes.
  *  <p>
- *  If parameter <i>jsp</i> is defined, constructs a URL pointing to the specified JSP page, under the baseURL known by the WikiEngine.
+ *  If parameter <i>jsp</i> is defined, constructs a URL pointing to the specified JSP page, under the baseURL known by the Engine.
  *  Any ParamTag name-value pairs contained in the body are added to this URL to provide support for arbitrary JSP calls.
  *  <p>
  *  @since 2.3.50
@@ -69,7 +69,8 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
 
     private BodyContent m_bodyContent;
 
-    @Override public void initTag() {
+    @Override
+    public void initTag() {
         super.initTag();
         m_version = m_cssClass = m_style = m_title = m_target = m_compareToVersion = m_rel = m_jsp = m_ref = m_accesskey = m_templatefile = null;
         m_context = WikiContext.VIEW;
@@ -149,7 +150,8 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
     /**
      * Support for ParamTag supplied parameters in body.
      */
-    @Override public void setContainedParameter( final String name, final String value ) {
+    @Override
+    public void setContainedParameter( final String name, final String value ) {
         if( name != null ) {
             if( m_containedParams == null ) {
                 m_containedParams = new HashMap<>();
@@ -205,11 +207,8 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
 
                 final String parms = (m_version != null) ? "version="+getVersion() : null;
 
-                //
                 //  Internal wiki link, but is it an attachment link?
-                //
                 final WikiPage p = engine.getManager( PageManager.class ).getPage( m_pageName );
-
                 if( p instanceof Attachment ) {
                     url = m_wikiContext.getURL( WikiContext.ATTACH, m_pageName );
                 } else if( (hashMark = m_ref.indexOf('#')) != -1 ) {
@@ -326,11 +325,13 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
         return engine.getURL( m_context, m_pageName, parms );
     }
 
-    @Override public int doWikiStartTag() throws Exception {
+    @Override
+    public int doWikiStartTag() throws Exception {
         return EVAL_BODY_BUFFERED;
     }
 
-    @Override public int doEndTag() {
+    @Override
+    public int doEndTag() {
         try {
             final Engine engine = m_wikiContext.getEngine();
             final JspWriter out = pageContext.getOut();
@@ -376,12 +377,14 @@ public class LinkTag extends WikiLinkTag implements ParamHandler, BodyTag {
         return EVAL_PAGE;
     }
 
-    @Override public void setBodyContent( final BodyContent bc )
+    @Override
+    public void setBodyContent( final BodyContent bc )
     {
         m_bodyContent = bc;
     }
 
-    @Override public void doInitBody() {
+    @Override
+    public void doInitBody() {
     }
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/variables/VariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/variables/VariableManager.java
index bb94598..8387902 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/variables/VariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/variables/VariableManager.java
@@ -79,7 +79,7 @@ public interface VariableManager {
      *  @param context WikiContext to look the variable in
      *  @param name Name of the variable to look for
      *  @return Variable value, or null, if there is no such variable.
-     *  @since 2.2 on WikiEngine, moved to VariableManager on 2.11.0
+     *  @since 2.2 on Engine, moved to VariableManager on 2.11.0
      */
     String getVariable( WikiContext context, String name );
 


[jspwiki] 15/20: JSPWIKI-120: rename + extract interfaces from InternationalizationManager, SearchManager, EditorManager and TemplateManager

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 558e4916f7f956bfb99475c1de006a030d728776
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 21:41:11 2020 +0100

    JSPWIKI-120: rename + extract interfaces from InternationalizationManager, SearchManager, EditorManager and TemplateManager
---
 .../i18n/DefaultInternationalizationManager.java   |  39 ++
 .../wiki/i18n/InternationalizationManager.java     |  24 +-
 ...earchManager.java => DefaultSearchManager.java} | 106 +-----
 .../java/org/apache/wiki/search/SearchManager.java | 289 +--------------
 ...ditorManager.java => DefaultEditorManager.java} |  97 +----
 .../org/apache/wiki/ui/DefaultTemplateManager.java | 353 +++++++++++++++++++
 .../java/org/apache/wiki/ui/EditorManager.java     | 162 +--------
 .../java/org/apache/wiki/ui/TemplateManager.java   | 392 +++------------------
 .../src/main/resources/ini/classmappings.xml       |   8 +-
 .../wiki/i18n/InternationalizationManagerTest.java |  10 +-
 10 files changed, 518 insertions(+), 962 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/i18n/DefaultInternationalizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/i18n/DefaultInternationalizationManager.java
new file mode 100644
index 0000000..a05ba13
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/i18n/DefaultInternationalizationManager.java
@@ -0,0 +1,39 @@
+/*
+    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.i18n;
+
+import org.apache.wiki.api.core.Engine;
+
+
+/**
+ *  Manages all internationalization in JSPWiki.
+ *
+ *  @since 2.6
+ */
+public class DefaultInternationalizationManager implements InternationalizationManager {
+
+    /**
+     *  Constructs a new InternationalizationManager.
+     *
+     *  @param engine To which engine this belongs to
+     */
+    public DefaultInternationalizationManager( final Engine engine ) {
+    }
+
+}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/i18n/InternationalizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/i18n/InternationalizationManager.java
index 6d2e07d..1feb01c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/i18n/InternationalizationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/i18n/InternationalizationManager.java
@@ -18,8 +18,6 @@
  */
 package org.apache.wiki.i18n;
 
-import org.apache.wiki.api.core.Engine;
-
 import java.text.MessageFormat;
 import java.util.Locale;
 import java.util.MissingResourceException;
@@ -31,32 +29,24 @@ import java.util.ResourceBundle;
  *
  *  @since 2.6
  */
-public class InternationalizationManager {
+public interface InternationalizationManager {
 
     /** The name of the ResourceBundle which contains any and all JSPWiki core resource strings.  It's value is {@value}. */
-    public static final String CORE_BUNDLE = "CoreResources";
+    String CORE_BUNDLE = "CoreResources";
     
     /** The name of the ResourceBundle which contains any and all JSPWiki default templates resource strings.  It's value is {@value}. */
-    public static final String DEF_TEMPLATE = "templates.default";
+    String DEF_TEMPLATE = "templates.default";
     // public static final String JSPWIKI_BUNDLE = "jspwiki";
     // public static final String PLUGINS_BUNDLE = "plugins";
 
     /**
-     *  Constructs a new InternationalizationManager.
-     *
-     *  @param engine To which engine this belongs to
-     */
-    public InternationalizationManager( final Engine engine ) {
-    }
-
-    /**
      *  Returns a String from the CORE_BUNDLE using English as the default locale.
      *
      *  @param key Key to find
      *  @return The English string
      *  @throws MissingResourceException If there is no such key
      */
-    public String get( final String key ) throws MissingResourceException {
+    default String get( final String key ) throws MissingResourceException {
         return get( CORE_BUNDLE, Locale.ENGLISH, key );
     }
     
@@ -68,7 +58,7 @@ public class InternationalizationManager {
      *  @return A localized string
      *  @throws MissingResourceException If the key cannot be located at all, even from the default locale.
      */
-    public ResourceBundle getBundle( final String bundle, Locale locale ) throws MissingResourceException {
+    default ResourceBundle getBundle( final String bundle, Locale locale ) throws MissingResourceException {
         if( locale == null ) {
             locale = Locale.getDefault();
         }
@@ -85,7 +75,7 @@ public class InternationalizationManager {
      *  @return A localized string (or from the default language, if not found)
      *  @throws MissingResourceException If the key cannot be located at all, even from the default locale.
      */
-    public String get( final String bundle, final Locale locale, final String key ) throws MissingResourceException {
+    default String get( final String bundle, final Locale locale, final String key ) throws MissingResourceException {
         return getBundle( bundle, locale ).getString( key );
     }
 
@@ -99,7 +89,7 @@ public class InternationalizationManager {
      *  @return A localized string (or from the default language, if not found)
      *  @throws MissingResourceException If the key cannot be located at all, even from the default locale.
      */
-    public String get( final String bundle, final Locale locale, final String key, final Object... args ) throws MissingResourceException {
+    default String get( final String bundle, final Locale locale, final String key, final Object... args ) throws MissingResourceException {
         final MessageFormat mf = new MessageFormat( get( bundle, locale, key ), locale );
         return mf.format( args );
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java b/jspwiki-main/src/main/java/org/apache/wiki/search/DefaultSearchManager.java
similarity index 75%
copy from jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
copy to jspwiki-main/src/main/java/org/apache/wiki/search/DefaultSearchManager.java
index dcc0eae..1831d92 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/DefaultSearchManager.java
@@ -29,19 +29,15 @@ import org.apache.wiki.ajax.WikiAjaxServlet;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.FilterException;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
-import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.wiki.event.WikiEvent;
-import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
-import org.apache.wiki.modules.InternalModule;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.util.ClassUtil;
 
-import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
@@ -54,24 +50,17 @@ import java.util.Map;
 import java.util.Properties;
 import java.util.Set;
 
+
 /**
  *  Manages searching the Wiki.
  *
  *  @since 2.2.21.
  */
-public class SearchManager extends BasicPageFilter implements InternalModule, WikiEventListener {
-
-    private static final Logger log = Logger.getLogger( SearchManager.class );
-
-    private static final String DEFAULT_SEARCHPROVIDER  = "org.apache.wiki.search.LuceneSearchProvider";
+public class DefaultSearchManager extends BasicPageFilter implements SearchManager {
 
-    /** Property name for setting the search provider. Value is <tt>{@value}</tt>. */
-    public static final String PROP_SEARCHPROVIDER      = "jspwiki.searchProvider";
+    private static final Logger log = Logger.getLogger( DefaultSearchManager.class );
 
-    private SearchProvider    m_searchProvider;
-
-    /** The name of the JSON object that manages search. */
-    public static final String JSON_SEARCH = "search";
+    private SearchProvider m_searchProvider;
 
     /**
      *  Creates a new SearchManager.
@@ -80,16 +69,16 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
      *  @param properties The list of Properties.
      *  @throws FilterException If it cannot be instantiated.
      */
-    public SearchManager( final Engine engine, final Properties properties ) throws FilterException {
+    public DefaultSearchManager( final Engine engine, final Properties properties ) throws FilterException {
         initialize( engine, properties );
         WikiEventManager.getInstance().addWikiEventListener( m_engine.getManager( PageManager.class ), this );
 
-        //TODO: Replace with custom annotations. See JSPWIKI-566
+        // TODO: Replace with custom annotations. See JSPWIKI-566
         WikiAjaxDispatcherServlet.registerServlet( JSON_SEARCH, new JSONSearch() );
     }
 
     /**
-     *  Provides a JSON RPC API to the JSPWiki Search Engine.
+     *  Provides a JSON AJAX API to the JSPWiki Search Engine.
      */
     public class JSONSearch implements WikiAjaxServlet {
 
@@ -98,16 +87,18 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
         public static final int DEFAULT_MAX_RESULTS = 20;
         public int maxResults = DEFAULT_MAX_RESULTS;
 
+        /** {@inheritDoc} */
         @Override
         public String getServletMapping() {
             return JSON_SEARCH;
         }
 
+        /** {@inheritDoc} */
         @Override
         public void service( final HttpServletRequest req,
                              final HttpServletResponse resp,
                              final String actionName,
-                             final List< String > params ) throws ServletException, IOException {
+                             final List< String > params ) throws IOException {
             String result = "";
             if( StringUtils.isNotBlank( actionName ) ) {
                 if( params.size() < 1 ) {
@@ -152,7 +143,6 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
             final StopWatch sw = new StopWatch();
             sw.start();
             final List< String > list = new ArrayList<>( maxLength );
-
             if( wikiName.length() > 0 ) {
                 // split pagename and attachment filename
                 String filename = "";
@@ -199,7 +189,6 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
             if( searchString.length() > 0 ) {
                 try {
                     final Collection< SearchResult > c;
-
                     if( m_searchProvider instanceof LuceneSearchProvider ) {
                         c = ( ( LuceneSearchProvider )m_searchProvider ).findPages( searchString, 0, wikiContext );
                     } else {
@@ -228,14 +217,7 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
     }
 
 
-    /**
-     *  This particular method starts off indexing and all sorts of various activities,
-     *  so you need to run this last, after things are done.
-     *
-     * @param engine the wiki engine
-     * @param properties the properties used to initialize the wiki engine
-     * @throws FilterException if the search provider failed to initialize
-     */
+    /** {@inheritDoc} */
     @Override
     public void initialize( final Engine engine, final Properties properties ) throws FilterException {
         m_engine = engine;
@@ -249,14 +231,12 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
     }
 
     private void loadSearchProvider( final Properties properties ) {
-        //
         // See if we're using Lucene, and if so, ensure that its index directory is up to date.
-        //
         final String providerClassName = properties.getProperty( PROP_SEARCHPROVIDER, DEFAULT_SEARCHPROVIDER );
 
         try {
             final Class<?> providerClass = ClassUtil.findClass( "org.apache.wiki.search", providerClassName );
-            m_searchProvider = (SearchProvider)providerClass.newInstance();
+            m_searchProvider = ( SearchProvider )providerClass.newInstance();
         } catch( final ClassNotFoundException | InstantiationException | IllegalAccessException e ) {
             log.warn("Failed loading SearchProvider, will use BasicSearchProvider.", e);
         }
@@ -268,70 +248,14 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
         log.debug("Loaded search provider " + m_searchProvider);
     }
 
-    /**
-     *  Returns the SearchProvider used.
-     *
-     *  @return The current SearchProvider.
-     */
+    /** {@inheritDoc} */
+    @Override
     public SearchProvider getSearchEngine()
     {
         return m_searchProvider;
     }
 
-    /**
-     *  Sends a search to the current search provider. The query is is whatever native format
-     *  the query engine wants to use.
-     *
-     * @param query The query.  Null is safe, and is interpreted as an empty query.
-     * @param wikiContext the context within which to run the search
-     * @return A collection of WikiPages that matched.
-     * @throws ProviderException If the provider fails and a search cannot be completed.
-     * @throws IOException If something else goes wrong.
-     */
-    public Collection< SearchResult > findPages( String query, final WikiContext wikiContext ) throws ProviderException, IOException {
-        if( query == null ) {
-            query = "";
-        }
-        return m_searchProvider.findPages( query, wikiContext );
-    }
-
-    /**
-     *  Removes the page from the search cache (if any).
-     *  @param page  The page to remove
-     */
-    public void pageRemoved( final WikiPage page )
-    {
-        m_searchProvider.pageRemoved(page);
-    }
-
-    /**
-     *  Reindexes the page.
-     *
-     *  @param wikiContext {@inheritDoc}
-     *  @param content {@inheritDoc}
-     */
-    @Override
-    public void postSave( final WikiContext wikiContext, final String content ) {
-        //  Makes sure that we're indexing the latest version of this page.
-        final WikiPage p = m_engine.getManager( PageManager.class ).getPage( wikiContext.getPage().getName() );
-        reindexPage( p );
-    }
-
-    /**
-     *   Forces the reindex of the given page.
-     *
-     *   @param page The page.
-     */
-    public void reindexPage( final WikiPage page )
-    {
-        m_searchProvider.reindexPage( page );
-    }
-
-    /**
-     *  If the page has been deleted, removes it from the index.
-     *
-     *  @param event {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     public void actionPerformed( final WikiEvent event ) {
         if( event instanceof WikiPageEvent && event.getType() == WikiPageEvent.PAGE_DELETE_REQUEST ) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
index dcc0eae..131be40 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
@@ -18,269 +18,41 @@
  */
 package org.apache.wiki.search;
 
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.time.StopWatch;
-import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
-import org.apache.wiki.ajax.AjaxUtil;
-import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
-import org.apache.wiki.ajax.WikiAjaxServlet;
-import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.exceptions.FilterException;
-import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.api.exceptions.ProviderException;
-import org.apache.wiki.api.filters.BasicPageFilter;
-import org.apache.wiki.event.WikiEvent;
+import org.apache.wiki.api.filters.PageFilter;
 import org.apache.wiki.event.WikiEventListener;
-import org.apache.wiki.event.WikiEventManager;
-import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.modules.InternalModule;
-import org.apache.wiki.pages.PageManager;
-import org.apache.wiki.parser.MarkupParser;
-import org.apache.wiki.references.ReferenceManager;
-import org.apache.wiki.util.ClassUtil;
 
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
+
 
 /**
  *  Manages searching the Wiki.
  *
  *  @since 2.2.21.
  */
-public class SearchManager extends BasicPageFilter implements InternalModule, WikiEventListener {
-
-    private static final Logger log = Logger.getLogger( SearchManager.class );
+public interface SearchManager extends PageFilter, InternalModule, WikiEventListener {
 
-    private static final String DEFAULT_SEARCHPROVIDER  = "org.apache.wiki.search.LuceneSearchProvider";
+    String DEFAULT_SEARCHPROVIDER = "org.apache.wiki.search.LuceneSearchProvider";
 
     /** Property name for setting the search provider. Value is <tt>{@value}</tt>. */
-    public static final String PROP_SEARCHPROVIDER      = "jspwiki.searchProvider";
-
-    private SearchProvider    m_searchProvider;
+    String PROP_SEARCHPROVIDER = "jspwiki.searchProvider";
 
     /** The name of the JSON object that manages search. */
-    public static final String JSON_SEARCH = "search";
-
-    /**
-     *  Creates a new SearchManager.
-     *
-     *  @param engine The Engine that owns this SearchManager.
-     *  @param properties The list of Properties.
-     *  @throws FilterException If it cannot be instantiated.
-     */
-    public SearchManager( final Engine engine, final Properties properties ) throws FilterException {
-        initialize( engine, properties );
-        WikiEventManager.getInstance().addWikiEventListener( m_engine.getManager( PageManager.class ), this );
-
-        //TODO: Replace with custom annotations. See JSPWIKI-566
-        WikiAjaxDispatcherServlet.registerServlet( JSON_SEARCH, new JSONSearch() );
-    }
-
-    /**
-     *  Provides a JSON RPC API to the JSPWiki Search Engine.
-     */
-    public class JSONSearch implements WikiAjaxServlet {
-
-        public static final String AJAX_ACTION_SUGGESTIONS = "suggestions";
-        public static final String AJAX_ACTION_PAGES = "pages";
-        public static final int DEFAULT_MAX_RESULTS = 20;
-        public int maxResults = DEFAULT_MAX_RESULTS;
-
-        @Override
-        public String getServletMapping() {
-            return JSON_SEARCH;
-        }
-
-        @Override
-        public void service( final HttpServletRequest req,
-                             final HttpServletResponse resp,
-                             final String actionName,
-                             final List< String > params ) throws ServletException, IOException {
-            String result = "";
-            if( StringUtils.isNotBlank( actionName ) ) {
-                if( params.size() < 1 ) {
-                    return;
-                }
-                final String itemId = params.get( 0 );
-                log.debug( "itemId=" + itemId );
-                if( params.size() > 1 ) {
-                    final String maxResultsParam = params.get( 1 );
-                    log.debug( "maxResultsParam=" + maxResultsParam );
-                    if( StringUtils.isNotBlank( maxResultsParam ) && StringUtils.isNumeric( maxResultsParam ) ) {
-                        maxResults = Integer.parseInt( maxResultsParam );
-                    }
-                }
-
-                if( actionName.equals( AJAX_ACTION_SUGGESTIONS ) ) {
-                    log.debug( "Calling getSuggestions() START" );
-                    final List< String > callResults = getSuggestions( itemId, maxResults );
-                    log.debug( "Calling getSuggestions() DONE. " + callResults.size() );
-                    result = AjaxUtil.toJson( callResults );
-                } else if( actionName.equals( AJAX_ACTION_PAGES ) ) {
-                    log.debug("Calling findPages() START");
-                    final WikiContext wikiContext = new WikiContext( m_engine, req, WikiContext.VIEW );
-                    final List< Map< String, Object > > callResults = findPages( itemId, maxResults, wikiContext );
-                    log.debug( "Calling findPages() DONE. " + callResults.size() );
-                    result = AjaxUtil.toJson( callResults );
-                }
-            }
-            log.debug( "result=" + result );
-            resp.getWriter().write( result );
-        }
-
-        /**
-         *  Provides a list of suggestions to use for a page name. Currently the algorithm just looks into the value parameter,
-         *  and returns all page names from that.
-         *
-         *  @param wikiName the page name
-         *  @param maxLength maximum number of suggestions
-         *  @return the suggestions
-         */
-        public List< String > getSuggestions( String wikiName, final int maxLength ) {
-            final StopWatch sw = new StopWatch();
-            sw.start();
-            final List< String > list = new ArrayList<>( maxLength );
-
-            if( wikiName.length() > 0 ) {
-                // split pagename and attachment filename
-                String filename = "";
-                final int pos = wikiName.indexOf("/");
-                if( pos >= 0 ) {
-                    filename = wikiName.substring( pos ).toLowerCase();
-                    wikiName = wikiName.substring( 0, pos );
-                }
-
-                final String cleanWikiName = MarkupParser.cleanLink(wikiName).toLowerCase() + filename;
-                final String oldStyleName = MarkupParser.wikifyLink(wikiName).toLowerCase() + filename;
-                final Set< String > allPages = m_engine.getManager( ReferenceManager.class ).findCreated();
-
-                int counter = 0;
-                for( final Iterator< String > i = allPages.iterator(); i.hasNext() && counter < maxLength; ) {
-                    final String p = i.next();
-                    final String pp = p.toLowerCase();
-                    if( pp.startsWith( cleanWikiName) || pp.startsWith( oldStyleName ) ) {
-                        list.add( p );
-                        counter++;
-                    }
-                }
-            }
-
-            sw.stop();
-            if( log.isDebugEnabled() ) {
-                log.debug( "Suggestion request for " + wikiName + " done in " + sw );
-            }
-            return list;
-        }
-
-        /**
-         *  Performs a full search of pages.
-         *
-         *  @param searchString The query string
-         *  @param maxLength How many hits to return
-         *  @return the pages found
-         */
-        public List< Map< String, Object > > findPages( final String searchString, final int maxLength, final WikiContext wikiContext ) {
-            final StopWatch sw = new StopWatch();
-            sw.start();
-
-            final List< Map< String, Object > > list = new ArrayList<>( maxLength );
-            if( searchString.length() > 0 ) {
-                try {
-                    final Collection< SearchResult > c;
-
-                    if( m_searchProvider instanceof LuceneSearchProvider ) {
-                        c = ( ( LuceneSearchProvider )m_searchProvider ).findPages( searchString, 0, wikiContext );
-                    } else {
-                        c = m_searchProvider.findPages( searchString, wikiContext );
-                    }
-
-                    int count = 0;
-                    for( final Iterator< SearchResult > i = c.iterator(); i.hasNext() && count < maxLength; count++ ) {
-                        final SearchResult sr = i.next();
-                        final HashMap< String, Object > hm = new HashMap<>();
-                        hm.put( "page", sr.getPage().getName() );
-                        hm.put( "score", sr.getScore() );
-                        list.add( hm );
-                    }
-                } catch( final Exception e ) {
-                    log.info( "AJAX search failed; ", e );
-                }
-            }
-
-            sw.stop();
-            if( log.isDebugEnabled() ) {
-                log.debug( "AJAX search complete in " + sw );
-            }
-            return list;
-        }
-    }
-
-
-    /**
-     *  This particular method starts off indexing and all sorts of various activities,
-     *  so you need to run this last, after things are done.
-     *
-     * @param engine the wiki engine
-     * @param properties the properties used to initialize the wiki engine
-     * @throws FilterException if the search provider failed to initialize
-     */
-    @Override
-    public void initialize( final Engine engine, final Properties properties ) throws FilterException {
-        m_engine = engine;
-        loadSearchProvider(properties);
-
-        try {
-            m_searchProvider.initialize( engine, properties );
-        } catch( final NoRequiredPropertyException | IOException e ) {
-            log.error( e.getMessage(), e );
-        }
-    }
-
-    private void loadSearchProvider( final Properties properties ) {
-        //
-        // See if we're using Lucene, and if so, ensure that its index directory is up to date.
-        //
-        final String providerClassName = properties.getProperty( PROP_SEARCHPROVIDER, DEFAULT_SEARCHPROVIDER );
-
-        try {
-            final Class<?> providerClass = ClassUtil.findClass( "org.apache.wiki.search", providerClassName );
-            m_searchProvider = (SearchProvider)providerClass.newInstance();
-        } catch( final ClassNotFoundException | InstantiationException | IllegalAccessException e ) {
-            log.warn("Failed loading SearchProvider, will use BasicSearchProvider.", e);
-        }
-
-        if( null == m_searchProvider ) {
-            // FIXME: Make a static with the default search provider
-            m_searchProvider = new BasicSearchProvider();
-        }
-        log.debug("Loaded search provider " + m_searchProvider);
-    }
+    String JSON_SEARCH = "search";
 
     /**
      *  Returns the SearchProvider used.
      *
      *  @return The current SearchProvider.
      */
-    public SearchProvider getSearchEngine()
-    {
-        return m_searchProvider;
-    }
+    SearchProvider getSearchEngine();
 
     /**
-     *  Sends a search to the current search provider. The query is is whatever native format
-     *  the query engine wants to use.
+     *  Sends a search to the current search provider. The query is is whatever native format the query engine wants to use.
      *
      * @param query The query.  Null is safe, and is interpreted as an empty query.
      * @param wikiContext the context within which to run the search
@@ -288,33 +60,20 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
      * @throws ProviderException If the provider fails and a search cannot be completed.
      * @throws IOException If something else goes wrong.
      */
-    public Collection< SearchResult > findPages( String query, final WikiContext wikiContext ) throws ProviderException, IOException {
+    default Collection< SearchResult > findPages( String query, final WikiContext wikiContext ) throws ProviderException, IOException {
         if( query == null ) {
             query = "";
         }
-        return m_searchProvider.findPages( query, wikiContext );
+        return getSearchEngine().findPages( query, wikiContext );
     }
 
     /**
      *  Removes the page from the search cache (if any).
-     *  @param page  The page to remove
-     */
-    public void pageRemoved( final WikiPage page )
-    {
-        m_searchProvider.pageRemoved(page);
-    }
-
-    /**
-     *  Reindexes the page.
      *
-     *  @param wikiContext {@inheritDoc}
-     *  @param content {@inheritDoc}
+     *  @param page  The page to remove
      */
-    @Override
-    public void postSave( final WikiContext wikiContext, final String content ) {
-        //  Makes sure that we're indexing the latest version of this page.
-        final WikiPage p = m_engine.getManager( PageManager.class ).getPage( wikiContext.getPage().getName() );
-        reindexPage( p );
+    default void pageRemoved( final WikiPage page ) {
+        getSearchEngine().pageRemoved( page );
     }
 
     /**
@@ -322,26 +81,8 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
      *
      *   @param page The page.
      */
-    public void reindexPage( final WikiPage page )
-    {
-        m_searchProvider.reindexPage( page );
-    }
-
-    /**
-     *  If the page has been deleted, removes it from the index.
-     *
-     *  @param event {@inheritDoc}
-     */
-    @Override
-    public void actionPerformed( final WikiEvent event ) {
-        if( event instanceof WikiPageEvent && event.getType() == WikiPageEvent.PAGE_DELETE_REQUEST ) {
-            final String pageName = ( ( WikiPageEvent ) event ).getPageName();
-
-            final WikiPage p = m_engine.getManager( PageManager.class ).getPage( pageName );
-            if( p != null ) {
-                pageRemoved( p );
-            }
-        }
+    default void reindexPage( final WikiPage page ) {
+        getSearchEngine().reindexPage( page );
     }
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultEditorManager.java
similarity index 63%
copy from jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
copy to jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultEditorManager.java
index 9d173fd..71a1cb4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultEditorManager.java
@@ -29,7 +29,6 @@ import org.apache.wiki.util.XmlUtil;
 import org.apache.wiki.variables.VariableManager;
 import org.jdom2.Element;
 
-import javax.servlet.jsp.PageContext;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
@@ -56,55 +55,28 @@ import java.util.Set;
  *
  *  @since 2.4
  */
-public class EditorManager extends ModuleManager {
-
-    /** The property name for setting the editor. Current value is "jspwiki.editor" - not used anymore: replaced by defaultpref.template.editor */
-    public static final String PROP_EDITORTYPE = "jspwiki.editor";
-
-    /** Parameter for changing editors at run-time */
-    public static final String PARA_EDITOR = "editor";
-
-    /** Known name for the plain wikimarkup editor. */
-    public static final String EDITOR_PLAIN = "plain";
-
-    /** Known name for the preview editor component. */
-    public static final String EDITOR_PREVIEW = "preview";
-
-    /** Known attribute name for storing the user edited text inside a HTTP parameter. */
-    public static final String REQ_EDITEDTEXT = "_editedtext";
-
-    /** Known attribute name for storing the user edited text inside a session or a page context */
-    public static final String ATTR_EDITEDTEXT = REQ_EDITEDTEXT;
+public class DefaultEditorManager extends ModuleManager implements EditorManager {
 
     private Map< String, WikiEditorInfo > m_editors;
 
-    private static final Logger log = Logger.getLogger( EditorManager.class );
+    private static final Logger log = Logger.getLogger( DefaultEditorManager.class );
 
-    public EditorManager( final Engine engine ) {
+    public DefaultEditorManager( final Engine engine ) {
         super( engine );
     }
 
-    /**
-     *  Initializes the EditorManager.  It also registers any editors it can find.
-     *
-     *  @param props  Properties for setup.
-     */
+    /** {@inheritDoc} */
+    @Override
     public void initialize( final Properties props ) {
         registerEditors();
     }
 
-    /**
-     *  This method goes through the jspwiki_module.xml files and hunts for editors. Any editors found are put in the registry.
-     */
+    /** This method goes through the jspwiki_module.xml files and hunts for editors. Any editors found are put in the registry. */
     private void registerEditors() {
         log.info( "Registering editor modules" );
         m_editors = new HashMap<>();
 
-        //
-        // Register all editors which have created a resource containing its properties.
-        //
-        // Get all resources of all modules
-        //
+        // Register all editors which have created a resource containing its properties. Get all resources of all modules
         final List< Element > editors = XmlUtil.parse( PLUGIN_RESOURCE_LOCATION, "/modules/editor" );
         for( final Element pluginEl : editors ) {
             final String name = pluginEl.getAttributeValue( "name" );
@@ -119,19 +91,8 @@ public class EditorManager extends ModuleManager {
         }
     }
 
-    /**
-     *  Returns an editor for the current context.  The editor names are matched in a case insensitive manner.  At the moment, the only
-     *  place that this method looks in is the property file, but in the future this will also look at user preferences.
-     *  <p>
-     *  Determines the editor to use by the following order of conditions:
-     *  1. Editor set in User Preferences
-     *  2. Default Editor set in jspwiki.properties
-     *  <p>
-     *  For the PREVIEW context, this method returns the "preview" editor.
-     *
-     * @param context The context that is chosen.
-     * @return The name of the chosen editor. If no match could be found, will revert to the default "plain" editor.
-     */
+    /** {@inheritDoc} */
+    @Override
     public String getEditorName( final WikiContext context ) {
         if( context.getRequestContext().equals( WikiContext.PREVIEW ) ) {
             return EDITOR_PREVIEW;
@@ -161,11 +122,8 @@ public class EditorManager extends ModuleManager {
         return EDITOR_PLAIN;
     }
 
-    /**
-     *  Returns a list of editors as Strings of editor names.
-     *
-     *  @return the list of available editors
-     */
+    /** {@inheritDoc} */
+    @Override
     public String[] getEditorList() {
         final String[] editors = new String[ m_editors.size() ];
         final Set< String > keys = m_editors.keySet();
@@ -173,12 +131,8 @@ public class EditorManager extends ModuleManager {
         return keys.toArray( editors );
     }
 
-    /**
-     *  Convenience method for getting the path to the editor JSP file.
-     *
-     *  @param context WikiContext from where the editor name is retrieved.
-     *  @return e.g. "editors/plain.jsp"
-     */
+    /** {@inheritDoc} */
+    @Override
     public String getEditorPath( final WikiContext context ) {
         final String editor = getEditorName( context );
         final WikiEditorInfo ed = m_editors.get( editor );
@@ -192,22 +146,6 @@ public class EditorManager extends ModuleManager {
         return path;
     }
 
-    /**
-     *  Convenience function which examines the current context and attempts to figure out whether the edited text is in the HTTP
-     *  request parameters or somewhere in the session.
-     *
-     *  @param ctx the JSP page context
-     *  @return the edited text, if present in the session page context or as a parameter
-     */
-    public static String getEditedText( final PageContext ctx ) {
-        String usertext = ctx.getRequest().getParameter( REQ_EDITEDTEXT );
-        if( usertext == null ) {
-            usertext = ( String )ctx.findAttribute( ATTR_EDITEDTEXT );
-        }
-
-        return usertext;
-    }
-
     /**  Contains info about an editor. */
     private static final class WikiEditorInfo extends WikiModuleInfo {
         private String m_path;
@@ -221,6 +159,7 @@ public class EditorManager extends ModuleManager {
             return info;
         }
 
+        /** {@inheritDoc} */
         @Override
         protected void initializeFromXML( final Element el ) {
             super.initializeFromXML( el );
@@ -236,17 +175,13 @@ public class EditorManager extends ModuleManager {
         }
     }
 
-    /**
-     *  {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     public Collection< WikiModuleInfo > modules() {
         return modules( m_editors.values().iterator() );
     }
 
-    /**
-     *  {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     public WikiEditorInfo getModuleInfo( final String moduleName ) {
         return m_editors.get( moduleName );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultTemplateManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultTemplateManager.java
new file mode 100644
index 0000000..85065fe
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultTemplateManager.java
@@ -0,0 +1,353 @@
+/*
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
+ */
+package org.apache.wiki.ui;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.log4j.Logger;
+import org.apache.wiki.InternalWikiException;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.modules.ModuleManager;
+import org.apache.wiki.modules.WikiModuleInfo;
+import org.apache.wiki.preferences.Preferences;
+import org.apache.wiki.preferences.Preferences.TimeFormat;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.jsp.PageContext;
+import java.io.IOException;
+import java.io.InputStream;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.TimeZone;
+import java.util.TreeSet;
+
+
+/**
+ *  This class takes care of managing JSPWiki templates.  This class also provides the ResourceRequest mechanism.
+ *
+ *  @since 2.1.62
+ */
+public class DefaultTemplateManager extends ModuleManager implements TemplateManager {
+
+    private static final Logger log = Logger.getLogger( DefaultTemplateManager.class );
+
+    /**
+     *  Creates a new TemplateManager.  There is typically one manager per engine.
+     *
+     *  @param engine The owning engine.
+     *  @param properties The property list used to initialize this.
+     */
+    public DefaultTemplateManager( final Engine engine, final Properties properties ) {
+        super( engine );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    // FIXME: Does not work yet
+    public boolean templateExists( final String templateName ) {
+        final ServletContext context = m_engine.getServletContext();
+        try( final InputStream in = context.getResourceAsStream( getPath( templateName ) + "ViewTemplate.jsp" ) ) {
+            if( in != null ) {
+                return true;
+            }
+        } catch( final IOException e ) {
+            log.error( e.getMessage(), e );
+        }
+        return false;
+    }
+
+    /**
+     *  Tries to locate a given resource from the template directory. If the given resource is not found under the current name, returns the
+     *  path to the corresponding one in the default template.
+     *
+     *  @param sContext The servlet context
+     *  @param name The name of the resource
+     *  @return The name of the resource which was found.
+     */
+    private static String findResource( final ServletContext sContext, final String name ) {
+        String resourceName = name;
+        try( final InputStream is = sContext.getResourceAsStream( resourceName ) ) {
+            if( is == null ) {
+                final String defname = makeFullJSPName( DEFAULT_TEMPLATE, removeTemplatePart( resourceName ) );
+                try( final InputStream iis = sContext.getResourceAsStream( defname ) ) {
+                    resourceName = iis != null ? defname : null;
+                }
+            }
+        } catch( final IOException e ) {
+            log.error( "unable to open " + name + " as resource stream", e );
+        }
+        return resourceName;
+    }
+
+    /**
+     *  Attempts to find a resource from the given template, and if it's not found
+     *  attempts to locate it from the default template.
+     * @param sContext servlet context used to search for the resource
+     * @param template template used to search for the resource
+     * @param name resource name
+     * @return the Resource for the given template and name.
+     */
+    private static String findResource( final ServletContext sContext, final String template, final String name ) {
+        if( name.charAt(0) == '/' ) {
+            // This is already a full path
+            return findResource( sContext, name );
+        }
+        final String fullname = makeFullJSPName( template, name );
+        return findResource( sContext, fullname );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String findJSP( final PageContext pageContext, final String name ) {
+        final ServletContext sContext = pageContext.getServletContext();
+        return findResource( sContext, name );
+    }
+
+    /**
+     *  Removes the template part of a name.
+     */
+    private static String removeTemplatePart( String name ) {
+        int idx = 0;
+        if( name.startsWith( "/" ) ) {
+            idx = 1;
+        }
+
+        idx = name.indexOf('/', idx);
+        if( idx != -1 ) {
+            idx = name.indexOf('/', idx+1); // Find second "/"
+            if( idx != -1 ) {
+                name = name.substring( idx+1 );
+            }
+        }
+
+        if( log.isDebugEnabled() ) {
+            log.debug( "Final name = "+name );
+        }
+        return name;
+    }
+
+    /**
+     *  Returns the full name (/templates/foo/bar) for name=bar, template=foo.
+     *
+     * @param template The name of the template.
+     * @param name The name of the resource.
+     * @return The full name for a template.
+     */
+    private static String makeFullJSPName( final String template, final String name ) {
+        return "/" + DIRECTORY + "/" + template + "/" + name;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String findJSP( final PageContext pageContext, final String template, final String name ) {
+        if( name == null || template == null ) {
+            log.fatal("findJSP() was asked to find a null template or name (" + template + "," + name + ")." + " JSP page '" +
+                      ( ( HttpServletRequest )pageContext.getRequest() ).getRequestURI() + "'" );
+            throw new InternalWikiException( "Illegal arguments to findJSP(); please check logs." );
+        }
+
+        return findResource( pageContext.getServletContext(), template, name );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String findResource( final WikiContext ctx, final String template, final String name ) {
+        if( m_engine.getServletContext() != null ) {
+            return findResource( m_engine.getServletContext(), template, name );
+        }
+
+        return getPath(template)+"/"+name;
+    }
+
+    /*
+     *  Returns a property, as defined in the template.  The evaluation is lazy, i.e. the properties are not loaded until the template is
+     *  actually used for the first time.
+     */
+    /*
+    public String getTemplateProperty( WikiContext context, String key )
+    {
+        String template = context.getTemplate();
+
+        try
+        {
+            Properties props = (Properties)m_propertyCache.getFromCache( template, -1 );
+
+            if( props == null )
+            {
+                try
+                {
+                    props = getTemplateProperties( template );
+
+                    m_propertyCache.putInCache( template, props );
+                }
+                catch( IOException e )
+                {
+                    log.warn("IO Exception while reading template properties",e);
+
+                    return null;
+                }
+            }
+
+            return props.getProperty( key );
+        }
+        catch( NeedsRefreshException ex )
+        {
+            // FIXME
+            return null;
+        }
+    }
+*/
+    /**
+     *  Returns an absolute path to a given template.
+     */
+    private static String getPath( final String template ) {
+        return "/" + DIRECTORY + "/" + template + "/";
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Set< String > listSkins( final PageContext pageContext, final String template ) {
+        final String place = makeFullJSPName( template, SKIN_DIRECTORY );
+        final ServletContext sContext = pageContext.getServletContext();
+        final Set< String > skinSet = sContext.getResourcePaths( place );
+        final Set< String > resultSet = new TreeSet<>();
+
+        if( log.isDebugEnabled() ) {
+            log.debug( "Listings skins from " + place );
+        }
+
+        if( skinSet != null ) {
+            final String[] skins = skinSet.toArray( new String[]{} );
+            for( final String skin : skins ) {
+                final String[] s = StringUtils.split( skin, "/" );
+                if( s.length > 2 && skin.endsWith( "/" ) ) {
+                    final String skinName = s[ s.length - 1 ];
+                    resultSet.add( skinName );
+                    if( log.isDebugEnabled() ) {
+                        log.debug( "...adding skin '" + skinName + "'" );
+                    }
+                }
+            }
+        }
+
+        return resultSet;
+    }
+
+
+    /** {@inheritDoc} */
+    @Override
+    public Map< String, String > listTimeFormats( final PageContext pageContext ) {
+        final WikiContext context = WikiContext.findContext( pageContext );
+        final Properties props = m_engine.getWikiProperties();
+        final ArrayList< String > tfArr = new ArrayList<>(40);
+        final LinkedHashMap< String, String > resultMap = new LinkedHashMap<>();
+
+        /* filter timeformat properties */
+        for( final Enumeration< ? > e = props.propertyNames(); e.hasMoreElements(); ) {
+            final String name = ( String )e.nextElement();
+            if( name.startsWith( TIMEFORMATPROPERTIES ) ) {
+                tfArr.add( name );
+            }
+        }
+
+        /* fetch actual formats */
+        if( tfArr.size() == 0 )  {/* no props found - make sure some default formats are avail */
+            tfArr.add( "dd-MMM-yy" );
+            tfArr.add( "d-MMM-yyyy" );
+            tfArr.add( "EEE, dd-MMM-yyyy, zzzz" );
+        } else {
+            Collections.sort( tfArr );
+
+            for (int i = 0; i < tfArr.size(); i++) {
+                tfArr.set(i, props.getProperty(tfArr.get(i)));
+            }
+        }
+
+        final String prefTimeZone = Preferences.getPreference( context, "TimeZone" );
+        final TimeZone tz = TimeZone.getTimeZone( prefTimeZone );
+
+        final Date d = new Date(); // current date
+        try {
+            // dummy format pattern
+            final SimpleDateFormat fmt = Preferences.getDateFormat( context, TimeFormat.DATETIME );
+            fmt.setTimeZone( tz );
+
+            for( final String s : tfArr ) {
+                try {
+                    final String f = s;
+                    fmt.applyPattern( f );
+                    resultMap.put( f, fmt.format( d ) );
+                } catch( final IllegalArgumentException e ) {
+                } // skip parameter
+            }
+        } catch( final IllegalArgumentException e ) {} // skip parameter
+
+        return resultMap;
+    }
+
+    /*
+     *  Always returns a valid property map.
+     */
+    /*
+    private Properties getTemplateProperties( String templateName )
+        throws IOException
+    {
+        Properties p = new Properties();
+
+        ServletContext context = m_engine.getServletContext();
+
+        InputStream propertyStream = context.getResourceAsStream(getPath(templateName)+PROPERTYFILE);
+
+        if( propertyStream != null )
+        {
+            p.load( propertyStream );
+
+            propertyStream.close();
+        }
+        else
+        {
+            log.debug("Template '"+templateName+"' does not have a propertyfile '"+PROPERTYFILE+"'.");
+        }
+
+        return p;
+    }
+*/
+
+    /** {@inheritDoc} */
+    @Override
+    public Collection< WikiModuleInfo > modules() {
+        return new ArrayList<>();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public WikiModuleInfo getModuleInfo( final String moduleName ) {
+    	return null;
+    }
+
+}
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
index 9d173fd..31b0c80 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
@@ -18,24 +18,12 @@
  */
 package org.apache.wiki.ui;
 
-import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.api.core.Engine;
-import org.apache.wiki.api.exceptions.NoSuchVariableException;
-import org.apache.wiki.modules.ModuleManager;
 import org.apache.wiki.modules.WikiModuleInfo;
-import org.apache.wiki.preferences.Preferences;
-import org.apache.wiki.util.XmlUtil;
-import org.apache.wiki.variables.VariableManager;
-import org.jdom2.Element;
 
 import javax.servlet.jsp.PageContext;
 import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
 import java.util.Properties;
-import java.util.Set;
 
 
 /**
@@ -56,68 +44,32 @@ import java.util.Set;
  *
  *  @since 2.4
  */
-public class EditorManager extends ModuleManager {
+public interface EditorManager {
 
     /** The property name for setting the editor. Current value is "jspwiki.editor" - not used anymore: replaced by defaultpref.template.editor */
-    public static final String PROP_EDITORTYPE = "jspwiki.editor";
+    String PROP_EDITORTYPE = "jspwiki.editor";
 
     /** Parameter for changing editors at run-time */
-    public static final String PARA_EDITOR = "editor";
+    String PARA_EDITOR = "editor";
 
     /** Known name for the plain wikimarkup editor. */
-    public static final String EDITOR_PLAIN = "plain";
+    String EDITOR_PLAIN = "plain";
 
     /** Known name for the preview editor component. */
-    public static final String EDITOR_PREVIEW = "preview";
+    String EDITOR_PREVIEW = "preview";
 
     /** Known attribute name for storing the user edited text inside a HTTP parameter. */
-    public static final String REQ_EDITEDTEXT = "_editedtext";
+    String REQ_EDITEDTEXT = "_editedtext";
 
     /** Known attribute name for storing the user edited text inside a session or a page context */
-    public static final String ATTR_EDITEDTEXT = REQ_EDITEDTEXT;
-
-    private Map< String, WikiEditorInfo > m_editors;
-
-    private static final Logger log = Logger.getLogger( EditorManager.class );
-
-    public EditorManager( final Engine engine ) {
-        super( engine );
-    }
+    String ATTR_EDITEDTEXT = REQ_EDITEDTEXT;
 
     /**
      *  Initializes the EditorManager.  It also registers any editors it can find.
      *
      *  @param props  Properties for setup.
      */
-    public void initialize( final Properties props ) {
-        registerEditors();
-    }
-
-    /**
-     *  This method goes through the jspwiki_module.xml files and hunts for editors. Any editors found are put in the registry.
-     */
-    private void registerEditors() {
-        log.info( "Registering editor modules" );
-        m_editors = new HashMap<>();
-
-        //
-        // Register all editors which have created a resource containing its properties.
-        //
-        // Get all resources of all modules
-        //
-        final List< Element > editors = XmlUtil.parse( PLUGIN_RESOURCE_LOCATION, "/modules/editor" );
-        for( final Element pluginEl : editors ) {
-            final String name = pluginEl.getAttributeValue( "name" );
-            final WikiEditorInfo info = WikiEditorInfo.newInstance( name, pluginEl );
-
-            if( checkCompatibility( info ) ) {
-                m_editors.put( name, info );
-                log.debug( "Registered editor " + name );
-            } else {
-                log.info( "Editor '" + name + "' not compatible with this version of JSPWiki." );
-            }
-        }
-    }
+    void initialize( Properties props );
 
     /**
      *  Returns an editor for the current context.  The editor names are matched in a case insensitive manner.  At the moment, the only
@@ -132,46 +84,14 @@ public class EditorManager extends ModuleManager {
      * @param context The context that is chosen.
      * @return The name of the chosen editor. If no match could be found, will revert to the default "plain" editor.
      */
-    public String getEditorName( final WikiContext context ) {
-        if( context.getRequestContext().equals( WikiContext.PREVIEW ) ) {
-            return EDITOR_PREVIEW;
-        }
-
-        // User has set an editor in preferences
-        String editor = Preferences.getPreference( context, PARA_EDITOR );
-
-        /* FIXME: actual default 'editor' property is read by the Preferences class */
-        if( editor == null ) {
-            // or use the default editor in jspwiki.properties
-            try {
-                editor = m_engine.getManager( VariableManager.class ).getValue( context, PROP_EDITORTYPE );
-            } catch( final NoSuchVariableException e ) {} // This is fine
-        }
-
-        if( editor != null ) {
-            final String[] editorlist = getEditorList();
-            editor = editor.trim();
-            for( final String s : editorlist ) {
-                if( s.equalsIgnoreCase( editor ) ) {
-                    return s;
-                }
-            }
-        }
-
-        return EDITOR_PLAIN;
-    }
+    String getEditorName( WikiContext context );
 
     /**
      *  Returns a list of editors as Strings of editor names.
      *
      *  @return the list of available editors
      */
-    public String[] getEditorList() {
-        final String[] editors = new String[ m_editors.size() ];
-        final Set< String > keys = m_editors.keySet();
-
-        return keys.toArray( editors );
-    }
+    String[] getEditorList();
 
     /**
      *  Convenience method for getting the path to the editor JSP file.
@@ -179,18 +99,7 @@ public class EditorManager extends ModuleManager {
      *  @param context WikiContext from where the editor name is retrieved.
      *  @return e.g. "editors/plain.jsp"
      */
-    public String getEditorPath( final WikiContext context ) {
-        final String editor = getEditorName( context );
-        final WikiEditorInfo ed = m_editors.get( editor );
-        final String path;
-        if( ed != null ) {
-            path = ed.getPath();
-        } else {
-            path = "editors/"+editor+".jsp";
-        }
-
-        return path;
-    }
+    String getEditorPath( WikiContext context );
 
     /**
      *  Convenience function which examines the current context and attempts to figure out whether the edited text is in the HTTP
@@ -199,7 +108,7 @@ public class EditorManager extends ModuleManager {
      *  @param ctx the JSP page context
      *  @return the edited text, if present in the session page context or as a parameter
      */
-    public static String getEditedText( final PageContext ctx ) {
+    static String getEditedText( final PageContext ctx ) {
         String usertext = ctx.getRequest().getParameter( REQ_EDITEDTEXT );
         if( usertext == null ) {
             usertext = ( String )ctx.findAttribute( ATTR_EDITEDTEXT );
@@ -208,48 +117,13 @@ public class EditorManager extends ModuleManager {
         return usertext;
     }
 
-    /**  Contains info about an editor. */
-    private static final class WikiEditorInfo extends WikiModuleInfo {
-        private String m_path;
-
-        protected static WikiEditorInfo newInstance( final String name, final Element el ) {
-            if( name == null || name.length() == 0 ) {
-                return null;
-            }
-            final WikiEditorInfo info = new WikiEditorInfo( name );
-            info.initializeFromXML( el );
-            return info;
-        }
-
-        @Override
-        protected void initializeFromXML( final Element el ) {
-            super.initializeFromXML( el );
-            m_path = el.getChildText("path");
-        }
-
-        private WikiEditorInfo( final String name ) {
-            super( name );
-        }
-
-        public String getPath() {
-            return m_path;
-        }
-    }
-
     /**
-     *  {@inheritDoc}
-     */
-    @Override
-    public Collection< WikiModuleInfo > modules() {
-        return modules( m_editors.values().iterator() );
-    }
-
-    /**
-     *  {@inheritDoc}
+     * Returns a collection of modules currently managed by this ModuleManager.  Each
+     * entry is an instance of the WikiModuleInfo class.  This method should return something
+     * which is safe to iterate over, even if the underlying collection changes.
+     *
+     * @return A Collection of WikiModuleInfo instances.
      */
-    @Override
-    public WikiEditorInfo getModuleInfo( final String moduleName ) {
-        return m_editors.get( moduleName );
-    }
+    Collection< WikiModuleInfo > modules();
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
index 68441f9..57114d1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/TemplateManager.java
@@ -18,40 +18,25 @@
  */
 package org.apache.wiki.ui;
 
-import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
-import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.i18n.InternationalizationManager;
-import org.apache.wiki.modules.ModuleManager;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.preferences.Preferences;
-import org.apache.wiki.preferences.Preferences.TimeFormat;
 import org.apache.wiki.util.ClassUtil;
 
-import javax.servlet.ServletContext;
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.jsp.PageContext;
 import javax.servlet.jsp.jstl.fmt.LocaleSupport;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
 import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
-import java.util.Properties;
 import java.util.ResourceBundle;
 import java.util.Set;
 import java.util.TimeZone;
-import java.util.TreeSet;
 import java.util.Vector;
 
 
@@ -60,132 +45,62 @@ import java.util.Vector;
  *
  *  @since 2.1.62
  */
-public class TemplateManager extends ModuleManager {
+public interface TemplateManager {
 
-    private static final String SKIN_DIRECTORY = "skins";
+    String SKIN_DIRECTORY = "skins";
 
     /** Requests a JavaScript function to be called during window.onload. Value is {@value}. */
-    public static final String RESOURCE_JSFUNCTION = "jsfunction";
+    String RESOURCE_JSFUNCTION = "jsfunction";
 
     /** Requests a JavaScript associative array with all localized strings. */
-    public static final String RESOURCE_JSLOCALIZEDSTRINGS = "jslocalizedstrings";
+    String RESOURCE_JSLOCALIZEDSTRINGS = "jslocalizedstrings";
 
     /** Requests a stylesheet to be inserted. Value is {@value}. */
-    public static final String RESOURCE_STYLESHEET = "stylesheet";
+    String RESOURCE_STYLESHEET = "stylesheet";
 
     /** Requests a script to be loaded. Value is {@value}. */
-    public static final String RESOURCE_SCRIPT = "script";
+    String RESOURCE_SCRIPT = "script";
 
     /** Requests inlined CSS. Value is {@value}. */
-    public static final String RESOURCE_INLINECSS = "inlinecss";
+    String RESOURCE_INLINECSS = "inlinecss";
 
     /** The default directory for the properties. Value is {@value}. */
-    public static final String DIRECTORY = "templates";
+    String DIRECTORY = "templates";
 
     /** The name of the default template. Value is {@value}. */
-    public static final String DEFAULT_TEMPLATE = "default";
+    String DEFAULT_TEMPLATE = "default";
 
     /** Name of the file that contains the properties. */
-    public static final String PROPERTYFILE = "template.properties";
+    String PROPERTYFILE = "template.properties";
 
     /** Location of I18N Resource bundles, and path prefix and suffixes */
-    public static final String I18NRESOURCE_PREFIX = "templates/default_";
+    String I18NRESOURCE_PREFIX = "templates/default_";
 
-    public static final String I18NRESOURCE_SUFFIX = ".properties";
+    String I18NRESOURCE_SUFFIX = ".properties";
 
     /** The default (en) RESOURCE name and id. */
-    public static final String I18NRESOURCE_EN = "templates/default.properties";
-    public static final String I18NRESOURCE_EN_ID = "en";
+    String I18NRESOURCE_EN = "templates/default.properties";
+    String I18NRESOURCE_EN_ID = "en";
 
     /** I18N string to mark the default locale */
-    public static final String I18NDEFAULT_LOCALE = "prefs.user.language.default";
+    String I18NDEFAULT_LOCALE = "prefs.user.language.default";
 
     /** I18N string to mark the server timezone */
-    public static final String I18NSERVER_TIMEZONE = "prefs.user.timezone.server";
+    String I18NSERVER_TIMEZONE = "prefs.user.timezone.server";
 
     /** Prefix of the default timeformat properties. */
-    public static final String TIMEFORMATPROPERTIES = "jspwiki.defaultprefs.timeformat.";
+    String TIMEFORMATPROPERTIES = "jspwiki.defaultprefs.timeformat.";
 
     /** The name under which the resource includes map is stored in the  WikiContext. */
-    public static final String RESOURCE_INCLUDES = "jspwiki.resourceincludes";
-
-    // private Cache m_propertyCache;
-
-    private static final Logger log = Logger.getLogger( TemplateManager.class );
+    String RESOURCE_INCLUDES = "jspwiki.resourceincludes";
 
     /** Requests a HTTP header. Value is {@value}. */
-    public static final String RESOURCE_HTTPHEADER = "httpheader";
-
-    /**
-     *  Creates a new TemplateManager.  There is typically one manager per engine.
-     *
-     *  @param engine The owning engine.
-     *  @param properties The property list used to initialize this.
-     */
-    public TemplateManager( final Engine engine, final Properties properties ) {
-        super( engine );
-
-        //
-        //  Uses the unlimited cache.
-        //
-        // m_propertyCache = new Cache( true, false );
-    }
+    String RESOURCE_HTTPHEADER = "httpheader";
 
     /**
      *  Check the existence of a template.
      */
-    // FIXME: Does not work yet
-    public boolean templateExists( final String templateName ) {
-        final ServletContext context = m_engine.getServletContext();
-        try( final InputStream in = context.getResourceAsStream( getPath( templateName ) + "ViewTemplate.jsp" ) ) {
-            if( in != null ) {
-                return true;
-            }
-        } catch( final IOException e ) {
-            log.error( e.getMessage(), e );
-        }
-        return false;
-    }
-
-    /**
-     *  Tries to locate a given resource from the template directory. If the given resource is not found under the current name, returns the
-     *  path to the corresponding one in the default template.
-     *
-     *  @param sContext The servlet context
-     *  @param name The name of the resource
-     *  @return The name of the resource which was found.
-     */
-    private static String findResource( final ServletContext sContext, final String name ) {
-        String resourceName = name;
-        try( final InputStream is = sContext.getResourceAsStream( resourceName ) ) {
-            if( is == null ) {
-                final String defname = makeFullJSPName( DEFAULT_TEMPLATE, removeTemplatePart( resourceName ) );
-                try( final InputStream iis = sContext.getResourceAsStream( defname ) ) {
-                    resourceName = iis != null ? defname : null;
-                }
-            }
-        } catch( final IOException e ) {
-            log.error( "unable to open " + name + " as resource stream", e );
-        }
-        return resourceName;
-    }
-
-    /**
-     *  Attempts to find a resource from the given template, and if it's not found
-     *  attempts to locate it from the default template.
-     * @param sContext
-     * @param template
-     * @param name
-     * @return the Resource for the given template and name.
-     */
-    private static String findResource( final ServletContext sContext, final String template, final String name ) {
-        if( name.charAt(0) == '/' ) {
-            // This is already a full path
-            return findResource( sContext, name );
-        }
-        final String fullname = makeFullJSPName( template, name );
-        return findResource( sContext, fullname );
-    }
+    boolean templateExists( String templateName );
 
     /**
      *  An utility method for finding a JSP page.  It searches only under either current context or by the absolute name.
@@ -194,44 +109,7 @@ public class TemplateManager extends ModuleManager {
      *  @param name The name of the JSP page to look for (e.g "Wiki.jsp")
      *  @return The context path to the resource
      */
-    public String findJSP( final PageContext pageContext, final String name ) {
-        final ServletContext sContext = pageContext.getServletContext();
-        return findResource( sContext, name );
-    }
-
-    /**
-     *  Removes the template part of a name.
-     */
-    private static String removeTemplatePart( String name ) {
-        int idx = 0;
-        if( name.startsWith( "/" ) ) {
-            idx = 1;
-        }
-
-        idx = name.indexOf('/', idx);
-        if( idx != -1 ) {
-            idx = name.indexOf('/', idx+1); // Find second "/"
-            if( idx != -1 ) {
-                name = name.substring( idx+1 );
-            }
-        }
-
-        if( log.isDebugEnabled() ) {
-            log.debug( "Final name = "+name );
-        }
-        return name;
-    }
-
-    /**
-     *  Returns the full name (/templates/foo/bar) for name=bar, template=foo.
-     *
-     * @param template The name of the template.
-     * @param name The name of the resource.
-     * @return The full name for a template.
-     */
-    private static String makeFullJSPName( final String template, final String name ) {
-        return "/" + DIRECTORY + "/" + template + "/" + name;
-    }
+    String findJSP( PageContext pageContext, String name );
 
     /**
      *  Attempts to locate a resource under the given template.  If that template does not exist, or the page does not exist under that
@@ -244,15 +122,7 @@ public class TemplateManager extends ModuleManager {
      *  @param name Which resource are we looking for (e.g. "ViewTemplate.jsp")
      *  @return path to the JSP page; null, if it was not found.
      */
-    public String findJSP( final PageContext pageContext, final String template, final String name ) {
-        if( name == null || template == null ) {
-            log.fatal("findJSP() was asked to find a null template or name (" + template + "," + name + ")." + " JSP page '" +
-                      ( ( HttpServletRequest )pageContext.getRequest() ).getRequestURI() + "'" );
-            throw new InternalWikiException( "Illegal arguments to findJSP(); please check logs." );
-        }
-
-        return findResource( pageContext.getServletContext(), template, name );
-    }
+    String findJSP( PageContext pageContext, String template, String name );
 
     /**
      *  Attempts to locate a resource under the given template.  This matches the functionality findJSP(), but uses the WikiContext as
@@ -266,58 +136,7 @@ public class TemplateManager extends ModuleManager {
      *  @param name the name of the resource to fine
      *  @return the path to the resource
      */
-    public String findResource( final WikiContext ctx, final String template, final String name ) {
-        if( m_engine.getServletContext() != null ) {
-            return findResource( m_engine.getServletContext(), template, name );
-        }
-
-        return getPath(template)+"/"+name;
-    }
-
-    /**
-     *  Returns a property, as defined in the template.  The evaluation is lazy, i.e. the properties are not loaded until the template is
-     *  actually used for the first time.
-     */
-    /*
-    public String getTemplateProperty( WikiContext context, String key )
-    {
-        String template = context.getTemplate();
-
-        try
-        {
-            Properties props = (Properties)m_propertyCache.getFromCache( template, -1 );
-
-            if( props == null )
-            {
-                try
-                {
-                    props = getTemplateProperties( template );
-
-                    m_propertyCache.putInCache( template, props );
-                }
-                catch( IOException e )
-                {
-                    log.warn("IO Exception while reading template properties",e);
-
-                    return null;
-                }
-            }
-
-            return props.getProperty( key );
-        }
-        catch( NeedsRefreshException ex )
-        {
-            // FIXME
-            return null;
-        }
-    }
-*/
-    /**
-     *  Returns an absolute path to a given template.
-     */
-    private static String getPath( final String template ) {
-        return "/" + DIRECTORY + "/" + template + "/";
-    }
+    String findResource( WikiContext ctx, String template, String name );
 
     /**
      *   Lists the skins available under this template.  Returns an empty Set, if there are no extra skins available.  Note that
@@ -329,43 +148,18 @@ public class TemplateManager extends ModuleManager {
      *   @return Set of Strings with the skin names.
      *   @since 2.3.26
      */
-    public Set< String > listSkins( final PageContext pageContext, final String template ) {
-        final String place = makeFullJSPName( template, SKIN_DIRECTORY );
-        final ServletContext sContext = pageContext.getServletContext();
-        final Set< String > skinSet = sContext.getResourcePaths( place );
-        final Set< String > resultSet = new TreeSet<>();
-
-        if( log.isDebugEnabled() ) {
-            log.debug( "Listings skins from " + place );
-        }
-
-        if( skinSet != null ) {
-            final String[] skins = skinSet.toArray( new String[]{} );
-            for( final String skin : skins ) {
-                final String[] s = StringUtils.split( skin, "/" );
-                if( s.length > 2 && skin.endsWith( "/" ) ) {
-                    final String skinName = s[ s.length - 1 ];
-                    resultSet.add( skinName );
-                    if( log.isDebugEnabled() ) {
-                        log.debug( "...adding skin '" + skinName + "'" );
-                    }
-                }
-            }
-        }
-
-        return resultSet;
-    }
+    Set< String > listSkins( PageContext pageContext, String template );
 
     /**
      * List all installed i18n language properties by classpath searching for files like :
      *    templates/default_*.properties
      *    templates/default.properties
      *
-     * @param pageContext
+     * @param pageContext page context
      * @return map of installed Languages
      * @since 2.7.x
      */
-    public Map< String, String > listLanguages( final PageContext pageContext ) {
+    default Map< String, String > listLanguages( final PageContext pageContext ) {
         final Map< String, String > resultMap = new LinkedHashMap<>();
         final String clientLanguage = pageContext.getRequest().getLocale().toString();
         final List< String > entries = ClassUtil.classpathEntriesUnder( DIRECTORY );
@@ -376,7 +170,7 @@ public class TemplateManager extends ModuleManager {
                 } else {
                     name = name.substring( I18NRESOURCE_PREFIX.length(), name.lastIndexOf( I18NRESOURCE_SUFFIX ) );
                 }
-                final Locale locale = new Locale( name.substring( 0, 2 ), ( ( name.indexOf( "_" ) == -1 ) ? "" : name.substring( 3, 5 ) ) );
+                final Locale locale = new Locale( name.substring( 0, 2 ), !name.contains( "_" ) ? "" : name.substring( 3, 5 ) );
                 String defaultLanguage = "";
                 if( clientLanguage.startsWith( name ) ) {
                     defaultLanguage = LocaleSupport.getLocalizedMessage( pageContext, I18NDEFAULT_LOCALE );
@@ -392,76 +186,30 @@ public class TemplateManager extends ModuleManager {
     /**
      * List all available timeformats, read from the jspwiki.properties
      *
-     * @param pageContext
+     * @param pageContext page context
      * @return map of TimeFormats
      * @since 2.7.x
      */
-    public Map< String, String > listTimeFormats( final PageContext pageContext ) {
-        final WikiContext context = WikiContext.findContext( pageContext );
-        final Properties props = m_engine.getWikiProperties();
-        final ArrayList< String > tfArr = new ArrayList<>(40);
-        final LinkedHashMap< String, String > resultMap = new LinkedHashMap<>();
-
-        /* filter timeformat properties */
-        for( final Enumeration< ? > e = props.propertyNames(); e.hasMoreElements(); ) {
-            final String name = ( String )e.nextElement();
-            if( name.startsWith( TIMEFORMATPROPERTIES ) ) {
-                tfArr.add( name );
-            }
-        }
-
-        /* fetch actual formats */
-        if( tfArr.size() == 0 )  {/* no props found - make sure some default formats are avail */
-            tfArr.add( "dd-MMM-yy" );
-            tfArr.add( "d-MMM-yyyy" );
-            tfArr.add( "EEE, dd-MMM-yyyy, zzzz" );
-        } else {
-            Collections.sort( tfArr );
-
-            for (int i = 0; i < tfArr.size(); i++) {
-                tfArr.set(i, props.getProperty(tfArr.get(i)));
-            }
-        }
-
-        final String prefTimeZone = Preferences.getPreference( context, "TimeZone" );
-        //TimeZone tz = TimeZone.getDefault();
-        final TimeZone tz = TimeZone.getTimeZone(prefTimeZone);
-        /*try
-        {
-            tz.setRawOffset(Integer.parseInt(prefTimeZone));
-        }
-        catch (Exception e)
-        {
-        }*/
-
-        final Date d = new Date(); // current date
-        try {
-            // dummy format pattern
-            final SimpleDateFormat fmt = Preferences.getDateFormat( context, TimeFormat.DATETIME );
-            fmt.setTimeZone( tz );
-
-            for( int i = 0; i < tfArr.size(); i++ ) {
-                try {
-                    final String f = tfArr.get( i );
-                    fmt.applyPattern( f );
-                    resultMap.put( f, fmt.format( d ) );
-                } catch( final IllegalArgumentException e ) {} // skip parameter
-            }
-        }
-        catch( final IllegalArgumentException e ) {} // skip parameter
+    Map< String, String > listTimeFormats( final PageContext pageContext );
 
-        return resultMap;
-    }
+    /**
+     * Returns a collection of modules currently managed by this ModuleManager.  Each
+     * entry is an instance of the WikiModuleInfo class.  This method should return something
+     * which is safe to iterate over, even if the underlying collection changes.
+     *
+     * @return A Collection of WikiModuleInfo instances.
+     */
+    Collection< WikiModuleInfo > modules();
 
     /**
      * List all timezones, with special marker for server timezone
      *
-     * @param pageContext
+     * @param pageContext page context
      * @return map of TimeZones
      * @since 2.7.x
      */
-    public Map< String, String > listTimeZones( final PageContext pageContext ) {
-        final Map<String,String> resultMap = new LinkedHashMap<>();
+    default Map< String, String > listTimeZones( final PageContext pageContext ) {
+        final Map< String, String > resultMap = new LinkedHashMap<>();
         final String[][] tzs = {
                           { "GMT-12", "Enitwetok, Kwajalien" },
                           { "GMT-11", "Nome, Midway Island, Samoa" },
@@ -511,33 +259,6 @@ public class TemplateManager extends ModuleManager {
     }
 
     /**
-     *  Always returns a valid property map.
-     */
-    /*
-    private Properties getTemplateProperties( String templateName )
-        throws IOException
-    {
-        Properties p = new Properties();
-
-        ServletContext context = m_engine.getServletContext();
-
-        InputStream propertyStream = context.getResourceAsStream(getPath(templateName)+PROPERTYFILE);
-
-        if( propertyStream != null )
-        {
-            p.load( propertyStream );
-
-            propertyStream.close();
-        }
-        else
-        {
-            log.debug("Template '"+templateName+"' does not have a propertyfile '"+PROPERTYFILE+"'.");
-        }
-
-        return p;
-    }
-*/
-    /**
      *  Returns the include resources marker for a given type.  This is in a
      *  HTML or Javascript comment format.
      *
@@ -545,7 +266,7 @@ public class TemplateManager extends ModuleManager {
      *  @param type the marker
      *  @return the generated marker comment
      */
-    public static String getMarker( final WikiContext context, final String type ) {
+    static String getMarker( final WikiContext context, final String type ) {
         if( type.equals( RESOURCE_JSLOCALIZEDSTRINGS ) ) {
             return getJSLocalizedStrings( context );
         } else if( type.equals( RESOURCE_JSFUNCTION ) ) {
@@ -561,7 +282,7 @@ public class TemplateManager extends ModuleManager {
      *  @return Javascript snippet which defines the LocalizedStrings array
      *  @since 2.5.108
      */
-    private static String getJSLocalizedStrings( final WikiContext context ) {
+    static String getJSLocalizedStrings( final WikiContext context ) {
         final StringBuilder sb = new StringBuilder();
         sb.append( "var LocalizedStrings = {\n");
         final ResourceBundle rb = Preferences.getBundle( context, InternationalizationManager.DEF_TEMPLATE );
@@ -575,7 +296,7 @@ public class TemplateManager extends ModuleManager {
                 } else {
                     sb.append( ",\n" );
                 }
-                sb.append( "\""+key+"\":\""+rb.getString(key)+"\"" );
+                sb.append( "\"" ).append( key ).append( "\":\"" ).append( rb.getString( key ) ).append( "\"" );
             }
         }
         sb.append("\n};\n");
@@ -604,7 +325,7 @@ public class TemplateManager extends ModuleManager {
      *  @param resource The resource to add.
      */
     @SuppressWarnings("unchecked")
-    public static void addResourceRequest( final WikiContext ctx, final String type, final String resource ) {
+    static void addResourceRequest( final WikiContext ctx, final String type, final String resource ) {
         HashMap< String, Vector< String > > resourcemap = ( HashMap< String, Vector< String > > ) ctx.getVariable( RESOURCE_INCLUDES );
         if( resourcemap == null ) {
             resourcemap = new HashMap<>();
@@ -636,7 +357,7 @@ public class TemplateManager extends ModuleManager {
             resources.add( resourceString );
         }
 
-        log.debug( "Request to add a resource: " + resourceString );
+        Logger.getLogger( TemplateManager.class ).debug( "Request to add a resource: " + resourceString );
 
         resourcemap.put( type, resources );
         ctx.setVariable( RESOURCE_INCLUDES, resourcemap );
@@ -650,7 +371,7 @@ public class TemplateManager extends ModuleManager {
      *  @return a String array for the resource requests
      */
     @SuppressWarnings("unchecked")
-    public static String[] getResourceRequests( final WikiContext ctx, final String type ) {
+    static String[] getResourceRequests( final WikiContext ctx, final String type ) {
         final HashMap< String, Vector< String > > hm = ( HashMap< String, Vector< String > > ) ctx.getVariable( RESOURCE_INCLUDES );
         if( hm == null ) {
             return new String[0];
@@ -672,7 +393,7 @@ public class TemplateManager extends ModuleManager {
      * @return the array of types requested
      */
     @SuppressWarnings("unchecked")
-    public static String[] getResourceTypes( final WikiContext ctx ) {
+    static String[] getResourceTypes( final WikiContext ctx ) {
         String[] res = new String[0];
         if( ctx != null ) {
             final HashMap< String, String > hm = ( HashMap< String, String > ) ctx.getVariable( RESOURCE_INCLUDES );
@@ -685,23 +406,4 @@ public class TemplateManager extends ModuleManager {
         return res;
     }
 
-    /**
-     *  Returns an empty collection, since at the moment the TemplateManager does not manage any modules.
-     *
-     *  @return {@inheritDoc}
-     */
-    @Override
-    public Collection< WikiModuleInfo > modules() {
-        return new ArrayList<>();
-    }
-
-    /**
-     *  Returns null!
-     *  {@inheritDoc}
-     */
-    @Override
-    public WikiModuleInfo getModuleInfo( final String moduleName ) {
-    	return null;
-    }
-
 }
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index da8d88f..a1817fb 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -97,7 +97,7 @@
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.i18n.InternationalizationManager</requestedClass>
-    <mappedClass>org.apache.wiki.i18n.InternationalizationManager</mappedClass>
+    <mappedClass>org.apache.wiki.i18n.DefaultInternationalizationManager</mappedClass>
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.references.ReferenceManager</requestedClass>
@@ -109,7 +109,7 @@
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.search.SearchManager</requestedClass>
-    <mappedClass>org.apache.wiki.search.SearchManager</mappedClass>
+    <mappedClass>org.apache.wiki.search.DefaultSearchManager</mappedClass>
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.tasks.TasksManager</requestedClass>
@@ -121,11 +121,11 @@
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.ui.EditorManager</requestedClass>
-    <mappedClass>org.apache.wiki.ui.EditorManager</mappedClass>
+    <mappedClass>org.apache.wiki.ui.DefaultEditorManager</mappedClass>
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.ui.TemplateManager</requestedClass>
-    <mappedClass>org.apache.wiki.ui.TemplateManager</mappedClass>
+    <mappedClass>org.apache.wiki.ui.DefaultTemplateManager</mappedClass>
   </mapping>
   <mapping>
     <requestedClass>org.apache.wiki.ui.progress.ProgressManager</requestedClass>
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/i18n/InternationalizationManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/i18n/InternationalizationManagerTest.java
index a397fea..7ede665 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/i18n/InternationalizationManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/i18n/InternationalizationManagerTest.java
@@ -17,17 +17,15 @@
     under the License.    
  */
 package org.apache.wiki.i18n;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
-
 import org.junit.jupiter.api.Test;
 
 import java.util.Locale;
 
-import org.junit.jupiter.api.Assertions;
-
 public class InternationalizationManagerTest
 {
-    InternationalizationManager i18n = new InternationalizationManager( null );
+    InternationalizationManager i18n = new DefaultInternationalizationManager( null );
     
     @BeforeEach
     public void setUp() throws Exception
@@ -41,7 +39,7 @@ public class InternationalizationManagerTest
     @Test
     public void testGetFromCoreWithArgs() 
     {
-        String str = i18n.get( InternationalizationManager.CORE_BUNDLE, 
+        final String str = i18n.get( InternationalizationManager.CORE_BUNDLE,
                                Locale.ENGLISH, 
                                "security.error.cannot.rename", 
                                "Test User" );
@@ -51,7 +49,7 @@ public class InternationalizationManagerTest
     @Test
     public void testGetFromDefTemplateWithArgs() 
     {
-        String str = i18n.get( InternationalizationManager.DEF_TEMPLATE, 
+        final String str = i18n.get( InternationalizationManager.DEF_TEMPLATE,
                                Locale.ENGLISH, 
                                "notification.createUserProfile.accept.content", 
                                "JSPWiki", "testUser", "Test User", "test@user.com", "www.foo.com" );


[jspwiki] 14/20: apply format & 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 2c5995b9e983a5570b57c38811cc33fddf549051
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 20:28:23 2020 +0100

    apply format & fixes suggested by intellij
---
 .../java/org/apache/wiki/workflow/Workflow.java    | 576 ++++++++-------------
 1 file changed, 211 insertions(+), 365 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/Workflow.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/Workflow.java
index 3a0883b..2cdda87 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/Workflow.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/Workflow.java
@@ -35,175 +35,134 @@ import java.util.Map;
 
 /**
  * <p>
- * Sequence of {@link Step} objects linked together. Workflows are always
- * initialized with a message key that denotes the name of the Workflow, and a
- * Principal that represents its owner.
+ * Sequence of {@link Step} objects linked together. Workflows are always initialized with a message key that denotes the name of the
+ * Workflow, and a Principal that represents its owner.
  * </p>
  * <h2>Workflow lifecycle</h2>
- * A Workflow's state (obtained by {@link #getCurrentState()}) will be one of the
- * following:
+ * A Workflow's state (obtained by {@link #getCurrentState()}) will be one of the following:
  * </p>
  * <ul>
- * <li><strong>{@link #CREATED}</strong>: after the Workflow has been
- * instantiated, but before it has been started using the {@link #start()}
+ * <li><strong>{@link #CREATED}</strong>: after the Workflow has been instantiated, but before it has been started using the {@link #start()}
  * method.</li>
- * <li><strong>{@link #RUNNING}</strong>: after the Workflow has been started
- * using the {@link #start()} method, but before it has finished processing all
- * Steps. Note that a Workflow can only be started once; attempting to start it
- * again results in an IllegalStateException. Callers can place the Workflow
- * into the WAITING state by calling {@link #waitstate()}.</li>
- * <li><strong>{@link #WAITING}</strong>: when the Workflow has temporarily
- * paused, for example because of a pending Decision. Once the responsible actor
- * decides what to do, the caller can change the Workflow back to the RUNNING
- * state by calling the {@link #restart()} method (this is done automatically by
- * the Decision class, for instance, when the {@link Decision#decide(Outcome)}
- * method is invoked)</li>
- * <li><strong>{@link #COMPLETED}</strong>: after the Workflow has finished
- * processing all Steps, without errors.</li>
- * <li><strong>{@link #ABORTED}</strong>: if a Step has elected to abort the
- * Workflow.</li>
+ * <li><strong>{@link #RUNNING}</strong>: after the Workflow has been started using the {@link #start()} method, but before it has
+ * finished processing all Steps. Note that a Workflow can only be started once; attempting to start it again results in an
+ * IllegalStateException. Callers can place the Workflow into the WAITING state by calling {@link #waitstate()}.</li>
+ * <li><strong>{@link #WAITING}</strong>: when the Workflow has temporarily paused, for example because of a pending Decision. Once the
+ * responsible actor decides what to do, the caller can change the Workflow back to the RUNNING state by calling the {@link #restart()}
+ * method (this is done automatically by the Decision class, for instance, when the {@link Decision#decide(Outcome)} method is invoked)</li>
+ * <li><strong>{@link #COMPLETED}</strong>: after the Workflow has finished processing all Steps, without errors.</li>
+ * <li><strong>{@link #ABORTED}</strong>: if a Step has elected to abort the Workflow.</li>
  * </ul>
  * <h2>Steps and processing algorithm</h2>
  * <p>
- * Workflow Step objects can be of type {@link Decision}, {@link Task} or other
- * Step subclasses. Decisions require user input, while Tasks do not. See the
- * {@link Step} class for more details.
+ * Workflow Step objects can be of type {@link Decision}, {@link Task} or other Step subclasses. Decisions require user input, while Tasks
+ * do not. See the {@link Step} class for more details.
  * </p>
  * <p>
- * After instantiating a new Workflow (but before telling it to {@link #start()}),
- * calling classes should specify the first Step by executing the
- * {@link #setFirstStep(Step)} method. Additional Steps can be chained by
- * invoking the first step's {@link Step#addSuccessor(Outcome, Step)} method.
+ * After instantiating a new Workflow (but before telling it to {@link #start()}), calling classes should specify the first Step by
+ * executing the {@link #setFirstStep(Step)} method. Additional Steps can be chained by invoking the first step's
+ * {@link Step#addSuccessor(Outcome, Step)} method.
  * </p>
  * <p>
- * When a Workflow's <code>start</code> method is invoked, the Workflow
- * retrieves the first Step and processes it. This Step, and subsequent ones,
- * are processed as follows:
+ * When a Workflow's <code>start</code> method is invoked, the Workflow retrieves the first Step and processes it. This Step, and subsequent
+ * ones, are processed as follows:
  * </p>
  * <ul>
- * <li>The Step's {@link Step#start()} method executes, which sets the start
- * time.</li>
- * <li>The Step's {@link Step#execute()} method is called to begin processing,
- * which will return an Outcome to indicate completion, continuation or errors:</li>
+ * <li>The Step's {@link Step#start()} method executes, which sets the start time.</li>
+ * <li>The Step's {@link Step#execute()} method is called to begin processing, which will return an Outcome to indicate completion,
+ * continuation or errors:</li>
  * <ul>
- * <li>{@link Outcome#STEP_COMPLETE} indicates that the execution method ran
- * without errors, and that the Step should be considered "completed."</li>
- * <li>{@link Outcome#STEP_CONTINUE} indicates that the execution method ran
- * without errors, but that the Step is not "complete" and should be put into
- * the WAITING state.</li>
- * <li>{@link Outcome#STEP_ABORT} indicates that the execution method
- * encountered errors, and should abort the Step <em>and</em> the Workflow as
- * a whole. When this happens, the Workflow will set the current Step's Outcome
- * to {@link Outcome#STEP_ABORT} and invoke the Workflow's {@link #abort()}
- * method. The Step's processing errors, if any, can be retrieved by
- * {@link Step#getErrors()}.</li>
+ * <li>{@link Outcome#STEP_COMPLETE} indicates that the execution method ran without errors, and that the Step should be considered
+ * "completed."</li>
+ * <li>{@link Outcome#STEP_CONTINUE} indicates that the execution method ran without errors, but that the Step is not "complete" and should
+ * be put into the WAITING state.</li>
+ * <li>{@link Outcome#STEP_ABORT} indicates that the execution method encountered errors, and should abort the Step <em>and</em> the
+ * Workflow as a whole. When this happens, the Workflow will set the current Step's Outcome to {@link Outcome#STEP_ABORT} and invoke the
+ * Workflow's {@link #abort()} method. The Step's processing errors, if any, can be retrieved by {@link Step#getErrors()}.</li>
  * </ul>
- * <li>The Outcome of the <code>execute</code> method also affects what
- * happens next. Depending on the result (and assuming the Step did not abort),
- * the Workflow will either move on to the next Step or put the Workflow into
- * the {@link Workflow#WAITING} state:</li>
+ * <li>The Outcome of the <code>execute</code> method also affects what happens next. Depending on the result (and assuming the Step did
+ * not abort), the Workflow will either move on to the next Step or put the Workflow into the {@link Workflow#WAITING} state:</li>
  * <ul>
- * <li>If the Outcome denoted "completion" (<em>i.e.</em>, its
- * {@link Step#isCompleted()} method returns <code>true</code>) then the Step
- * is considered complete; the Workflow looks up the next Step by calling the
- * current Step's {@link Step#getSuccessor(Outcome)} method. If
- * <code>successor()</code> returns a non-<code>null</code> Step, the
- * return value is marked as the current Step and added to the Workflow's Step
- * history. If <code>successor()</code> returns <code>null</code>, then the
- * Workflow has no more Steps and it enters the {@link #COMPLETED} state.</li>
- * <li>If the Outcome did not denote "completion" (<em>i.e.</em>, its
- * {@link Step#isCompleted()} method returns <code>false</code>), then the
- * Step still has further work to do. The Workflow enters the {@link #WAITING}
- * state and stops further processing until a caller restarts it.</li>
+ * <li>If the Outcome denoted "completion" (<em>i.e.</em>, its {@link Step#isCompleted()} method returns <code>true</code>) then the Step
+ * is considered complete; the Workflow looks up the next Step by calling the current Step's {@link Step#getSuccessor(Outcome)} method. If
+ * <code>successor()</code> returns a non-<code>null</code> Step, the return value is marked as the current Step and added to the Workflow's
+ * Step history. If <code>successor()</code> returns <code>null</code>, then the Workflow has no more Steps and it enters the
+ * {@link #COMPLETED} state.</li>
+ * <li>If the Outcome did not denote "completion" (<em>i.e.</em>, its {@link Step#isCompleted()} method returns <code>false</code>), then
+ * the Step still has further work to do. The Workflow enters the {@link #WAITING} state and stops further processing until a caller
+ * restarts it.</li>
  * </ul>
  * </ul>
  * </p>
  * <p>
- * The currently executing Step can be obtained by {@link #getCurrentStep()}. The
- * actor for the current Step is returned by {@link #getCurrentActor()}.
+ * The currently executing Step can be obtained by {@link #getCurrentStep()}. The actor for the current Step is returned by
+ * {@link #getCurrentActor()}.
  * </p>
  * <p>
- * To provide flexibility for specific implementations, the Workflow class
- * provides two additional features that enable Workflow participants (<em>i.e.</em>,
- * Workflow subclasses and Step/Task/Decision subclasses) to share context and
- * state information. These two features are <em>named attributes</em> and
- * <em>message arguments</em>:
+ * To provide flexibility for specific implementations, the Workflow class provides two additional features that enable Workflow
+ * participants (<em>i.e.</em>, Workflow subclasses and Step/Task/Decision subclasses) to share context and state information. These two
+ * features are <em>named attributes</em> and <em>message arguments</em>:
  * </p>
  * <ul>
- * <li><strong>Named attributes</strong> are simple key-value pairs that
- * Workflow participants can get or set. Keys are Strings; values can be any
- * Object. Named attributes are set with {@link #setAttribute(String, Object)}
- * and retrieved with {@link #getAttribute(String)}.</li>
- * <li><strong>Message arguments</strong> are used in combination with
- * JSPWiki's {@link org.apache.wiki.i18n.InternationalizationManager} to
- * create language-independent user interface messages. The message argument
- * array is retrieved via {@link #getMessageArguments()}; the first two array
- * elements will always be these: a String representing work flow owner's name,
- * and a String representing the current actor's name. Workflow participants
- * can add to this array by invoking {@link #addMessageArgument(Serializable)}.</li>
+ * <li><strong>Named attributes</strong> are simple key-value pairs that Workflow participants can get or set. Keys are Strings; values
+ * can be any Object. Named attributes are set with {@link #setAttribute(String, Object)} and retrieved with {@link #getAttribute(String)}.</li>
+ * <li><strong>Message arguments</strong> are used in combination with JSPWiki's {@link org.apache.wiki.i18n.InternationalizationManager} to
+ * create language-independent user interface messages. The message argument array is retrieved via {@link #getMessageArguments()}; the
+ * first two array elements will always be these: a String representing work flow owner's name, and a String representing the current
+ * actor's name. Workflow participants can add to this array by invoking {@link #addMessageArgument(Serializable)}.</li>
  * </ul>
  * <h2>Example</h2>
  * <p>
- * Workflow Steps can be very powerful when linked together. JSPWiki provides
- * two abstract subclasses classes that you can use to build your own Workflows:
- * Tasks and Decisions. As noted, Tasks are Steps that execute without user
- * intervention, while Decisions require actors (<em>aka</em> Principals) to
- * take action. Decisions and Tasks can be mixed freely to produce some highly
- * elaborate branching structures.
+ * Workflow Steps can be very powerful when linked together. JSPWiki provides two abstract subclasses classes that you can use to build
+ * your own Workflows: Tasks and Decisions. As noted, Tasks are Steps that execute without user intervention, while Decisions require
+ * actors (<em>aka</em> Principals) to take action. Decisions and Tasks can be mixed freely to produce some highly elaborate branching
+ * structures.
  * </p>
  * <p>
- * Here is a simple case. For example, suppose you would like to create a
- * Workflow that (a) executes a initialization Task, (b) pauses to obtain an
- * approval Decision from a user in the Admin group, and if approved, (c)
- * executes a "finish" Task. Here's sample code that illustrates how to do it:
+ * Here is a simple case. For example, suppose you would like to create a Workflow that (a) executes a initialization Task, (b) pauses to
+ * obtain an approval Decision from a user in the Admin group, and if approved, (c) executes a "finish" Task. Here's sample code that
+ * illustrates how to do it:
  * </p>
  *
  * <pre>
  *    // Create workflow; owner is current user
- * 1  Workflow workflow = new Workflow(&quot;workflow.myworkflow&quot;, context.getCurrentUser());
+ * 1  Workflow workflow = new Workflow( &quot; workflow.myworkflow &quot;, context.getCurrentUser() );
  *
  *    // Create custom initialization task
- * 2  Step initTask = new InitTask(this);
+ * 2  Step initTask = new InitTask( this );
  *
  *    // Create finish task
- * 3  Step finishTask = new FinishTask(this);
+ * 3  Step finishTask = new FinishTask( this );
  *
  *    // Create an intermediate decision step
- * 4  Principal actor = new GroupPrincipal(&quot;Admin&quot;);
- * 5  Step decision = new SimpleDecision(this, &quot;decision.AdminDecision&quot;, actor);
+ * 4  Principal actor = new GroupPrincipal( &quot;Admin&quot; );
+ * 5  Step decision = new SimpleDecision( this, &quot;decision.AdminDecision&quot;, actor );
  *
  *    // Hook the steps together
- * 6  initTask.addSuccessor(Outcome.STEP_COMPLETE, decision);
- * 7  decision.addSuccessor(Outcome.DECISION_APPROVE, finishTask);
+ * 6  initTask.addSuccessor( Outcome.STEP_COMPLETE, decision );
+ * 7  decision.addSuccessor( Outcome.DECISION_APPROVE, finishTask );
  *
  *    // Set workflow's first step
- * 8  workflow.setFirstStep(initTask);
+ * 8  workflow.setFirstStep( initTask );
  * </pre>
  *
  * <p>
  * Some comments on the source code:
  * </p>
  * <ul>
- * <li>Line 1 instantiates the workflow with a sample message key and
- * designated owner Principal, in this case the current wiki user</li>
- * <li>Lines 2 and 3 instantiate the custom Task subclasses, which contain the
- * business logic</li>
- * <li>Line 4 creates the relevant GroupPrincipal for the <code>Admin</code>
- * group, who will be the actor in the Decision step</li>
- * <li>Line 5 creates the Decision step, passing the Workflow, sample message
- * key, and actor in the constructor</li>
- * <li>Line 6 specifies that if the InitTask's Outcome signifies "normal
- * completion" (STEP_COMPLETE), the SimpleDecision step should be invoked next</li>
- * <li>Line 7 specifies that if the actor (anyone possessing the
- * <code>Admin</code> GroupPrincipal) selects DECISION_APPROVE, the FinishTask
+ * <li>Line 1 instantiates the workflow with a sample message key and designated owner Principal, in this case the current wiki user</li>
+ * <li>Lines 2 and 3 instantiate the custom Task subclasses, which contain the business logic</li>
+ * <li>Line 4 creates the relevant GroupPrincipal for the <code>Admin</code> group, who will be the actor in the Decision step</li>
+ * <li>Line 5 creates the Decision step, passing the Workflow, sample message key, and actor in the constructor</li>
+ * <li>Line 6 specifies that if the InitTask's Outcome signifies "normal completion" (STEP_COMPLETE), the SimpleDecision step should be
+ * invoked next</li>
+ * <li>Line 7 specifies that if the actor (anyone possessing the <code>Admin</code> GroupPrincipal) selects DECISION_APPROVE, the FinishTask
  * step should be invoked</li>
- * <li>Line 8 adds the InitTask (and all of its successor Steps, nicely wired
- * together) to the workflow</li>
+ * <li>Line 8 adds the InitTask (and all of its successor Steps, nicely wired together) to the workflow</li>
  * </ul>
- *
  */
-public class Workflow implements Serializable
-{
+public class Workflow implements Serializable {
+
     private static final long serialVersionUID = 5228149040690660032L;
 
     /** Time value: the start or end time has not been set. */
@@ -218,10 +177,7 @@ public class Workflow implements Serializable
     /** State value: Workflow aborted before completion. */
     public static final int ABORTED = 40;
 
-    /**
-     * State value: Workflow paused, typically because a Step returned an
-     * Outcome that doesn't signify "completion."
-     */
+    /** State value: Workflow paused, typically because a Step returned an Outcome that doesn't signify "completion." */
     public static final int WAITING = 30;
 
     /** State value: Workflow started, and is running. */
@@ -231,7 +187,7 @@ public class Workflow implements Serializable
     public static final int CREATED = -2;
 
     /** Lazily-initialized attribute map. */
-    private Map<String, Object> m_attributes;
+    private Map< String, Object > m_attributes;
 
     /** The initial Step for this Workflow. */
     private Step m_firstStep;
@@ -239,7 +195,7 @@ public class Workflow implements Serializable
     /** Flag indicating whether the Workflow has started yet. */
     private boolean m_started;
 
-    private final LinkedList<Step> m_history;
+    private final LinkedList< Step > m_history;
 
     private int m_id;
 
@@ -256,62 +212,45 @@ public class Workflow implements Serializable
     private WorkflowManager m_manager;
 
     /**
-     * Constructs a new Workflow object with a supplied message key, owner
-     * Principal, and undefined unique identifier {@link #ID_NOT_SET}. Once
-     * instantiated the Workflow is considered to be in the {@link #CREATED}
-     * state; a caller must explicitly invoke the {@link #start()} method to
-     * begin processing.
+     * Constructs a new Workflow object with a supplied message key, owner Principal, and undefined unique identifier {@link #ID_NOT_SET}.
+     * Once instantiated the Workflow is considered to be in the {@link #CREATED} state; a caller must explicitly invoke the
+     * {@link #start()} method to begin processing.
      *
-     * @param messageKey
-     *            the message key used to construct a localized workflow name,
-     *            such as <code>workflow.saveWikiPage</code>
-     * @param owner
-     *            the Principal who owns the Workflow. Typically, this is the
-     *            user who created and submitted it
-     */
-    public Workflow(String messageKey, Principal owner)
-    {
-        super();
+     * @param messageKey the message key used to construct a localized workflow name, such as <code>workflow.saveWikiPage</code>
+     * @param owner the Principal who owns the Workflow. Typically, this is the user who created and submitted it
+     */
+    public Workflow( final String messageKey, final Principal owner ) {
         m_attributes = null;
         m_currentStep = null;
-        m_history = new LinkedList<Step>();
+        m_history = new LinkedList<>();
         m_id = ID_NOT_SET;
         m_key = messageKey;
         m_manager = null;
-        m_messageArgs = new ArrayList<Serializable>();
+        m_messageArgs = new ArrayList<>();
         m_owner = owner;
         m_started = false;
         m_state = CREATED;
     }
 
     /**
-     * Aborts the Workflow by setting the current Step's Outcome to
-     * {@link Outcome#STEP_ABORT}, and the Workflow's overall state to
-     * {@link #ABORTED}. It also appends the aborted Step into the workflow
-     * history, and sets the current step to <code>null</code>. If the Step
-     * is a Decision, it is removed from the DecisionQueue. This method
-     * can be called at any point in the lifecycle prior to completion, but it
-     * cannot be called twice. It finishes by calling the {@link #cleanup()}
-     * method to flush retained objects. If the Workflow had been previously
-     * aborted, this method throws an IllegalStateException.
+     * Aborts the Workflow by setting the current Step's Outcome to {@link Outcome#STEP_ABORT}, and the Workflow's overall state to
+     * {@link #ABORTED}. It also appends the aborted Step into the workflow history, and sets the current step to <code>null</code>.
+     * If the Step is a Decision, it is removed from the DecisionQueue. This method can be called at any point in the lifecycle prior
+     * to completion, but it cannot be called twice. It finishes by calling the {@link #cleanup()} method to flush retained objects.
+     * If the Workflow had been previously aborted, this method throws an IllegalStateException.
      */
-    public final synchronized void abort()
-    {
+    public final synchronized void abort() {
         // Check corner cases: previous abort or completion
-        if ( m_state == ABORTED )
-        {
+        if( m_state == ABORTED ) {
             throw new IllegalStateException( "The workflow has already been aborted." );
         }
-        if ( m_state == COMPLETED )
-        {
+        if( m_state == COMPLETED ) {
             throw new IllegalStateException( "The workflow has already completed." );
         }
 
-        if ( m_currentStep != null )
-        {
-            if ( m_manager != null && m_currentStep instanceof Decision )
-            {
-                Decision d = (Decision)m_currentStep;
+        if( m_currentStep != null ) {
+            if( m_manager != null && m_currentStep instanceof Decision ) {
+                final Decision d = ( Decision )m_currentStep;
                 m_manager.getDecisionQueue().remove( d );
             }
             m_currentStep.setOutcome( Outcome.STEP_ABORT );
@@ -323,18 +262,14 @@ public class Workflow implements Serializable
     }
 
     /**
-     * Appends a message argument object to the array returned by
-     * {@link #getMessageArguments()}. The object <em>must</em> be an type
-     * used by the {@link java.text.MessageFormat}: String, Date, or Number
-     * (BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, Short).
-     * If the object is not of type String, Number or Date, this method throws
-     * an IllegalArgumentException.
+     * Appends a message argument object to the array returned by {@link #getMessageArguments()}. The object <em>must</em> be an type
+     * used by the {@link java.text.MessageFormat}: String, Date, or Number (BigDecimal, BigInteger, Byte, Double, Float, Integer, Long,
+     * Short). If the object is not of type String, Number or Date, this method throws an IllegalArgumentException.
+     *
      * @param obj the object to add
      */
-    public final void addMessageArgument( Serializable obj )
-    {
-        if ( obj instanceof String || obj instanceof Date || obj instanceof Number )
-        {
+    public final void addMessageArgument( final Serializable obj ) {
+        if( obj instanceof String || obj instanceof Date || obj instanceof Number ) {
             m_messageArgs.add( obj );
             return;
         }
@@ -347,18 +282,15 @@ public class Workflow implements Serializable
      *
      * @return the current actor
      */
-    public final synchronized Principal getCurrentActor()
-    {
-        if ( m_currentStep == null )
-        {
+    public final synchronized Principal getCurrentActor() {
+        if( m_currentStep == null ) {
             return null;
         }
         return m_currentStep.getActor();
     }
 
     /**
-     * Returns the workflow state: {@link #CREATED}, {@link #RUNNING},
-     * {@link #WAITING}, {@link #COMPLETED} or {@link #ABORTED}.
+     * Returns the workflow state: {@link #CREATED}, {@link #RUNNING}, {@link #WAITING}, {@link #COMPLETED} or {@link #ABORTED}.
      *
      * @return the workflow state
      */
@@ -368,8 +300,7 @@ public class Workflow implements Serializable
     }
 
     /**
-     * Returns the current Step, or <code>null</code> if the workflow has not
-     * started or already completed.
+     * Returns the current Step, or <code>null</code> if the workflow has not started or already completed.
      *
      * @return the current step
      */
@@ -379,36 +310,29 @@ public class Workflow implements Serializable
     }
 
     /**
-     * Retrieves a named Object associated with this Workflow. If the Workflow
-     * has completed or aborted, this method always returns <code>null</code>.
+     * Retrieves a named Object associated with this Workflow. If the Workflow has completed or aborted, this method always returns
+     * <code>null</code>.
      *
      * @param attr the name of the attribute
      * @return the value
      */
-    public final synchronized Object getAttribute( String attr )
-    {
-        if ( m_attributes == null )
-        {
+    public final synchronized Object getAttribute( final String attr ) {
+        if( m_attributes == null ) {
             return null;
         }
         return m_attributes.get( attr );
     }
 
     /**
-     * The end time for this Workflow, expressed as a system time number. This
-     * value is equal to the end-time value returned by the final Step's
-     * {@link Step#getEndTime()} method, if the workflow has completed.
-     * Otherwise, this method returns {@link #TIME_NOT_SET}.
+     * The end time for this Workflow, expressed as a system time number. This value is equal to the end-time value returned by the final
+     * Step's {@link Step#getEndTime()} method, if the workflow has completed. Otherwise, this method returns {@link #TIME_NOT_SET}.
      *
      * @return the end time
      */
-    public final Date getEndTime()
-    {
-        if ( isCompleted() )
-        {
-            Step last = m_history.getLast();
-            if ( last != null )
-            {
+    public final Date getEndTime() {
+        if( isCompleted() ) {
+            final Step last = m_history.getLast();
+            if( last != null ) {
                 return last.getEndTime();
             }
         }
@@ -416,8 +340,7 @@ public class Workflow implements Serializable
     }
 
     /**
-     * Returns the unique identifier for this Workflow. If not set, this method
-     * returns ID_NOT_SET ({@value #ID_NOT_SET}).
+     * Returns the unique identifier for this Workflow. If not set, this method returns ID_NOT_SET ({@value #ID_NOT_SET}).
      *
      * @return the unique identifier
      */
@@ -428,8 +351,7 @@ public class Workflow implements Serializable
 
     /**
      * <p>
-     * Returns an array of message arguments, used by
-     * {@link java.text.MessageFormat} to create localized messages. The first
+     * Returns an array of message arguments, used by {@link java.text.MessageFormat} to create localized messages. The first
      * two array elements will always be these:
      * </p>
      * <ul>
@@ -439,20 +361,18 @@ public class Workflow implements Serializable
      * finished, the value of this argument will be a dash character (<code>-</code>)</li>
      * </ul>
      * <p>
-     * Workflow and Step subclasses are free to append items to this collection
-     * with {@link #addMessageArgument(Serializable)}.
+     * Workflow and Step subclasses are free to append items to this collection with {@link #addMessageArgument(Serializable)}.
      * </p>
      *
      * @return the array of message arguments
      */
-    public final Serializable[] getMessageArguments()
-    {
-        List<Serializable> args = new ArrayList<Serializable>();
+    public final Serializable[] getMessageArguments() {
+        final List< Serializable > args = new ArrayList<>();
         args.add( m_owner.getName() );
-        Principal actor = getCurrentActor();
+        final Principal actor = getCurrentActor();
         args.add( actor == null ? "-" : actor.getName() );
         args.addAll( m_messageArgs );
-        return args.toArray( new Serializable[args.size()] );
+        return args.toArray( new Serializable[ args.size() ] );
     }
 
     /**
@@ -467,8 +387,7 @@ public class Workflow implements Serializable
     }
 
     /**
-     * The owner Principal on whose behalf this Workflow is being executed; that
-     * is, the user who created the workflow.
+     * The owner Principal on whose behalf this Workflow is being executed; that is, the user who created the workflow.
      *
      * @return the name of the Principal who owns this workflow
      */
@@ -478,10 +397,9 @@ public class Workflow implements Serializable
     }
 
     /**
-     * The start time for this Workflow, expressed as a system time number. This
-     * value is equal to the start-time value returned by the first Step's
-     * {@link Step#getStartTime()} method, if the workflow has started already.
-     * Otherwise, this method returns {@link #TIME_NOT_SET}.
+     * The start time for this Workflow, expressed as a system time number. This value is equal to the start-time value returned by the
+     * first Step's {@link Step#getStartTime()} method, if the workflow has started already. Otherwise, this method returns
+     * {@link #TIME_NOT_SET}.
      *
      * @return the start time
      */
@@ -501,13 +419,10 @@ public class Workflow implements Serializable
     }
 
     /**
-     * Returns a Step history for this Workflow as a List, chronologically, from the
-     * first Step to the currently executing one. The first step is the first
-     * item in the array. If the Workflow has not started, this method returns a
-     * zero-length array.
+     * Returns a Step history for this Workflow as a List, chronologically, from the first Step to the currently executing one. The first
+     * step is the first item in the array. If the Workflow has not started, this method returns a zero-length array.
      *
-     * @return an array of Steps representing those that have executed, or are
-     *         currently executing
+     * @return an array of Steps representing those that have executed, or are currently executing
      */
     public final List< Step > getHistory()
     {
@@ -525,25 +440,20 @@ public class Workflow implements Serializable
     }
 
     /**
-     * Determines whether this Workflow is completed; that is, if it has no
-     * additional Steps to perform. If the last Step in the workflow is
+     * Determines whether this Workflow is completed; that is, if it has no additional Steps to perform. If the last Step in the workflow is
      * finished, this method will return <code>true</code>.
      *
-     * @return <code>true</code> if the workflow has been started but has no
-     *         more steps to perform; <code>false</code> if not.
+     * @return <code>true</code> if the workflow has been started but has no more steps to perform; <code>false</code> if not.
      */
-    public final synchronized boolean isCompleted()
-    {
+    public final synchronized boolean isCompleted() {
         // If current step is null, then we're done
         return m_started && m_state == COMPLETED;
     }
 
     /**
-     * Determines whether this Workflow has started; that is, its
-     * {@link #start()} method has been executed.
+     * Determines whether this Workflow has started; that is, its {@link #start()} method has been executed.
      *
-     * @return <code>true</code> if the workflow has been started;
-     *         <code>false</code> if not.
+     * @return <code>true</code> if the workflow has been started; <code>false</code> if not.
      */
     public final boolean isStarted()
     {
@@ -551,12 +461,10 @@ public class Workflow implements Serializable
     }
 
     /**
-     * Convenience method that returns the predecessor of the current Step. This
-     * method simply examines the Workflow history and returns the
+     * Convenience method that returns the predecessor of the current Step. This method simply examines the Workflow history and returns the
      * second-to-last Step.
      *
-     * @return the predecessor, or <code>null</code> if the first Step is
-     *         currently executing
+     * @return the predecessor, or <code>null</code> if the first Step is currently executing
      */
     public final Step getPreviousStep()
     {
@@ -564,51 +472,39 @@ public class Workflow implements Serializable
     }
 
     /**
-     * Restarts the Workflow from the {@link #WAITING} state and puts it into
-     * the {@link #RUNNING} state again. If the Workflow had not previously been
-     * paused, this method throws an IllegalStateException. If any of the
-     * Steps in this Workflow throw a WikiException, the Workflow will abort
-     * and propagate the exception to callers.
-     * @throws WikiException if the current task's {@link Task#execute()} method
-     * throws an exception
+     * Restarts the Workflow from the {@link #WAITING} state and puts it into the {@link #RUNNING} state again. If the Workflow had not
+     * previously been paused, this method throws an IllegalStateException. If any of the Steps in this Workflow throw a WikiException,
+     * the Workflow will abort and propagate the exception to callers.
+     *
+     * @throws WikiException if the current task's {@link Task#execute()} method throws an exception
      */
-    public final synchronized void restart() throws WikiException
-    {
-        if ( m_state != WAITING )
-        {
+    public final synchronized void restart() throws WikiException {
+        if( m_state != WAITING ) {
             throw new IllegalStateException( "Workflow is not paused; cannot restart." );
         }
         m_state = RUNNING;
         fireEvent( WorkflowEvent.RUNNING );
 
         // Process current step
-        try
-        {
+        try {
             processCurrentStep();
-        }
-        catch ( WikiException e )
-        {
+        } catch( final WikiException e ) {
             abort();
             throw e;
         }
     }
 
     /**
-     * Temporarily associates an object with this Workflow, as a named attribute, for the
-     * duration of workflow execution. The passed object can be anything required by
-     * an executing Step, although it <em>should</em> be serializable. Note that when the workflow
+     * Temporarily associates an object with this Workflow, as a named attribute, for the duration of workflow execution. The passed
+     * object can be anything required by an executing Step, although it <em>should</em> be serializable. Note that when the workflow
      * completes or aborts, all attributes will be cleared.
      *
-     * @param attr
-     *            the attribute name
-     * @param obj
-     *            the value
+     * @param attr the attribute name
+     * @param obj  the value
      */
-    public final synchronized void setAttribute(String attr, Object obj )
-    {
-        if ( m_attributes == null )
-        {
-            m_attributes = new HashMap<String, Object>();
+    public final synchronized void setAttribute( final String attr, final Object obj ) {
+        if( m_attributes == null ) {
+            m_attributes = new HashMap<>();
         }
         m_attributes.put( attr, obj );
     }
@@ -619,10 +515,9 @@ public class Workflow implements Serializable
      * marked as the "current" step or added to the Workflow history until the
      * {@link #start()} method is called.
      *
-     * @param step
-     *            the first step for the workflow
+     * @param step the first step for the workflow
      */
-    public final synchronized void setFirstStep(Step step)
+    public final synchronized void setFirstStep( final Step step )
     {
         m_firstStep = step;
     }
@@ -630,10 +525,9 @@ public class Workflow implements Serializable
     /**
      * Sets the unique identifier for this Workflow.
      *
-     * @param id
-     *            the unique identifier
+     * @param id the unique identifier
      */
-    public final synchronized void setId( int id )
+    public final synchronized void setId( final int id )
     {
         this.m_id = id;
     }
@@ -641,32 +535,25 @@ public class Workflow implements Serializable
     /**
      * Sets the WorkflowManager that contains this Workflow.
      *
-     * @param manager
-     *            the workflow manager
+     * @param manager the workflow manager
      */
-    public final synchronized void setWorkflowManager( WorkflowManager manager )
-    {
+    public final synchronized void setWorkflowManager( final WorkflowManager manager ) {
         m_manager = manager;
         addWikiEventListener( manager );
     }
 
     /**
-     * Starts the Workflow and sets the state to {@link #RUNNING}. If the
-     * Workflow has already been started (or previously aborted), this method
-     * returns an {@linkplain IllegalStateException}. If any of the
-     * Steps in this Workflow throw a WikiException, the Workflow will abort
-     * and propagate the exception to callers.
-     * @throws WikiException if the current Step's {@link Step#start()}
-     * method throws an exception of any kind
+     * Starts the Workflow and sets the state to {@link #RUNNING}. If the Workflow has already been started (or previously aborted), this
+     * method returns an {@linkplain IllegalStateException}. If any of the Steps in this Workflow throw a WikiException, the Workflow will
+     * abort and propagate the exception to callers.
+     *
+     * @throws WikiException if the current Step's {@link Step#start()} method throws an exception of any kind
      */
-    public final synchronized void start() throws WikiException
-    {
-        if ( m_state == ABORTED )
-        {
+    public final synchronized void start() throws WikiException {
+        if( m_state == ABORTED ) {
             throw new IllegalStateException( "Workflow cannot be started; it has already been aborted." );
         }
-        if ( m_started )
-        {
+        if( m_started ) {
             throw new IllegalStateException( "Workflow has already started." );
         }
         m_started = true;
@@ -678,27 +565,20 @@ public class Workflow implements Serializable
         m_history.add( m_currentStep );
 
         // Process current step
-        try
-        {
+        try {
             processCurrentStep();
-        }
-        catch ( WikiException e )
-        {
+        } catch( final WikiException e ) {
             abort();
             throw e;
         }
     }
 
     /**
-     * Sets the Workflow in the {@link #WAITING} state. If the Workflow is not
-     * running or has already been paused, this method throws an
-     * IllegalStateException. Once paused, the Workflow can be un-paused by
-     * executing the {@link #restart()} method.
+     * Sets the Workflow in the {@link #WAITING} state. If the Workflow is not running or has already been paused, this method throws an
+     * IllegalStateException. Once paused, the Workflow can be un-paused by executing the {@link #restart()} method.
      */
-    public final synchronized void waitstate()
-    {
-        if ( m_state != RUNNING )
-        {
+    public final synchronized void waitstate() {
+        if ( m_state != RUNNING ) {
             throw new IllegalStateException( "Workflow is not running; cannot pause." );
         }
         m_state = WAITING;
@@ -716,15 +596,11 @@ public class Workflow implements Serializable
     }
 
     /**
-     * Protected helper method that changes the Workflow's state to
-     * {@link #COMPLETED} and sets the current Step to <code>null</code>. It
-     * calls the {@link #cleanup()} method to flush retained objects.
-     * This method will no-op if it has previously been called.
+     * Protected helper method that changes the Workflow's state to {@link #COMPLETED} and sets the current Step to <code>null</code>. It
+     * calls the {@link #cleanup()} method to flush retained objects. This method will no-op if it has previously been called.
      */
-    protected final synchronized void complete()
-    {
-        if ( !isCompleted() )
-        {
+    protected final synchronized void complete() {
+        if( !isCompleted() ) {
             m_state = COMPLETED;
             fireEvent( WorkflowEvent.COMPLETED );
             cleanup();
@@ -734,67 +610,46 @@ public class Workflow implements Serializable
     /**
      * Protected method that returns the predecessor for a supplied Step.
      *
-     * @param step
-     *            the Step for which the predecessor is requested
-     * @return its predecessor, or <code>null</code> if the first Step was
-     *         supplied.
+     * @param step the Step for which the predecessor is requested
+     * @return its predecessor, or <code>null</code> if the first Step was supplied.
      */
-    protected final Step previousStep(Step step)
-    {
-        int index = m_history.indexOf( step );
+    protected final Step previousStep( final Step step ) {
+        final int index = m_history.indexOf( step );
         return index < 1 ? null : m_history.get( index - 1 );
     }
 
     /**
-     * Protected method that processes the current Step by calling
-     * {@link Step#execute()}. If the <code>execute</code> throws an
-     * exception, this method will propagate the exception immediately
-     * to callers without aborting.
-     * @throws WikiException if the current Step's {@link Step#start()}
-     * method throws an exception of any kind
+     * Protected method that processes the current Step by calling {@link Step#execute()}. If the <code>execute</code> throws an
+     * exception, this method will propagate the exception immediately to callers without aborting.
+     *
+     * @throws WikiException if the current Step's {@link Step#start()} method throws an exception of any kind
      */
-    protected final void processCurrentStep() throws WikiException
-    {
-        while ( m_currentStep != null )
-        {
-
+    protected final void processCurrentStep() throws WikiException {
+        while ( m_currentStep != null ) {
             // Start and execute the current step
-            if ( !m_currentStep.isStarted() )
-            {
+            if( !m_currentStep.isStarted() ) {
                 m_currentStep.start();
             }
-            try
-            {
-                Outcome result = m_currentStep.execute();
-                if ( Outcome.STEP_ABORT.equals( result ) )
-                {
-                    abort();
-                    break;
-                }
-
-                if ( !m_currentStep.isCompleted() )
-                {
-                    m_currentStep.setOutcome( result );
-                }
+            final Outcome result = m_currentStep.execute();
+            if( Outcome.STEP_ABORT.equals( result ) ) {
+                abort();
+                break;
             }
-            catch ( WikiException e )
-            {
-                throw e;
+
+            if( !m_currentStep.isCompleted() ) {
+                m_currentStep.setOutcome( result );
             }
 
-            // Get the execution Outcome; if not complete, pause workflow and
-            // exit
-            Outcome outcome = m_currentStep.getOutcome();
-            if ( !outcome.isCompletion() )
-            {
+            // Get the execution Outcome; if not complete, pause workflow and exit
+            final Outcome outcome = m_currentStep.getOutcome();
+            if ( !outcome.isCompletion() ) {
                 waitstate();
                 break;
             }
 
             // Get the next Step; if null, we're done
-            Step nextStep = m_currentStep.getSuccessor( outcome );
-            if ( nextStep == null )
-            {
+            final Step nextStep = m_currentStep.getSuccessor( outcome );
+            if ( nextStep == null ) {
                 complete();
                 break;
             }
@@ -809,26 +664,20 @@ public class Workflow implements Serializable
     // events processing .......................................................
 
     /**
-     * Registers a WikiEventListener with this instance. This is a convenience
-     * method.
+     * Registers a WikiEventListener with this instance. This is a convenience method.
      *
-     * @param listener
-     *            the event listener
+     * @param listener the event listener
      */
-    public final synchronized void addWikiEventListener( WikiEventListener listener )
-    {
+    public final synchronized void addWikiEventListener( final WikiEventListener listener ) {
         WikiEventManager.addWikiEventListener( this, listener );
     }
 
     /**
-     * Un-registers a WikiEventListener with this instance. This is a
-     * convenience method.
+     * Un-registers a WikiEventListener with this instance. This is a convenience method.
      *
-     * @param listener
-     *            the event listener
+     * @param listener the event listener
      */
-    public final synchronized void removeWikiEventListener( WikiEventListener listener )
-    {
+    public final synchronized void removeWikiEventListener( final WikiEventListener listener ) {
         WikiEventManager.removeWikiEventListener( this, listener );
     }
 
@@ -836,13 +685,10 @@ public class Workflow implements Serializable
      * Fires a WorkflowEvent of the provided type to all registered listeners.
      *
      * @see org.apache.wiki.event.WorkflowEvent
-     * @param type
-     *            the event type to be fired
+     * @param type the event type to be fired
      */
-    protected final void fireEvent( int type )
-    {
-        if ( WikiEventManager.isListening( this ) )
-        {
+    protected final void fireEvent( final int type ) {
+        if ( WikiEventManager.isListening( this ) ) {
             WikiEventManager.fireEvent( this, new WorkflowEvent( this, type ) );
         }
     }


[jspwiki] 11/20: JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (6)

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 32c889f7a10e29f1483a4b96d6776180a30e30da
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 19:24:16 2020 +0100

    JSPWIKI-120: remove use of WikiEngine throughout the code as much as possible and use Engine instead (6)
---
 .../wiki/workflow/DefaultWorkflowManager.java      |  4 +--
 .../org/apache/wiki/workflow/WorkflowBuilder.java  |  4 +--
 .../org/apache/wiki/workflow/WorkflowManager.java  |  2 +-
 .../java/org/apache/wiki/xmlrpc/RPCHandler.java    |  5 +---
 .../java/org/apache/wiki/xmlrpc/RPCServlet.java    | 30 ++++++++++------------
 .../wiki/filters/DefaultFilterManagerTest.java     | 22 ++++++++--------
 .../java/org/apache/wiki/filters/TestFilter.java   |  8 +++---
 7 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
index 0ace9d9..5459d10 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/DefaultWorkflowManager.java
@@ -148,13 +148,13 @@ public class DefaultWorkflowManager implements WorkflowManager {
     }
 
     /**
-     * Protected helper method that returns the associated WikiEngine
+     * Protected helper method that returns the associated Engine
      *
      * @return the wiki engine
      */
     protected Engine getEngine() {
         if ( m_engine == null ) {
-            throw new IllegalStateException( "WikiEngine cannot be null; please initialize WorkflowManager first." );
+            throw new IllegalStateException( "Engine cannot be null; please initialize WorkflowManager first." );
         }
         return m_engine;
     }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowBuilder.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowBuilder.java
index c18b8b8..95afafb 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowBuilder.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowBuilder.java
@@ -34,7 +34,7 @@ public final class WorkflowBuilder {
     private final Engine m_engine;
 
     /**
-     * Private constructor that creates a new WorkflowBuilder for the supplied WikiEngine.
+     * Private constructor that creates a new WorkflowBuilder for the supplied Engine.
      * @param engine the wiki engine
      */
     private WorkflowBuilder( final Engine engine )
@@ -43,7 +43,7 @@ public final class WorkflowBuilder {
     }
 
     /**
-     * Returns the WorkflowBuilder instance for a WikiEngine. Only one WorkflowBuilder
+     * Returns the WorkflowBuilder instance for a Engine. Only one WorkflowBuilder
      * exists for a given engine.
      * @param engine the wiki engine
      * @return the workflow builder
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
index 60858db..0322a21 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/workflow/WorkflowManager.java
@@ -98,7 +98,7 @@ public interface WorkflowManager extends WikiEventListener {
     List< Workflow > getCompletedWorkflows();
 
     /**
-     * Initializes the WorkflowManager using a specfied WikiEngine and properties. Any properties that begin with
+     * Initializes the WorkflowManager using a specfied Engine and properties. Any properties that begin with
      * {@link #PROPERTY_APPROVER_PREFIX} will be assumed to be Decisions that require approval. For a given property key, everything
      * after the prefix denotes the Decision's message key. The property value indicates the Principal (Role, GroupPrincipal, WikiPrincipal)
      * that must approve the Decision. For example, if the property key/value pair is {@code jspwiki.approver.workflow.saveWikiPage=Admin},
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java
index 7bf5423..f343a63 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCHandler.java
@@ -18,7 +18,6 @@
  */
 package org.apache.wiki.xmlrpc;
 
-import org.apache.log4j.Logger;
 import org.apache.wiki.LinkCollector;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
@@ -43,11 +42,9 @@ import java.util.Vector;
  *
  *  @since 1.6.6
  */
-// We could use WikiEngine directly, but because of introspection it would show just too many methods to be safe.
+// We could use Engine directly, but because of introspection it would show just too many methods to be safe.
 public class RPCHandler extends AbstractRPCHandler {
 
-    private static final Logger log = Logger.getLogger( RPCHandler.class );
-
     /**
      *  Converts Java string into RPC string.
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java
index 29ec933..4259acc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/RPCServlet.java
@@ -21,6 +21,7 @@ package org.apache.wiki.xmlrpc;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.xmlrpc.ContextXmlRpcHandler;
 import org.apache.xmlrpc.Invoker;
 import org.apache.xmlrpc.XmlRpcContext;
@@ -49,17 +50,15 @@ import java.util.Vector;
  *
  *  @since 1.6.6
  */
-public class RPCServlet extends HttpServlet
-{
+public class RPCServlet extends HttpServlet {
     private static final long serialVersionUID = 3976735878410416180L;
 
-    /** This is what is appended to each command, if the handler has
-        not been specified.  */
+    /** This is what is appended to each command, if the handler has not been specified. */
     // FIXME: Should this be $default?
     public static final String XMLRPC_PREFIX = "wiki";
 
-    private WikiEngine       m_engine;
-    private XmlRpcServer     m_xmlrpcServer = new XmlRpcServer();
+    private Engine m_engine;
+    private XmlRpcServer m_xmlrpcServer = new XmlRpcServer();
 
     private static final Logger log = Logger.getLogger( RPCServlet.class );
 
@@ -77,7 +76,7 @@ public class RPCServlet extends HttpServlet
     /**
      *  Initializes the servlet.
      */
-    public void init( final ServletConfig config ) throws ServletException {
+    @Override public void init( final ServletConfig config ) throws ServletException {
         m_engine = WikiEngine.getInstance( config );
 
         String handlerName = config.getInitParameter( "handler" );
@@ -93,9 +92,7 @@ public class RPCServlet extends HttpServlet
         try {
             initHandler( prefix, handlerName );
 
-            //
             // FIXME: The metaweblog API should be possible to turn off.
-            //
             initHandler( "metaWeblog", "org.apache.wiki.xmlrpc.MetaWeblogHandler" );
         } catch( final Exception e ) {
             log.fatal("Unable to start RPC interface: ", e);
@@ -106,7 +103,7 @@ public class RPCServlet extends HttpServlet
     /**
      *  Handle HTTP POST.  This is an XML-RPC call, and we'll just forward the query to an XmlRpcServer.
      */
-    public void doPost( final HttpServletRequest request, final HttpServletResponse response ) throws ServletException {
+    @Override public void doPost( final HttpServletRequest request, final HttpServletResponse response ) throws ServletException {
         log.debug("Received POST to RPCServlet");
 
         try {
@@ -135,7 +132,7 @@ public class RPCServlet extends HttpServlet
     /**
      *  Handles HTTP GET.  However, we do not respond to GET requests, other than to show an explanatory text.
      */
-    public void doGet( final HttpServletRequest request, final HttpServletResponse response ) throws ServletException {
+    @Override public void doGet( final HttpServletRequest request, final HttpServletResponse response ) throws ServletException {
         log.debug("Received HTTP GET to RPCServlet");
 
         try {
@@ -160,7 +157,7 @@ public class RPCServlet extends HttpServlet
             m_clazz = clazz;
         }
 
-        public Object execute( final String method, final Vector params, final XmlRpcContext context ) throws Exception {
+        @Override public Object execute( final String method, final Vector params, final XmlRpcContext context ) throws Exception {
             final WikiRPCHandler rpchandler = (WikiRPCHandler) m_clazz.newInstance();
             rpchandler.initialize( ((WikiXmlRpcContext)context).getWikiContext() );
 
@@ -179,18 +176,16 @@ public class RPCServlet extends HttpServlet
             m_context = ctx;
         }
 
-        public XmlRpcHandlerMapping getHandlerMapping()
+        @Override public XmlRpcHandlerMapping getHandlerMapping()
         {
             return m_mapping;
         }
 
-        public String getPassword() {
-            // TODO Auto-generated method stub
+        @Override public String getPassword() {
             return null;
         }
 
-        public String getUserName() {
-            // TODO Auto-generated method stub
+        @Override public String getUserName() {
             return null;
         }
 
@@ -199,4 +194,5 @@ public class RPCServlet extends HttpServlet
             return m_context;
         }
     }
+
 }
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 91b665b..3534901 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
@@ -16,8 +16,8 @@
     specific language governing permissions and limitations
     under the License.
  */
-
 package org.apache.wiki.filters;
+
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.filters.PageFilter;
@@ -35,33 +35,33 @@ public class DefaultFilterManagerTest {
 
     @Test
     public void testInitFilters() throws Exception {
-        FilterManager m = new DefaultFilterManager( engine, props );
+        final FilterManager m = new DefaultFilterManager( engine, props );
 
-        List<PageFilter> l = m.getFilterList();
+        final List<PageFilter> l = m.getFilterList();
 
         Assertions.assertEquals( 2, l.size(), "Wrong number of filters" );
 
-        Iterator<PageFilter> i = l.iterator();
-        PageFilter f1 = i.next();
+        final Iterator<PageFilter> i = l.iterator();
+        final PageFilter f1 = i.next();
 
         Assertions.assertTrue( f1 instanceof ProfanityFilter, "Not a Profanityfilter" );
 
-        PageFilter f2 = i.next();
+        final PageFilter f2 = i.next();
 
         Assertions.assertTrue( f2 instanceof TestFilter, "Not a Testfilter" );
     }
 
     @Test
     public void testInitParams() throws Exception {
-        FilterManager m = new DefaultFilterManager( engine, props );
+        final FilterManager m = new DefaultFilterManager( engine, props );
 
-        List<PageFilter> l = m.getFilterList();
+        final List<PageFilter> l = m.getFilterList();
 
-        Iterator<PageFilter> i = l.iterator();
+        final Iterator<PageFilter> i = l.iterator();
         i.next();
-        TestFilter f2 = (TestFilter)i.next();
+        final TestFilter f2 = (TestFilter)i.next();
 
-        Properties p = f2.m_properties;
+        final Properties p = f2.m_properties;
 
         Assertions.assertEquals( "Zippadippadai", p.getProperty("foobar"), "no foobar" );
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/filters/TestFilter.java b/jspwiki-main/src/test/java/org/apache/wiki/filters/TestFilter.java
index 3e7996e..044af74 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/filters/TestFilter.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/filters/TestFilter.java
@@ -18,17 +18,17 @@
  */
 package org.apache.wiki.filters;
 
-import java.util.Properties;
-
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.filters.BasicPageFilter;
 
+import java.util.Properties;
+
 
 public class TestFilter extends BasicPageFilter {
 	
     public Properties m_properties;
 
-    public void initialize( WikiEngine engine, Properties props ) {
+    @Override public void initialize( final Engine engine, final Properties props ) {
         m_properties = props;
     }
 


[jspwiki] 05/20: JSPWIKI-120: URLConstructor#initialize(..) uses Engine instead of WikiEngine

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

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

commit 25e2488f088e7fb93ec9511f279aa8ddc346d82e
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 19:02:22 2020 +0100

    JSPWIKI-120: URLConstructor#initialize(..) uses Engine instead of WikiEngine
---
 .../org/apache/wiki/url/DefaultURLConstructor.java | 22 +++++++++++-----------
 .../org/apache/wiki/url/ShortURLConstructor.java   |  6 +++---
 .../apache/wiki/url/ShortViewURLConstructor.java   |  4 ++--
 .../java/org/apache/wiki/url/URLConstructor.java   |  4 ++--
 4 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java
index f35200e..f127c06 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java
@@ -20,7 +20,7 @@ package org.apache.wiki.url;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.ui.Command;
 import org.apache.wiki.ui.CommandResolver;
 import org.apache.wiki.util.TextUtil;
@@ -38,7 +38,7 @@ import java.util.Properties;
  */
 public class DefaultURLConstructor implements URLConstructor {
 
-    protected WikiEngine m_engine;
+    protected Engine m_engine;
 
     /**
      *  Contains the absolute path of the JSPWiki Web application without the actual servlet (which is the m_urlPrefix).
@@ -49,7 +49,7 @@ public class DefaultURLConstructor implements URLConstructor {
      *
      * {@inheritDoc}
      */
-    public void initialize( final WikiEngine engine, final Properties properties ) {
+    @Override public void initialize( final Engine engine, final Properties properties ) {
         m_engine = engine;
         m_pathPrefix = engine.getBaseURL() + "/";
     }
@@ -125,14 +125,14 @@ public class DefaultURLConstructor implements URLConstructor {
      *
      *  {@inheritDoc}
      */
-    public String makeURL( final String context, final String name, String parameters ) {
+    @Override public String makeURL( final String context, final String name, String parameters ) {
         if( parameters != null && parameters.length() > 0 ) {
-            if( context.equals(WikiContext.ATTACH) ) {
-                parameters = "?"+parameters;
-            } else if( context.equals(WikiContext.NONE) ) {
-                parameters = (name.indexOf('?') != -1 ) ? "&amp;" : "?" + parameters;
+            if( context.equals( WikiContext.ATTACH ) ) {
+                parameters = "?" + parameters;
+            } else if( context.equals( WikiContext.NONE ) ) {
+                parameters = name.indexOf( '?' ) != -1 ? "&amp;" : "?" + parameters;
             } else {
-                parameters = "&amp;"+parameters;
+                parameters = "&amp;" + parameters;
             }
         } else {
             parameters = "";
@@ -145,7 +145,7 @@ public class DefaultURLConstructor implements URLConstructor {
      *
      *  {@inheritDoc}
      */
-    public String parsePage( final String context, final HttpServletRequest request, final Charset encoding ) {
+    @Override public String parsePage( final String context, final HttpServletRequest request, final Charset encoding ) {
         String pagereq = request.getParameter( "page" );
         if( context.equals(WikiContext.ATTACH) ) {
             pagereq = parsePageFromURL( request, encoding );
@@ -185,7 +185,7 @@ public class DefaultURLConstructor implements URLConstructor {
      * @param request The HTTP Request that was used to end up in this page.
      * @return "Wiki.jsp", "PageInfo.jsp", etc.  Just return the name, JSPWiki will figure out the page.
      */
-    public String getForwardPage( final HttpServletRequest request ) {
+    @Override public String getForwardPage( final HttpServletRequest request ) {
         return "Wiki.jsp";
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
index 7b988f6..69530db 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
@@ -21,7 +21,7 @@ package org.apache.wiki.url;
 import org.apache.log4j.Logger;
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.util.TextUtil;
 
 import javax.servlet.http.HttpServletRequest;
@@ -50,7 +50,7 @@ public class ShortURLConstructor extends DefaultURLConstructor {
     
     /** {@inheritDoc} */
     @Override
-    public void initialize( final WikiEngine engine, final Properties properties ) {
+    public void initialize( final Engine engine, final Properties properties ) {
         super.initialize( engine, properties );
         
         m_urlPrefix = TextUtil.getStringProperty( properties, PROP_PREFIX, null );
@@ -160,7 +160,7 @@ public class ShortURLConstructor extends DefaultURLConstructor {
             jspPage = "Wiki";
         }
     
-        return jspPage+".jsp";
+        return jspPage + ".jsp";
     }
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java
index 8265c31..2c2ab39 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortViewURLConstructor.java
@@ -19,7 +19,7 @@
 package org.apache.wiki.url;
 
 import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 
 import javax.servlet.http.HttpServletRequest;
 import java.util.Properties;
@@ -34,7 +34,7 @@ public class ShortViewURLConstructor extends ShortURLConstructor {
     /**
      *  {@inheritDoc}
      */
-    public void initialize( final WikiEngine engine, final Properties properties ) {
+    @Override public void initialize( final Engine engine, final Properties properties ) {
         super.initialize( engine, properties );
     }
     
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
index 6035750..a0ac40f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.url;
 
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.api.core.Engine;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
@@ -43,7 +43,7 @@ public interface URLConstructor {
      *  @param  engine The WikiEngine that this URLConstructor belongs to
      *  @param properties Properties used to initialize
      */
-    void initialize( WikiEngine engine, Properties properties );
+    void initialize( Engine engine, Properties properties );
 
     /**
      *  Constructs the URL with a bunch of parameters.


[jspwiki] 17/20: minor formatting edits

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 0a2c57c88823d1e1d2e472d58b9679e7f87bb83a
Author: juanpablo <ju...@apache.org>
AuthorDate: Wed Feb 26 21:44:13 2020 +0100

    minor formatting edits
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java    | 10 +++++-----
 .../java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java   |  6 +++---
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
index cd76c5a..7fce8c9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -58,11 +58,11 @@ import java.util.PropertyPermission;
  */
 public class WikiContext implements Cloneable, Command {
 
-    private    Command m_command;
-    private    WikiPage   m_page;
-    private    WikiPage   m_realPage;
-    private    Engine     m_engine;
-    private    String     m_template = "default";
+    private Command  m_command;
+    private WikiPage m_page;
+    private WikiPage m_realPage;
+    private Engine   m_engine;
+    private String   m_template = "default";
 
     private HashMap< String, Object > m_variableMap = new HashMap<>();
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
index d931181..8f055c8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
@@ -43,8 +43,8 @@ import java.util.concurrent.ConcurrentHashMap;
 
 
 /**
- * This provides a simple ajax servlet for handling /ajax/<ClassName> requests.
- * HttpServlet classes need to be registered using {@link WikiAjaxDispatcherServlet#registerServlet(WikiAjaxServlet)}
+ * This provides a simple ajax servlet for handling /ajax/<ClassName> requests. HttpServlet classes need to be registered using
+ * {@link WikiAjaxDispatcherServlet#registerServlet(WikiAjaxServlet)}
  *
  * @since 2.10.2-svn12
  */
@@ -66,7 +66,7 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
     public void init( final ServletConfig config ) throws ServletException {
         super.init( config );
         m_engine = WikiEngine.getInstance( config );
-        PATH_AJAX = "/"+TextUtil.getStringProperty( m_engine.getWikiProperties(), "jspwiki.ajax.url.prefix", "ajax" ) + "/";
+        PATH_AJAX = "/" + TextUtil.getStringProperty( m_engine.getWikiProperties(), "jspwiki.ajax.url.prefix", "ajax" ) + "/";
         log.info( "WikiAjaxDispatcherServlet initialized." );
     }
 


[jspwiki] 19/20: update portable binaries to tomcat 8.5.51

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 cbcdd3c6f521c5fcd39c5db86eba071bd8e34bae
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Feb 27 16:03:34 2020 +0100

    update portable binaries to tomcat 8.5.51
---
 .../tomcat/woas.app/Contents/Java/bootstrap.jar    | Bin 35203 -> 35204 bytes
 .../tomcat/woas.app/Contents/Java/tomcat-juli.jar  | Bin 49903 -> 49783 bytes
 .../src/overlay/launchers/tomcat/woas.exe          | Bin 3493354 -> 3500245 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 c84e05e..95efd4c 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 f00f867..16d0177 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 38ad409..ab59538 100644
Binary files a/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe and b/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe differ


[jspwiki] 18/20: update flexmark to 0.60.2

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 1e578aa6d8f17a82184c78ec488cbd57cded23f2
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Feb 27 00:07:22 2020 +0100

    update flexmark to 0.60.2
---
 .../java/org/apache/wiki/markdown/renderer/JSPWikiLinkRenderer.java    | 3 +--
 .../org/apache/wiki/markdown/renderer/JSPWikiNodeRendererFactory.java  | 2 +-
 .../main/java/org/apache/wiki/parser/markdown/MarkdownDocument.java    | 2 +-
 pom.xml                                                                | 2 +-
 4 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/renderer/JSPWikiLinkRenderer.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/renderer/JSPWikiLinkRenderer.java
index 70895c7..6b7c760 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/renderer/JSPWikiLinkRenderer.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/renderer/JSPWikiLinkRenderer.java
@@ -18,7 +18,6 @@
 */
 package org.apache.wiki.markdown.renderer;
 
-import com.vladsch.flexmark.html.CustomNodeRenderer;
 import com.vladsch.flexmark.html.HtmlWriter;
 import com.vladsch.flexmark.html.renderer.LinkType;
 import com.vladsch.flexmark.html.renderer.NodeRenderer;
@@ -44,7 +43,7 @@ public class JSPWikiLinkRenderer implements NodeRenderer {
     @Override
     public Set< NodeRenderingHandler< ? > > getNodeRenderingHandlers() {
         final HashSet< NodeRenderingHandler< ? > > set = new HashSet<>();
-        set.add( new NodeRenderingHandler<>( JSPWikiLink.class, new CustomNodeRenderer< JSPWikiLink >() {
+        set.add( new NodeRenderingHandler<>( JSPWikiLink.class, new NodeRenderingHandler.CustomNodeRenderer< JSPWikiLink >() {
 
             /**
              * {@inheritDoc}
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/renderer/JSPWikiNodeRendererFactory.java b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/renderer/JSPWikiNodeRendererFactory.java
index 147a757..ce376b9 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/renderer/JSPWikiNodeRendererFactory.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/markdown/renderer/JSPWikiNodeRendererFactory.java
@@ -50,7 +50,7 @@ public class JSPWikiNodeRendererFactory implements DelegatingNodeRendererFactory
      * {@inheritDoc}
      */
     @Override
-    public Set< Class< ? extends NodeRendererFactory > > getDelegates() {
+    public Set< Class< ? > > getDelegates() {
         // return null if renderer does not delegate or delegates only to core node renderer
         return null;
     }
diff --git a/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownDocument.java b/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownDocument.java
index b8b0e28..e441a0a 100755
--- a/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownDocument.java
+++ b/jspwiki-markdown/src/main/java/org/apache/wiki/parser/markdown/MarkdownDocument.java
@@ -23,8 +23,8 @@ import com.vladsch.flexmark.ext.toc.TocExtension;
 import com.vladsch.flexmark.parser.Parser;
 import com.vladsch.flexmark.parser.ParserEmulationProfile;
 import com.vladsch.flexmark.util.ast.Node;
-import com.vladsch.flexmark.util.builder.Extension;
 import com.vladsch.flexmark.util.data.MutableDataSet;
+import com.vladsch.flexmark.util.misc.Extension;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.markdown.MarkdownForJSPWikiExtension;
diff --git a/pom.xml b/pom.xml
index c7c6a65..b3def41 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,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.50</flexmark.version>
+    <flexmark.version>0.60.2</flexmark.version>
     <freshcookies-security.version>0.60</freshcookies-security.version>
     <gson.version>2.8.5</gson.version>
     <hsqldb.version>2.5.0</hsqldb.version>