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/03/21 17:04:02 UTC

[jspwiki] branch master updated (6929dc2 -> 3404df2)

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 6929dc2  apply format suggested by intellij
     new d5bcff7  move test adaptees to src/test + generate test-jar in order to not have to exclude coverage metrics from jspwiki-210-test-adaptees (it doesn't make sense, it's test code)
     new bdab6f2  catch rare NPE + provide some tests
     new 8742454  WikiPageProvider should extend o.a.w.WikiProvider, not o.a.w.api.providers.WikiProvider
     new 466f2be  o.a.w.search classes don't need to extend their counterparts from o.a.w.api.search
     new ced752b  added new adapter to convert classes between o.a.w.search and o.a.w.api.search
     new 3338f0c  JSPWIKI-303: move back to jspwiki-main o.a.w.search.QueryItem and o.a.w.search.SearchResult
     new b48d88f  add back constructors to ensure page/attachment backwards compatibility
     new 9c00c58  add missing Apache License
     new 3c3dcea  code format
     new 5a89dba  use constant from AttachmentProvider
     new 2bae34f  change comment in jspwiki.properties so it aligns with property's default value
     new 0de5b15  added new static methods on TestEngine to ease creation ofinstances with custom properties
     new 1f95c37  complete javadocs
     new c92bb4d  add missing Apache License to tests
     new cd501d2  JSPWIKI-303: provide backwards compatibility with public API for page/attachment providers not using it
     new 6aef232  update dependencies:
     new 559f94b  update portable launchers to tomcat 9.0.33
     new d98d205  mark constructors using WikiEngine as deprecated
     new 2f68a41  use Context instead of WikiContext
     new a3bacfa  extract all commands to its own class in order to break class cycles
     new 1c3c14b  use Context instead of WikiContext
     new 7c5fb15  mark constructors using WikiEngine as deprecated
     new 01b2adf  use Page insead of WikiPage
     new 445716e  apply suggested format by intellij
     new 8758178  refactor tests so they only build a TestEngine instance per class instead of per test
     new 4d44357  add missing Apache License
     new 084c501  use Context instead of WikiContext
     new b7597bf  extract isJSPWikiPermission to PermissionChecks class in order to break some class cycles
     new 7377ff9  use Context and Page instead of WikiContext and WikiPage
     new 3d99319  use getManager( XYZ.class ) instead of getXYZManager methods of WikiEngine
     new a493a16  reorganized WikiEngine initialization, to ease generalization of managers' creation and configuration later on
     new 3806007  move rss initialization from WikiEngine into RSSGenerator
     new eae6861  use Context instead of Wikicontext
     new 078122f  Extract interface + rename from RSSGenerator
     new 1059775  push default methods on GroupManager to implementation on DefaultGroupManager
     new 3404df2  2.11.0-M7-git-14

The 36 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                                       |  22 ++
 jspwiki-210-adapters/pom.xml                       |   5 +-
 .../main/java/org/apache/wiki/WikiProvider.java    |  14 +-
 .../org/apache/wiki/api/plugin/WikiPlugin.java     |   3 +-
 .../org/apache/wiki/providers/SearchAdapter.java   |  58 +++
 .../providers/WikiAttachmentAdapterProvider.java   | 150 ++++++++
 .../wiki/providers/WikiPageAdapterProvider.java    | 169 +++++++++
 .../apache/wiki/providers/WikiPageProvider.java    |   2 +-
 .../org/apache/wiki/filters/FilterFrom210Test.java |  19 +-
 .../org/apache/wiki/plugin/PluginFrom210Test.java  |  18 +
 .../apache/wiki/providers/SearchAdapterTest.java   |  65 ++++
 .../wiki/providers/WikiProviderAdaptersTest.java   | 113 ++++++
 jspwiki-210-test-adaptees/pom.xml                  |  25 ++
 .../java/com/example/filters/TwoXFilter.java       |  18 +
 .../java/com/example/filters/TwoXFilterTest.java   |  34 --
 .../java/com/example/plugins/TwoXPlugin.java       |   0
 .../java/com/example/plugins/TwoXPluginTest.java   |  33 --
 .../providers/TwoXWikiAttachmentProvider.java      | 198 ++++++++++
 .../example/providers/TwoXWikiPageProvider.java    | 206 ++++++++++
 .../src/main/java/org/apache/wiki/api/Release.java |   2 +-
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 121 +++---
 .../src/main/java/org/apache/wiki/WikiPage.java    |  19 +-
 .../wiki/ajax/WikiAjaxDispatcherServlet.java       |   2 +-
 .../org/apache/wiki/attachment/Attachment.java     |  14 +
 .../apache/wiki/attachment/AttachmentManager.java  |   5 +-
 .../wiki/attachment/DefaultAttachmentManager.java  |   5 +-
 .../wiki/attachment/DynamicAttachmentProvider.java |   4 +-
 .../org/apache/wiki/auth/AuthorizationManager.java |  10 +-
 .../wiki/auth/DefaultAuthorizationManager.java     |   2 +-
 .../org/apache/wiki/auth/DefaultUserManager.java   |   6 +-
 .../java/org/apache/wiki/auth/UserManager.java     |   6 +-
 .../wiki/auth/authorize/DefaultGroupManager.java   |  34 ++
 .../apache/wiki/auth/authorize/GroupManager.java   |  37 +-
 .../wiki/auth/permissions/AllPermission.java       | 111 +++---
 .../auth/permissions/AllPermissionCollection.java  |  14 +-
 .../wiki/auth/permissions/PermissionChecks.java    |  24 +-
 .../apache/wiki/content/DefaultPageRenamer.java    |  26 +-
 .../java/org/apache/wiki/content/PageRenamer.java  |   4 +-
 .../apache/wiki/plugin/DefaultPluginManager.java   | 236 +++---------
 .../java/org/apache/wiki/plugin/PluginManager.java |  22 +-
 .../org/apache/wiki/preferences/Preferences.java   | 151 +++-----
 .../wiki/providers/AbstractFileProvider.java       |   4 +-
 .../wiki/providers/BasicAttachmentProvider.java    |   7 +-
 .../apache/wiki/providers/FileSystemProvider.java  |   4 +-
 .../wiki/providers/VersioningFileProvider.java     |  10 +-
 ...{RSSGenerator.java => DefaultRSSGenerator.java} | 210 +++--------
 .../java/org/apache/wiki/rss/RSSGenerator.java     | 416 ++++-----------------
 .../java/org/apache/wiki/search/QueryItem.java     |   0
 .../java/org/apache/wiki/search/SearchMatcher.java |  21 +-
 .../java/org/apache/wiki/search/SearchResult.java  |   0
 .../java/org/apache/wiki/ui/AbstractCommand.java   |  56 +--
 .../main/java/org/apache/wiki/ui/AllCommands.java  |  67 ++++
 .../java/org/apache/wiki/ui/CommandResolver.java   |   4 +-
 .../org/apache/wiki/ui/DefaultCommandResolver.java |   2 +-
 .../org/apache/wiki/ui/DefaultEditorManager.java   |   5 +-
 .../java/org/apache/wiki/ui/EditorManager.java     |   6 +-
 .../org/apache/wiki/ui/GenericHTTPHandler.java     |   7 +-
 .../java/org/apache/wiki/ui/InputValidator.java    |  31 +-
 .../main/java/org/apache/wiki/ui/Installer.java    |   4 +-
 .../main/java/org/apache/wiki/ui/PageCommand.java  |  12 +-
 .../org/apache/wiki/ui/admin/SimpleAdminBean.java  |   6 +-
 .../apache/wiki/ui/admin/WikiFormAdminBean.java    |  35 +-
 .../org/apache/wiki/ui/admin/beans/ModuleBean.java |   3 +-
 .../wiki/ui/admin/beans/PlainEditorAdminBean.java  |  55 ++-
 .../wiki/ui/admin/beans/SearchManagerBean.java     |   6 +-
 .../org/apache/wiki/ui/admin/beans/UserBean.java   |   4 +-
 .../src/main/resources/ini/classmappings.xml       |   4 +
 .../src/main/resources/ini/jspwiki.properties      |   2 +-
 .../src/test/java/org/apache/wiki/TestEngine.java  |  80 ++--
 .../test/java/org/apache/wiki/WikiEngineTest.java  |  26 +-
 .../test/java/org/apache/wiki/WikiSessionTest.java |   4 +-
 .../wiki/attachment/AttachmentManagerTest.java     |   2 +-
 .../wiki/auth/AuthenticationManagerTest.java       |   6 +-
 .../apache/wiki/auth/AuthorizationManagerTest.java |  19 +-
 .../java/org/apache/wiki/auth/UserManagerTest.java |   6 +-
 .../java/org/apache/wiki/auth/acl/AclImplTest.java |  76 ++--
 .../wiki/auth/acl/DefaultAclManagerTest.java       |   6 +-
 .../auth/login/CookieAssertionLoginModuleTest.java |  63 ++--
 .../org/apache/wiki/auth/user/UserProfileTest.java |  53 +--
 .../org/apache/wiki/content/PageRenamerTest.java   |  58 +--
 .../apache/wiki/pages/DefaultPageManagerTest.java  |  21 +-
 .../wiki/parser/JSPWikiMarkupParserTest.java       |   6 +-
 .../wiki/plugin/DefaultPluginManagerTest.java      |   3 +-
 .../java/org/apache/wiki/plugin/GroupsTest.java    |   3 +-
 .../java/org/apache/wiki/plugin/IfPluginTest.java  |  12 +-
 .../org/apache/wiki/plugin/PageViewPluginTest.java |  37 +-
 .../wiki/plugin/RecentChangesPluginTest.java       |  22 +-
 .../providers/BasicAttachmentProviderTest.java     |   4 +-
 .../wiki/providers/FileSystemProviderTest.java     |  97 +++--
 .../wiki/references/ReferenceManagerTest.java      |   2 +-
 .../apache/wiki/render/RenderingManagerTest.java   |  16 +-
 .../java/org/apache/wiki/rss/RSSGeneratorTest.java |   8 +-
 .../org/apache/wiki/search/SearchManagerTest.java  |   2 +-
 .../apache/wiki/stress/MassiveRepositoryTest.java  |   3 +-
 .../org/apache/wiki/ui/CommandResolverTest.java    |   2 +-
 .../apache/wiki/workflow/ApprovalWorkflowTest.java |  10 +-
 .../apache/wiki/workflow/DecisionQueueTest.java    |   6 +-
 .../java/org/apache/wiki/workflow/OutcomeTest.java |  91 ++---
 .../apache/wiki/workflow/WorkflowManagerTest.java  |  22 +-
 .../org/apache/wiki/xmlrpc/RPCHandlerTest.java     |   5 +-
 .../wiki/render/markdown/MarkdownRendererTest.java |   3 +-
 .../tomcat/woas.app/Contents/Java/bootstrap.jar    | Bin 35071 -> 35071 bytes
 .../tomcat/woas.app/Contents/Java/tomcat-juli.jar  | Bin 47886 -> 49372 bytes
 .../src/overlay/launchers/tomcat/woas.exe          | Bin 3564962 -> 3575670 bytes
 .../wiki/search/tika/TikaSearchProviderTest.java   |   3 +-
 .../main/java/org/apache/wiki/util/HttpUtil.java   |  13 +-
 .../java/org/apache/wiki/util/HttpUtilTest.java    |  19 +
 pom.xml                                            |   8 +-
 108 files changed, 2138 insertions(+), 1667 deletions(-)
 create mode 100644 jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/SearchAdapter.java
 create mode 100644 jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiAttachmentAdapterProvider.java
 create mode 100644 jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiPageAdapterProvider.java
 create mode 100644 jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/SearchAdapterTest.java
 create mode 100644 jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/WikiProviderAdaptersTest.java
 rename jspwiki-210-test-adaptees/src/{main => test}/java/com/example/filters/TwoXFilter.java (63%)
 delete mode 100644 jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilterTest.java
 rename jspwiki-210-test-adaptees/src/{main => test}/java/com/example/plugins/TwoXPlugin.java (100%)
 delete mode 100644 jspwiki-210-test-adaptees/src/test/java/com/example/plugins/TwoXPluginTest.java
 create mode 100644 jspwiki-210-test-adaptees/src/test/java/com/example/providers/TwoXWikiAttachmentProvider.java
 create mode 100644 jspwiki-210-test-adaptees/src/test/java/com/example/providers/TwoXWikiPageProvider.java
 copy jspwiki-api/src/main/java/org/apache/wiki/api/exceptions/FilterException.java => jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/PermissionChecks.java (58%)
 copy jspwiki-main/src/main/java/org/apache/wiki/rss/{RSSGenerator.java => DefaultRSSGenerator.java} (64%)
 rename {jspwiki-210-adapters => jspwiki-main}/src/main/java/org/apache/wiki/search/QueryItem.java (100%)
 rename {jspwiki-210-adapters => jspwiki-main}/src/main/java/org/apache/wiki/search/SearchResult.java (100%)
 create mode 100644 jspwiki-main/src/main/java/org/apache/wiki/ui/AllCommands.java


[jspwiki] 01/36: move test adaptees to src/test + generate test-jar in order to not have to exclude coverage metrics from jspwiki-210-test-adaptees (it doesn't make sense, it's test code)

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

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

commit d5bcff788cc5ac58cf1b5d226033f160f22ad2ed
Author: juanpablo <ju...@apache.org>
AuthorDate: Tue Mar 17 21:59:32 2020 +0100

    move test adaptees to src/test + generate test-jar in order to not have to exclude coverage metrics from jspwiki-210-test-adaptees (it doesn't make sense, it's test code)
---
 jspwiki-210-adapters/pom.xml                       |  5 ++--
 jspwiki-210-test-adaptees/pom.xml                  | 25 ++++++++++++++++
 .../java/com/example/filters/TwoXFilter.java       |  0
 .../java/com/example/filters/TwoXFilterTest.java   | 34 ----------------------
 .../java/com/example/plugins/TwoXPlugin.java       |  0
 .../java/com/example/plugins/TwoXPluginTest.java   | 33 ---------------------
 6 files changed, 28 insertions(+), 69 deletions(-)

diff --git a/jspwiki-210-adapters/pom.xml b/jspwiki-210-adapters/pom.xml
index cde8e1c..fb4b58b 100644
--- a/jspwiki-210-adapters/pom.xml
+++ b/jspwiki-210-adapters/pom.xml
@@ -27,7 +27,7 @@
 
   <modelVersion>4.0.0</modelVersion>
   <artifactId>jspwiki-210-adapters</artifactId>
-  <name>Apache JSPWiki adapters for extensions not using public api</name>
+  <name>Apache JSPWiki adapters for pre-public api</name>
 
   <dependencies>
     <dependency>
@@ -67,8 +67,9 @@
     <dependency>
       <groupId>${project.groupId}</groupId>
       <artifactId>jspwiki-210-test-adaptees</artifactId>
-      <scope>test</scope>
       <version>${project.version}</version>
+      <type>test-jar</type>
+      <scope>test</scope>
     </dependency>
 
     <dependency>
diff --git a/jspwiki-210-test-adaptees/pom.xml b/jspwiki-210-test-adaptees/pom.xml
index f8b1a4f..2512784 100644
--- a/jspwiki-210-test-adaptees/pom.xml
+++ b/jspwiki-210-test-adaptees/pom.xml
@@ -67,4 +67,29 @@
       <scope>test</scope>
     </dependency>
   </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>test-jar</goal>
+            </goals>
+            <phase>package</phase>
+            <configuration>
+              <excludes>
+                <exclude>**/test*/**</exclude>
+                <exclude>**/*Test.class</exclude>
+                <exclude>**/*Test$*.class</exclude>
+                <exclude>**/*Tests.class</exclude>
+              </excludes>
+              <skipIfEmpty>true</skipIfEmpty>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
 </project>
diff --git a/jspwiki-210-test-adaptees/src/main/java/com/example/filters/TwoXFilter.java b/jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilter.java
similarity index 100%
rename from jspwiki-210-test-adaptees/src/main/java/com/example/filters/TwoXFilter.java
rename to jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilter.java
diff --git a/jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilterTest.java b/jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilterTest.java
deleted file mode 100644
index cb682c0..0000000
--- a/jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilterTest.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
- */
-package com.example.filters;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-
-public class TwoXFilterTest {
-
-    @Test
-    public void testFilter() throws Exception {
-        final TwoXFilter txf = new TwoXFilter();
-        txf.initialize( null, null );
-        Assertions.assertEquals("see how I care about yor content - hmmm...", txf.postTranslate( null, null ) );
-    }
-
-}
diff --git a/jspwiki-210-test-adaptees/src/main/java/com/example/plugins/TwoXPlugin.java b/jspwiki-210-test-adaptees/src/test/java/com/example/plugins/TwoXPlugin.java
similarity index 100%
rename from jspwiki-210-test-adaptees/src/main/java/com/example/plugins/TwoXPlugin.java
rename to jspwiki-210-test-adaptees/src/test/java/com/example/plugins/TwoXPlugin.java
diff --git a/jspwiki-210-test-adaptees/src/test/java/com/example/plugins/TwoXPluginTest.java b/jspwiki-210-test-adaptees/src/test/java/com/example/plugins/TwoXPluginTest.java
deleted file mode 100644
index 6d54680..0000000
--- a/jspwiki-210-test-adaptees/src/test/java/com/example/plugins/TwoXPluginTest.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-    Licensed to the Apache Software Foundation (ASF) under one
-    or more contributor license agreements.  See the NOTICE file
-    distributed with this work for additional information
-    regarding copyright ownership.  The ASF licenses this file
-    to you under the Apache License, Version 2.0 (the
-    "License"); you may not use this file except in compliance
-    with the License.  You may obtain a copy of the License at
-
-       http://www.apache.org/licenses/LICENSE-2.0
-
-    Unless required by applicable law or agreed to in writing,
-    software distributed under the License is distributed on an
-    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-    KIND, either express or implied.  See the License for the
-    specific language governing permissions and limitations
-    under the License.
- */
-package com.example.plugins;
-
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
-
-public class TwoXPluginTest {
-	
-    @Test
-	public void testPlugin() throws Exception {
-		final TwoXPlugin txp = new TwoXPlugin();
-		Assertions.assertEquals("hakuna matata", txp.execute( null, null ) );
-	}
-
-}


[jspwiki] 18/36: mark constructors using WikiEngine as deprecated

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 d98d205bb07eed3cbdacfc429b2d23778beb208f
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 14:09:28 2020 +0100

    mark constructors using WikiEngine as deprecated
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java      | 11 ++++++-----
 .../src/main/java/org/apache/wiki/attachment/Attachment.java  |  2 ++
 2 files changed, 8 insertions(+), 5 deletions(-)

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 36412f3..f76dcec 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
@@ -65,11 +65,13 @@ public class WikiPage implements Page {
     }
 
     /**
-     *  Create a new WikiPage using a given engine and name.
+     * Create a new WikiPage using a given engine and name.
      *
-     *  @param engine The Engine that owns this page.
-     *  @param name   The name of the page.
+     * @param engine The Engine that owns this page.
+     * @param name   The name of the page.
+     * @deprecated kept for compatibility with page/attachment providers not using public API. Use {@code WikiPage(Engine, String)} instead.
      */
+    @Deprecated
     public WikiPage( final WikiEngine engine, final String name ) {
         this( ( Engine )engine, name );
     }
@@ -160,8 +162,7 @@ public class WikiPage implements Page {
      *  @param date The date
      */
     @Override
-    public void setLastModified( final Date date )
-    {
+    public void setLastModified( final Date date ) {
         m_lastModified = date;
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
index 3b47033..22748c9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
@@ -51,7 +51,9 @@ public class Attachment extends WikiPage implements org.apache.wiki.api.core.Att
      * @param engine     The Engine which is hosting this attachment.
      * @param parentPage The page which will contain this attachment.
      * @param fileName   The file name for the attachment.
+     * @deprecated kept for compatibility with page/attachment providers not using public API. Use {@code Attachment(Engine, String, String)} instead.
      */
+    @Deprecated
     public Attachment( final WikiEngine engine, final String parentPage, final String fileName ) {
         this( ( Engine )engine, parentPage, fileName );
     }


[jspwiki] 33/36: use Context instead of Wikicontext

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

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

commit eae68614959e762e0fd21daffdc94eebc147aa4b
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 17:45:15 2020 +0100

    use Context instead of Wikicontext
---
 .../org/apache/wiki/preferences/Preferences.java   | 27 ++++++++++------------
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/preferences/Preferences.java b/jspwiki-main/src/main/java/org/apache/wiki/preferences/Preferences.java
index 7c3639a..b1ae4c2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/preferences/Preferences.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/preferences/Preferences.java
@@ -85,15 +85,13 @@ public class Preferences extends HashMap< String,String > {
      *
      *  @param pageContext The page context.
      */
-    // FIXME: The way that date preferences are chosen is currently a bit wacky: it all
-    //        gets saved to the cookie based on the browser state with which the user
-    //        happened to first arrive to the site with.  This, unfortunately, means that
-    //        even if the user changes e.g. language preferences (like in a web cafe),
-    //        the old preferences still remain in a site cookie.
+    // FIXME: The way that date preferences are chosen is currently a bit wacky: it all gets saved to the cookie based on the browser state
+    //        with which the user happened to first arrive to the site with.  This, unfortunately, means that even if the user changes e.g.
+    //        language preferences (like in a web cafe), the old preferences still remain in a site cookie.
     public static void reloadPreferences( final PageContext pageContext ) {
         final Preferences prefs = new Preferences();
         final Properties props = PropertyReader.loadWebAppProps( pageContext.getServletContext() );
-        final WikiContext ctx = WikiContext.findContext( pageContext );
+        final Context ctx = WikiContext.findContext( pageContext );
         final String dateFormat = ctx.getEngine().getManager( InternationalizationManager.class )
                                            .get( InternationalizationManager.CORE_BUNDLE, getLocale( ctx ), "common.datetimeformat" );
 
@@ -130,16 +128,14 @@ public class Preferences extends HashMap< String,String > {
      */
 	private static void parseJSONPreferences( final HttpServletRequest request, final Preferences prefs ) {
         final String prefVal = TextUtil.urlDecodeUTF8( HttpUtil.retrieveCookieValue( request, "JSPWikiUserPrefs" ) );
-
         if( prefVal != null ) {
             // Convert prefVal JSON to a generic hashmap
-            @SuppressWarnings("unchecked") final Map<String,String> map = new Gson().fromJson(prefVal, Map.class );
-
-            for (String key : map.keySet()) {
+            @SuppressWarnings( "unchecked" ) final Map< String, String > map = new Gson().fromJson( prefVal, Map.class );
+            for( String key : map.keySet() ) {
                 key = TextUtil.replaceEntities( key );
                 // Sometimes this is not a String as it comes from the Cookie set by Javascript
-                final Object value = map.get(key);
-                if (value != null) {
+                final Object value = map.get( key );
+                if( value != null ) {
                     prefs.put( key, value.toString() );
                 }
             }
@@ -156,10 +152,11 @@ public class Preferences extends HashMap< String,String > {
      */
     public static String getPreference( final Context wikiContext, final String name ) {
         final HttpServletRequest request = wikiContext.getHttpRequest();
-        if ( request == null ) return null;
+        if ( request == null ) {
+            return null;
+        }
 
         final Preferences prefs = (Preferences)request.getSession().getAttribute( SESSIONPREFS );
-
         if( prefs != null ) {
             return prefs.get( name );
         }
@@ -239,7 +236,7 @@ public class Preferences extends HashMap< String,String > {
      * Locates the i18n ResourceBundle given.  This method interprets the request locale, and uses that to figure out which language the
      * user wants.
      *
-     * @param context {@link WikiContext} holding the user's locale
+     * @param context {@link Context} holding the user's locale
      * @param bundle  The name of the bundle you are looking for.
      * @return A localized string (or from the default language, if not found)
      * @throws MissingResourceException If the bundle cannot be found


[jspwiki] 21/36: use Context instead of WikiContext

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

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

commit 1c3c14b1d9c9adc3c89d88a71988cb77f23f52d0
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 14:15:02 2020 +0100

    use Context instead of WikiContext
---
 .../apache/wiki/plugin/DefaultPluginManager.java   | 236 ++++++---------------
 .../java/org/apache/wiki/plugin/PluginManager.java |  22 +-
 2 files changed, 72 insertions(+), 186 deletions(-)

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 a0db25b..02a5fbb 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
@@ -30,7 +30,6 @@ import org.apache.oro.text.regex.PatternMatcher;
 import org.apache.oro.text.regex.Perl5Compiler;
 import org.apache.oro.text.regex.Perl5Matcher;
 import org.apache.wiki.InternalWikiException;
-import org.apache.wiki.WikiContext;
 import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
 import org.apache.wiki.ajax.WikiAjaxServlet;
 import org.apache.wiki.api.core.Context;
@@ -160,23 +159,16 @@ import java.util.StringTokenizer;
 public class DefaultPluginManager extends BaseModuleManager implements PluginManager {
 
     private static final String PLUGIN_INSERT_PATTERN = "\\{?(INSERT)?\\s*([\\w\\._]+)[ \\t]*(WHERE)?[ \\t]*";
-
     private static final Logger log = Logger.getLogger( DefaultPluginManager.class );
-
     private static final String DEFAULT_FORMS_PACKAGE = "org.apache.wiki.forms";
 
-    private ArrayList<String> m_searchPath = new ArrayList<>();
-
-    private ArrayList<String> m_externalJars = new ArrayList<>();
-
+    private ArrayList< String > m_searchPath = new ArrayList<>();
+    private ArrayList< String > m_externalJars = new ArrayList<>();
     private Pattern m_pluginPattern;
-
     private boolean m_pluginsEnabled = true;
 
-    /**
-     *  Keeps a list of all known plugin classes.
-     */
-    private Map<String, WikiPluginInfo> m_pluginClassMap = new HashMap<>();
+    /** Keeps a list of all known plugin classes. */
+    private Map< String, WikiPluginInfo > m_pluginClassMap = new HashMap<>();
 
     /**
      *  Create a new PluginManager.
@@ -187,20 +179,16 @@ public class DefaultPluginManager extends BaseModuleManager implements PluginMan
     public DefaultPluginManager( final Engine engine, final Properties props ) {
         super( engine );
         final String packageNames = props.getProperty( PROP_SEARCHPATH );
-
         if ( packageNames != null ) {
             final StringTokenizer tok = new StringTokenizer( packageNames, "," );
-
             while( tok.hasMoreTokens() ) {
                 m_searchPath.add( tok.nextToken().trim() );
             }
         }
 
         final String externalJars = props.getProperty( PROP_EXTERNALJARS );
-
         if( externalJars != null ) {
             final StringTokenizer tok = new StringTokenizer( externalJars, "," );
-
             while( tok.hasMoreTokens() ) {
                 m_externalJars.add( tok.nextToken().trim() );
             }
@@ -208,50 +196,38 @@ public class DefaultPluginManager extends BaseModuleManager implements PluginMan
 
         registerPlugins();
 
-        //
         //  The default packages are always added.
-        //
         m_searchPath.add( DEFAULT_PACKAGE );
         m_searchPath.add( DEFAULT_FORMS_PACKAGE );
 
         final PatternCompiler compiler = new Perl5Compiler();
-
         try {
             m_pluginPattern = compiler.compile( PLUGIN_INSERT_PATTERN );
         } catch( final MalformedPatternException e ) {
             log.fatal( "Internal error: someone messed with pluginmanager patterns.", e );
-            throw new InternalWikiException( "PluginManager patterns are broken" , e);
+            throw new InternalWikiException( "PluginManager patterns are broken" , e );
         }
-
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     public void enablePlugins( final boolean enabled ) {
         m_pluginsEnabled = enabled;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     public boolean pluginsEnabled() {
         return m_pluginsEnabled;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     public Pattern getPluginPattern() {
 		return m_pluginPattern;
 	}
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     @Override
     public String getPluginSearchPath() {
     	return TextUtil.getStringProperty( m_engine.getWikiProperties(), PROP_SEARCHPATH, null );
@@ -260,61 +236,34 @@ public class DefaultPluginManager extends BaseModuleManager implements PluginMan
 	/**
      *  Attempts to locate a plugin class from the class path set in the property file.
      *
-     *  @param classname Either a fully fledged class name, or just the name of the file (that is,
-     *  "org.apache.wiki.plugin.Counter" or just plain "Counter").
-     *
+     *  @param classname Either a fully fledged class name, or just the name of the file (that is, "org.apache.wiki.plugin.Counter" or just plain "Counter").
      *  @return A found class.
-     *
      *  @throws ClassNotFoundException if no such class exists.
      */
     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( final Map<String,String> params, final Throwable t )
-    {
-        final Element div = XhtmlUtil.element(XHTML.div,"Plugin execution failed, stack trace follows:");
-        div.setAttribute(XHTML.ATTR_class,"debug");
-
+    /** Outputs a HTML-formatted version of a stack trace. */
+    private String stackTrace( final Map<String,String> params, final Throwable t ) {
+        final Element div = XhtmlUtil.element( XHTML.div, "Plugin execution failed, stack trace follows:" );
+        div.setAttribute( XHTML.ATTR_class, "debug" );
 
         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"));
-
-        final Element list = XhtmlUtil.element(XHTML.ul);
+        t.printStackTrace( new PrintWriter( out ) );
+        div.addContent( XhtmlUtil.element( XHTML.pre, out.toString() ) );
+        div.addContent( XhtmlUtil.element( XHTML.b, "Parameters to the plugin" ) );
 
+        final Element list = XhtmlUtil.element( XHTML.ul );
         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);
-
-        return XhtmlUtil.serialize(div);
+        div.addContent( list );
+        return XhtmlUtil.serialize( div );
     }
 
-    /**
-     *  Executes a plugin class in the given context.
-     *  <P>Used to be private, but is public since 1.9.21.
-     *
-     *  @param context The current WikiContext.
-     *  @param classname The name of the class.  Can also be a
-     *  shortened version without the package name, since the class name is searched from the
-     *  package search path.
-     *
-     *  @param params A parsed map of key-value pairs.
-     *
-     *  @return Whatever the plugin returns.
-     *
-     *  @throws PluginException If the plugin execution failed for
-     *  some reason.
-     *
-     *  @since 2.0
-     */
+    /** {@inheritDoc} */
     @Override
     public String execute( final Context context, final String classname, final Map< String, String > params ) throws PluginException {
         if( !m_pluginsEnabled ) {
@@ -355,110 +304,75 @@ public class DefaultPluginManager extends BaseModuleManager implements PluginMan
         }
     }
 
-    /**
-     *  Parses plugin arguments.  Handles quotes and all other kewl stuff.
-     *
-     *  <h3>Special parameters</h3>
-     *  The plugin body is put into a special parameter defined by {@link #PARAM_BODY};
-     *  the plugin's command line into a parameter defined by {@link #PARAM_CMDLINE};
-     *  and the bounds of the plugin within the wiki page text by a parameter defined
-     *  by {@link #PARAM_BOUNDS}, whose value is stored as a two-element int[] array,
-     *  i.e., <tt>[start,end]</tt>.
-     *
-     * @param argstring The argument string to the plugin.  This is
-     *  typically a list of key-value pairs, using "'" to escape
-     *  spaces in strings, followed by an empty line and then the
-     *  plugin body.  In case the parameter is null, will return an
-     *  empty parameter list.
-     *
-     * @return A parsed list of parameters.
-     *
-     * @throws IOException If the parsing fails.
-     */
+    /** {@inheritDoc} */
     @Override
     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;
         }
 
         arglist.put( PARAM_CMDLINE, argstring );
-
-        final StringReader    in      = new StringReader(argstring);
-        final StreamTokenizer tok     = new StreamTokenizer(in);
-        int             type;
+        final StringReader in = new StringReader( argstring );
+        final StreamTokenizer tok = new StreamTokenizer( in );
+        tok.eolIsSignificant( true );
 
         String param = null;
         String value;
-
-        tok.eolIsSignificant( true );
-
         boolean potentialEmptyLine = false;
-        boolean quit               = false;
-
+        boolean quit = false;
         while( !quit ) {
             final String s;
-            type = tok.nextToken();
+            final int type = tok.nextToken();
 
             switch( type ) {
-              case StreamTokenizer.TT_EOF:
+            case StreamTokenizer.TT_EOF:
                 quit = true;
                 s = null;
                 break;
 
-              case StreamTokenizer.TT_WORD:
+            case StreamTokenizer.TT_WORD:
                 s = tok.sval;
                 potentialEmptyLine = false;
                 break;
 
-              case StreamTokenizer.TT_EOL:
+            case StreamTokenizer.TT_EOL:
                 quit = potentialEmptyLine;
                 potentialEmptyLine = true;
                 s = null;
                 break;
 
-              case StreamTokenizer.TT_NUMBER:
-                s = Integer.toString( (int) tok.nval );
+            case StreamTokenizer.TT_NUMBER:
+                s = Integer.toString( ( int )tok.nval );
                 potentialEmptyLine = false;
                 break;
 
-              case '\'':
+            case '\'':
                 s = tok.sval;
                 break;
 
-              default:
+            default:
                 s = null;
             }
 
-            //
-            //  Assume that alternate words on the line are
-            //  parameter and value, respectively.
-            //
+            //  Assume that alternate words on the line are parameter and value, respectively.
             if( s != null ) {
                 if( param == null ) {
                     param = s;
                 } else {
                     value = s;
-
                     arglist.put( param, value );
-
-                    // log.debug("ARG: "+param+"="+value);
                     param = null;
                 }
             }
         }
 
-        //
         //  Now, we'll check the body.
-        //
         if( potentialEmptyLine ) {
             final StringWriter out = new StringWriter();
             FileUtil.copyContents( in, out );
-
             final String bodyContent = out.toString();
-
             if( bodyContent != null ) {
                 arglist.put( PARAM_BODY, bodyContent );
             }
@@ -467,22 +381,9 @@ public class DefaultPluginManager extends BaseModuleManager implements PluginMan
         return arglist;
     }
 
-    /**
-     *  Parses a plugin.  Plugin commands are of the form:
-     *  [{INSERT myplugin WHERE param1=value1, param2=value2}]
-     *  myplugin may either be a class name or a plugin alias.
-     *  <P>
-     *  This is the main entry point that is used.
-     *
-     *  @param context The current WikiContext.
-     *  @param commandline The full command line, including plugin name, parameters and body.
-     *
-     *  @return HTML as returned by the plugin, or possibly an error message.
-     *
-     *  @throws PluginException From the plugin itself, it propagates, waah!
-     */
+    /** {@inheritDoc} */
     @Override
-    public String execute( final WikiContext context, final String commandline ) throws PluginException {
+    public String execute( final Context context, final String commandline ) throws PluginException {
         if( !m_pluginsEnabled ) {
             return "";
         }
@@ -493,74 +394,64 @@ public class DefaultPluginManager extends BaseModuleManager implements PluginMan
         try {
             if( matcher.contains( commandline, m_pluginPattern ) ) {
                 final MatchResult res = matcher.getMatch();
-
-                final String plugin   = res.group(2);
-                final String args     = commandline.substring(res.endOffset(0),
-                                                        commandline.length() -
-                                                        (commandline.charAt(commandline.length()-1) == '}' ? 1 : 0 ) );
-                final Map<String, String> arglist  = parseArgs( args );
-
+                final String plugin = res.group( 2 );
+                final int endIndex = commandline.length() - ( commandline.charAt( commandline.length() - 1 ) == '}' ? 1 : 0 );
+                final String args = commandline.substring( res.endOffset( 0 ), endIndex );
+                final Map< String, String > arglist = parseArgs( args );
                 return execute( context, plugin, arglist );
             }
         } catch( final NoSuchElementException e ) {
-            final String msg =  "Missing parameter in plugin definition: "+commandline;
+            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( final IOException e ) {
-            final String msg = "Zyrf.  Problems with parsing arguments: "+commandline;
+            final String msg = "Zyrf.  Problems with parsing arguments: " + commandline;
             log.warn( msg, e );
             throw new PluginException( MessageFormat.format( rb.getString( "plugin.error.parsingarguments" ), commandline ) );
         }
 
-        // FIXME: We could either return an empty string "", or
-        // the original line.  If we want unsuccessful requests
+        // FIXME: We could either return an empty string "", or the original line.  If we want unsuccessful requests
         // to be invisible, then we should return an empty string.
         return commandline;
     }
 
-    /**
-     *  Register a plugin.
-     */
+    /** Register a plugin. */
     private void registerPlugin( final WikiPluginInfo pluginClass ) {
         String name;
 
-        // Registrar the plugin with the className without the package-part
+        // Register the plugin with the className without the package-part
         name = pluginClass.getName();
         if( name != null ) {
             log.debug( "Registering plugin [name]: " + name );
             m_pluginClassMap.put( name, pluginClass );
         }
 
-        // Registrar the plugin with a short convenient name.
+        // Register the plugin with a short convenient name.
         name = pluginClass.getAlias();
         if( name != null ) {
             log.debug( "Registering plugin [shortName]: " + name );
             m_pluginClassMap.put( name, pluginClass );
         }
 
-        // Registrar the plugin with the className with the package-part
+        // Register the plugin with the className with the package-part
         name = pluginClass.getClassName();
         if( name != null ) {
             log.debug( "Registering plugin [className]: " + name );
             m_pluginClassMap.put( name, pluginClass );
         }
 
-        pluginClass.initializePlugin( pluginClass, m_engine , m_searchPath, m_externalJars);
+        pluginClass.initializePlugin( pluginClass, m_engine, m_searchPath, m_externalJars );
     }
 
     private void registerPlugins() {
+        // Register all plugins which have created a resource containing its properties.
         log.info( "Registering plugins" );
         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( final Element pluginEl : plugins ) {
             final String className = pluginEl.getAttributeValue( "class" );
-            final WikiPluginInfo pluginInfo = WikiPluginInfo.newInstance( className, pluginEl ,m_searchPath, m_externalJars);
-
+            final WikiPluginInfo pluginInfo = WikiPluginInfo.newInstance( className, pluginEl ,m_searchPath, m_externalJars );
             if( pluginInfo != null ) {
                 registerPlugin( pluginInfo );
             }
@@ -569,12 +460,9 @@ public class DefaultPluginManager extends BaseModuleManager implements PluginMan
 
     /**
      *  Contains information about a bunch of plugins.
-     *
-     *
      */
-    // FIXME: This class needs a better interface to return all sorts of possible
-    //        information from the plugin XML.  In fact, it probably should have
-    //        some sort of a superclass system.
+    // FIXME: This class needs a better interface to return all sorts of possible information from the plugin XML.  In fact, it probably
+    //  should have some sort of a superclass system.
     public static final class WikiPluginInfo extends WikiModuleInfo {
 
         private String    m_className;
@@ -587,15 +475,16 @@ public class DefaultPluginManager extends BaseModuleManager implements PluginMan
         /**
          *  Creates a new plugin info object which can be used to access a plugin.
          *
-         *  @param className Either a fully qualified class name, or a "short" name which is then
-         *                   checked against the internal list of plugin packages.
+         *  @param className Either a fully qualified class name, or a "short" name which is then checked against the internal list of plugin packages.
          *  @param el A JDOM Element containing the information about this class.
          *  @param searchPath A List of Strings, containing different package names.
          *  @param externalJars the list of external jars to search
          *  @return A WikiPluginInfo object.
          */
         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;
+            if( className == null || className.length() == 0 ) {
+                return null;
+            }
 
             final WikiPluginInfo info = new WikiPluginInfo( className );
             info.initializeFromXML( el );
@@ -603,8 +492,7 @@ public class DefaultPluginManager extends BaseModuleManager implements PluginMan
         }
 
         /**
-         *  Initializes a plugin, if it has not yet been initialized.
-         *  If the plugin extends {@link HttpServlet} it will automatically
+         *  Initializes a plugin, if it has not yet been initialized. If the plugin extends {@link HttpServlet} it will automatically
          *  register it as AJAX using {@link WikiAjaxDispatcherServlet#registerServlet(String, WikiAjaxServlet)}.
          *
          *  @param engine The Engine
@@ -693,19 +581,18 @@ public class DefaultPluginManager extends BaseModuleManager implements PluginMan
          *
          *  @param searchPath A List of Strings, containing different package names.
          *  @param externalJars the list of external jars to search
-
          *  @return A new plugin.
          *  @throws ClassNotFoundException If the class declared was not found.
          *  @throws InstantiationException If the class cannot be instantiated-
          *  @throws IllegalAccessException If the class cannot be accessed.
          */
 
-        public Plugin newPluginInstance( final List<String> searchPath, final List<String> externalJars) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
+        public Plugin 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);
+                m_clazz = ClassUtil.findClass( searchPath, externalJars ,m_className );
             }
 
-            return (Plugin) m_clazz.newInstance();
+            return ( Plugin )m_clazz.newInstance();
         }
 
         /**
@@ -778,6 +665,7 @@ public class DefaultPluginManager extends BaseModuleManager implements PluginMan
         public String toString() {
             return "Plugin :[name=" + m_name + "][className=" + m_className + "]";
         }
+
     } // WikiPluginClass
 
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java
index 7ed86fb..a7fee6d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/plugin/PluginManager.java
@@ -19,7 +19,6 @@
 package org.apache.wiki.plugin;
 
 import org.apache.oro.text.regex.Pattern;
-import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.exceptions.PluginException;
 import org.apache.wiki.api.plugin.Plugin;
@@ -117,19 +116,18 @@ public interface PluginManager extends ModuleManager {
     Map< String, String > parseArgs( String argstring ) throws IOException;
 
     /**
-     * Parses a plugin.  Plugin commands are of the form:
-     * {@code [{INSERT myplugin WHERE param1=value1, param2=value2}] }
-     * myplugin may either be a class name or a plugin alias.
-     * <P>
-     * This is the main entry point that is used.
+     *  Parses a plugin.  Plugin commands are of the form:<br/>
+     *  {@code [{INSERT myplugin WHERE param1=value1, param2=value2}]}<br/>
+     *  myplugin may either be a class name or a plugin alias.
+     *  <P>
+     *  This is the main entry point that is used.
      *
-     * @param context The current WikiContext.
-     * @param commandline The full command line, including plugin name, parameters and body.
-     * @return HTML as returned by the plugin, or possibly an error message.
-     *
-     * @throws PluginException From the plugin itself, it propagates, waah!
+     *  @param context The current WikiContext.
+     *  @param commandline The full command line, including plugin name, parameters and body.
+     *  @return HTML as returned by the plugin, or possibly an error message.
+     *  @throws PluginException From the plugin itself, it propagates, waah!
      */
-    String execute( WikiContext context, String commandline ) throws PluginException;
+    String execute( Context context, String commandline ) throws PluginException;
     
     /**
      * Creates a {@link Plugin}.


[jspwiki] 29/36: use Context and Page instead of WikiContext and WikiPage

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 7377ff98dc36d32cfd7b8820c7a1cefb72801391
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 15:44:28 2020 +0100

    use Context and Page instead of WikiContext and WikiPage
---
 .../org/apache/wiki/attachment/AttachmentManager.java   |  5 ++---
 .../wiki/attachment/DefaultAttachmentManager.java       |  5 ++---
 .../wiki/attachment/DynamicAttachmentProvider.java      |  4 ++--
 .../java/org/apache/wiki/auth/AuthorizationManager.java | 10 +++++-----
 .../apache/wiki/auth/DefaultAuthorizationManager.java   |  2 +-
 .../org/apache/wiki/auth/authorize/GroupManager.java    |  8 ++++----
 .../org/apache/wiki/content/DefaultPageRenamer.java     | 17 ++++++++---------
 .../main/java/org/apache/wiki/content/PageRenamer.java  |  4 ++--
 .../src/main/java/org/apache/wiki/ui/PageCommand.java   | 12 ++++++------
 9 files changed, 32 insertions(+), 35 deletions(-)

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 0b91e5b..c22b695 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
@@ -20,7 +20,6 @@ package org.apache.wiki.attachment;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
-import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Attachment;
 import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Page;
@@ -191,7 +190,7 @@ public interface AttachmentManager {
      *  @throws ProviderException If the backend fails due to some reason
      *  @throws IOException If the stream cannot be opened
      */
-    InputStream getAttachmentStream( WikiContext ctx, Attachment att ) throws ProviderException, IOException;
+    InputStream getAttachmentStream( Context ctx, Attachment att ) throws ProviderException, IOException;
 
     /**
      *  Stores a dynamic attachment.  Unlike storeAttachment(), this just stores the attachment in the memory.
@@ -199,7 +198,7 @@ public interface AttachmentManager {
      *  @param ctx A WikiContext
      *  @param att An attachment to store
      */
-    void storeDynamicAttachment( WikiContext ctx, DynamicAttachment att );
+    void storeDynamicAttachment( Context ctx, DynamicAttachment att );
 
     /**
      *  Finds a DynamicAttachment.  Normally, you should just use {@link #getAttachmentInfo(String)} , since that will find also
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java
index 6642227..654adc8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/DefaultAttachmentManager.java
@@ -22,7 +22,6 @@ import net.sf.ehcache.Cache;
 import net.sf.ehcache.CacheManager;
 import net.sf.ehcache.Element;
 import org.apache.log4j.Logger;
-import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Attachment;
 import org.apache.wiki.api.core.Context;
@@ -242,7 +241,7 @@ public class DefaultAttachmentManager implements AttachmentManager {
 
     /** {@inheritDoc} */
     @Override
-    public InputStream getAttachmentStream( final WikiContext ctx, final Attachment att ) throws ProviderException, IOException {
+    public InputStream getAttachmentStream( final Context ctx, final Attachment att ) throws ProviderException, IOException {
         if( m_provider == null ) {
             return null;
         }
@@ -256,7 +255,7 @@ public class DefaultAttachmentManager implements AttachmentManager {
 
     /** {@inheritDoc} */
     @Override
-    public void storeDynamicAttachment( final WikiContext ctx, final DynamicAttachment att ) {
+    public void storeDynamicAttachment( final Context ctx, final DynamicAttachment att ) {
         m_dynamicAttachments.put( new Element( att.getName(), att ) );
     }
 
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 e891bb6..e555f24 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,8 +18,8 @@
  */
 package org.apache.wiki.attachment;
 
-import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Attachment;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.exceptions.ProviderException;
 
 import java.io.IOException;
@@ -45,6 +45,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( Context context, Attachment att ) throws ProviderException, IOException;
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
index 40cb14f..a0c1e80 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.auth;
 
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
@@ -166,7 +166,7 @@ public interface AuthorizationManager {
     boolean hasRoleOrPrincipal( Session session, Principal principal );
 
     /**
-     * Checks whether the current user has access to the wiki context, by obtaining the required Permission ({@link WikiContext#requiredPermission()})
+     * Checks whether the current user has access to the wiki context, by obtaining the required Permission ({@link Context#requiredPermission()})
      * and delegating the access check to {@link #checkPermission(Session, Permission)}. If the user is allowed, this method returns
      * <code>true</code>; <code>false</code> otherwise. If access is allowed, the wiki context will be added to the request as an attribute
      * with the key name {@link org.apache.wiki.api.core.Context#ATTR_CONTEXT}. Note that this method will automatically redirect the user to
@@ -177,13 +177,13 @@ public interface AuthorizationManager {
      * @return the result of the access check
      * @throws IOException In case something goes wrong
      */
-    default boolean hasAccess( final WikiContext context, final HttpServletResponse response ) throws IOException {
+    default boolean hasAccess( final Context context, final HttpServletResponse response ) throws IOException {
         return hasAccess( context, response, true );
     }
 
     /**
      * Checks whether the current user has access to the wiki context (and
-     * optionally redirects if not), by obtaining the required Permission ({@link WikiContext#requiredPermission()})
+     * optionally redirects if not), by obtaining the required Permission ({@link Context#requiredPermission()})
      * and delegating the access check to {@link #checkPermission(Session, Permission)}.
      * If the user is allowed, this method returns <code>true</code>;
      * <code>false</code> otherwise. Also, the wiki context will be added to the request as attribute
@@ -195,7 +195,7 @@ public interface AuthorizationManager {
      * @return the result of the access check
      * @throws IOException If something goes wrong
      */
-    boolean hasAccess( final WikiContext context, final HttpServletResponse response, final boolean redirect ) throws IOException;
+    boolean hasAccess( final Context context, final HttpServletResponse response, final boolean redirect ) throws IOException;
 
     /**
      * Initializes AuthorizationManager with an engine and set of properties. Expects to find property 'jspwiki.authorizer' with a valid
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java
index edb6a5a..5ca590a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultAuthorizationManager.java
@@ -199,7 +199,7 @@ public class DefaultAuthorizationManager implements AuthorizationManager {
 
     /** {@inheritDoc} */
     @Override
-    public boolean hasAccess( final WikiContext context, final HttpServletResponse response, final boolean redirect ) throws IOException {
+    public boolean hasAccess( final Context context, final HttpServletResponse response, final boolean redirect ) throws IOException {
         final boolean allowed = checkPermission( context.getWikiSession(), context.requiredPermission() );
         final ResourceBundle rb = Preferences.getBundle( context, InternationalizationManager.CORE_BUNDLE );
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
index ce8b856..f6986b3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
@@ -19,7 +19,7 @@
 package org.apache.wiki.auth.authorize;
 
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.Authorizer;
 import org.apache.wiki.auth.NoSuchPrincipalException;
@@ -115,7 +115,7 @@ public interface GroupManager extends Authorizer, WikiEventListener {
      * @throws WikiSecurityException if the group name isn't allowed, or if <code>create</code> is <code>false</code>
      *                               and the Group does not exist
      */
-    default Group parseGroup( final WikiContext context, final boolean create ) throws WikiSecurityException {
+    default Group parseGroup( final Context context, final boolean create ) throws WikiSecurityException {
         // Extract parameters
         final HttpServletRequest request = context.getHttpRequest();
         final String name = request.getParameter( "group" );
@@ -185,7 +185,7 @@ public interface GroupManager extends Authorizer, WikiEventListener {
      * @param context the current wiki context
      * @param group the supplied Group
      */
-    default void validateGroup( final WikiContext context, final Group group ) {
+    default void validateGroup( final Context context, final Group group ) {
         final InputValidator validator = new InputValidator( MESSAGES_KEY, context );
 
         // Name cannot be null or one of the restricted names
@@ -210,7 +210,7 @@ public interface GroupManager extends Authorizer, WikiEventListener {
      * @throws WikiSecurityException if <code>session</code> is <code>null</code> or the Group name is illegal
      * @see Group#RESTRICTED_GROUPNAMES
      */
-    default void checkGroupName( final WikiContext context, final String name ) throws WikiSecurityException {
+    default void checkGroupName( final Context context, final String name ) throws WikiSecurityException {
         // TODO: groups cannot have the same name as a user
 
         // Name cannot be null
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
index 04db620..9d64ecc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
@@ -20,9 +20,8 @@ package org.apache.wiki.content;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.InternalWikiException;
-import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Attachment;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Page;
 import org.apache.wiki.api.exceptions.ProviderException;
@@ -67,7 +66,7 @@ public class DefaultPageRenamer implements PageRenamer {
      *  @throws WikiException If the page cannot be renamed.
      */
     @Override
-    public String renamePage( final WikiContext context, final String renameFrom, final String renameTo, final boolean changeReferrers ) throws WikiException {
+    public String renamePage( final Context context, final String renameFrom, final String renameTo, final boolean changeReferrers ) throws WikiException {
         //  Sanity checks first
         if( renameFrom == null || renameFrom.length() == 0 ) {
             throw new WikiException( "From name may not be null or empty" );
@@ -113,7 +112,7 @@ public class DefaultPageRenamer implements PageRenamer {
         if( toPage == null ) {
             throw new InternalWikiException( "Rename seems to have failed for some strange reason - please check logs!" );
         }
-        toPage.setAttribute( WikiPage.CHANGENOTE, fromPage.getName() + " ==> " + toPage.getName() );
+        toPage.setAttribute( Page.CHANGENOTE, fromPage.getName() + " ==> " + toPage.getName() );
         toPage.setAuthor( context.getCurrentUser().getName() );
         engine.getManager( PageManager.class ).putPageText( toPage, engine.getManager( PageManager.class ).getPureText( toPage ) );
 
@@ -165,7 +164,7 @@ public class DefaultPageRenamer implements PageRenamer {
      *  @param fromPage The old page
      *  @param toPage The new page
      */
-    private void updateReferrers( final WikiContext context, final Page fromPage, final Page toPage, final Set< String > referrers ) {
+    private void updateReferrers( final Context context, final Page fromPage, final Page toPage, final Set< String > referrers ) {
         if( referrers.isEmpty() ) { // No referrers
             return;
         }
@@ -188,7 +187,7 @@ public class DefaultPageRenamer implements PageRenamer {
             }
             
             if( !sourceText.equals( newText ) ) {
-                p.setAttribute( WikiPage.CHANGENOTE, fromPage.getName()+" ==> "+toPage.getName() );
+                p.setAttribute( Page.CHANGENOTE, fromPage.getName()+" ==> "+toPage.getName() );
                 p.setAuthor( context.getCurrentUser().getName() );
          
                 try {
@@ -227,7 +226,7 @@ public class DefaultPageRenamer implements PageRenamer {
     /**
      *  Replaces camelcase links.
      */
-    private String replaceCCReferrerString( final WikiContext context, final String sourceText, final String from, final String to ) {
+    private String replaceCCReferrerString( final Context context, final String sourceText, final String from, final String to ) {
         final StringBuilder sb = new StringBuilder( sourceText.length()+32 );
         final Pattern linkPattern = Pattern.compile( "\\p{Lu}+\\p{Ll}+\\p{Lu}+[\\p{L}\\p{Digit}]*" );
         final Matcher matcher = linkPattern.matcher( sourceText );
@@ -253,7 +252,7 @@ public class DefaultPageRenamer implements PageRenamer {
         return sb.toString();
     }
 
-    private String replaceReferrerString( final WikiContext context, final String sourceText, final String from, final String to ) {
+    private String replaceReferrerString( final Context context, final String sourceText, final String from, final String to ) {
         final StringBuilder sb = new StringBuilder( sourceText.length()+32 );
         
         // This monstrosity just looks for a JSPWiki link pattern.  But it is pretty cool for a regexp, isn't it?  If you can
@@ -313,7 +312,7 @@ public class DefaultPageRenamer implements PageRenamer {
     /**
      *  This method does a correct replacement of a single link, taking into account anchors and attachments.
      */
-    private String replaceSingleLink( final WikiContext context, final String original, final String from, final String newlink ) {
+    private String replaceSingleLink( final Context context, final String original, final String from, final String newlink ) {
         final int hash = original.indexOf( '#' );
         final int slash = original.indexOf( '/' );
         String realLink = original;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/content/PageRenamer.java b/jspwiki-main/src/main/java/org/apache/wiki/content/PageRenamer.java
index c62b478..3f2c006 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/content/PageRenamer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/content/PageRenamer.java
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.content;
 
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.exceptions.WikiException;
 
 /**
@@ -39,7 +39,7 @@ public interface PageRenamer {
      *  @return The final new name (in case it had to be modified)
      *  @throws WikiException If the page cannot be renamed.
      */
-    String renamePage( WikiContext context, String renameFrom, String renameTo, boolean changeReferrers ) throws WikiException;
+    String renamePage( Context context, String renameFrom, String renameTo, boolean changeReferrers ) throws WikiException;
 
     /**
      * Fires a WikiPageRenameEvent to all registered listeners. Currently not used internally by JSPWiki itself, but you can use it for
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java
index b8fcca7..11ce763 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/PageCommand.java
@@ -18,8 +18,8 @@
  */
 package org.apache.wiki.ui;
 
-import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Command;
+import org.apache.wiki.api.core.Page;
 import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.auth.permissions.PermissionFactory;
 
@@ -92,7 +92,7 @@ public final class PageCommand extends AbstractCommand {
     private PageCommand( final String requestContext,
                          final String urlPattern,
                          final String contentTemplate,
-                         final WikiPage target,
+                         final Page target,
                          final String action ) {
         super( requestContext, urlPattern, contentTemplate, target );
         m_action = action;
@@ -112,10 +112,10 @@ public final class PageCommand extends AbstractCommand {
      * @throws IllegalArgumentException if the target is not of the correct type
      */
     public Command targetedCommand( final Object target ) {
-        if( !( target instanceof WikiPage ) ) {
-            throw new IllegalArgumentException( "Target must non-null and of type WikiPage." );
+        if( !( target instanceof Page ) ) {
+            throw new IllegalArgumentException( "Target must non-null and of type Page." );
         }
-        return new PageCommand( getRequestContext(), getURLPattern(), getContentTemplate(), ( WikiPage )target, m_action );
+        return new PageCommand( getRequestContext(), getURLPattern(), getContentTemplate(), ( Page )target, m_action );
     }
 
     /**
@@ -126,7 +126,7 @@ public final class PageCommand extends AbstractCommand {
         if( target == null ) {
             return getJSPFriendlyName();
         }
-        return ( ( WikiPage )target ).getName();
+        return ( ( Page )target ).getName();
     }
 
     /**


[jspwiki] 19/36: use Context instead of WikiContext

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

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

commit 2f68a41f3359222ad8c5ee717f0c61a828746b91
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 14:11:46 2020 +0100

    use Context instead of WikiContext
---
 .../org/apache/wiki/auth/DefaultUserManager.java   |  6 +--
 .../java/org/apache/wiki/auth/UserManager.java     |  6 +--
 .../org/apache/wiki/ui/GenericHTTPHandler.java     |  7 +--
 .../java/org/apache/wiki/ui/InputValidator.java    | 31 ++++++------
 .../org/apache/wiki/ui/admin/SimpleAdminBean.java  |  6 +--
 .../apache/wiki/ui/admin/WikiFormAdminBean.java    | 35 ++++++--------
 .../org/apache/wiki/ui/admin/beans/ModuleBean.java |  3 +-
 .../wiki/ui/admin/beans/PlainEditorAdminBean.java  | 55 +++++++++-------------
 .../wiki/ui/admin/beans/SearchManagerBean.java     |  6 +--
 .../org/apache/wiki/ui/admin/beans/UserBean.java   |  4 +-
 10 files changed, 71 insertions(+), 88 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java
index 0b8db6f..776f741 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/DefaultUserManager.java
@@ -20,10 +20,10 @@ package org.apache.wiki.auth;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.log4j.Logger;
-import org.apache.wiki.WikiContext;
 import org.apache.wiki.ajax.AjaxUtil;
 import org.apache.wiki.ajax.WikiAjaxDispatcherServlet;
 import org.apache.wiki.ajax.WikiAjaxServlet;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
@@ -285,7 +285,7 @@ public class DefaultUserManager implements UserManager {
 
     /** {@inheritDoc} */
     @Override
-    public UserProfile parseProfile( final WikiContext context ) {
+    public UserProfile parseProfile( final Context context ) {
         // Retrieve the user's profile (may have been previously cached)
         final UserProfile profile = getUserProfile( context.getWikiSession() );
         final HttpServletRequest request = context.getHttpRequest();
@@ -315,7 +315,7 @@ public class DefaultUserManager implements UserManager {
 
     /** {@inheritDoc} */
     @Override
-    public void validateProfile( final WikiContext context, final UserProfile profile ) {
+    public void validateProfile( final Context context, final UserProfile profile ) {
         final boolean isNew = profile.isNew();
         final Session session = context.getWikiSession();
         final InputValidator validator = new InputValidator( SESSION_MESSAGES, context );
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 fc62bb1..266cbe4 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
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.auth;
 
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
@@ -131,7 +131,7 @@ public interface UserManager {
      * @param context the current wiki context
      * @return a new, populated user profile
      */
-    UserProfile parseProfile( WikiContext context );
+    UserProfile parseProfile( Context context );
 
     /**
      * Validates a user profile, and appends any errors to the session errors list. If the profile is new, the password will be checked to
@@ -143,7 +143,7 @@ public interface UserManager {
      * @param context the current wiki context
      * @param profile the supplied UserProfile
      */
-    void validateProfile( WikiContext context, UserProfile profile );
+    void validateProfile( Context context, UserProfile profile );
 
     /**
      *  A helper method for returning all of the known WikiNames in this system.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/GenericHTTPHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/GenericHTTPHandler.java
index f6b3abe..21d3c93 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/GenericHTTPHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/GenericHTTPHandler.java
@@ -18,7 +18,8 @@
  */
 package org.apache.wiki.ui;
 
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
+
 
 /**
  *  Provides a generic HTTP handler interface.
@@ -39,13 +40,13 @@ public interface GenericHTTPHandler {
      *  @param context associated WikiContext
      *  @return the HTML for the bean
      */
-    String doGet( WikiContext context );
+    String doGet( Context context );
     
     /**
      *  Handles a POST response.
      *  @param context associated WikiContext
      *  @return the response string resulting from the POST
      */
-    String doPost( WikiContext context );
+    String doPost( Context context );
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
index 13aa834..8d0f5a4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/InputValidator.java
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.ui;
 
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.preferences.Preferences;
@@ -36,28 +36,25 @@ import java.util.regex.Pattern;
  * @since 2.3.54
  */
 public final class InputValidator {
-    /** Standard input validator. */
-    public static final int STANDARD       = 0;
 
+    /** Standard input validator. */
+    public static final int STANDARD = 0;
     /** Input validator for e-mail addresses. **/
-    public static final int EMAIL          = 1;
-
+    public static final int EMAIL    = 1;
     /** @since 2.4.82 */
-    public static final int ID             = 2;
+    public static final int ID        = 2;
 
+    /**
+     * Used when checking against IDs such as a full name when saving groups.
+     * @since 2.4.82
+     */
+    protected static final Pattern ID_PATTERN     = Pattern.compile( "[\\x00\\r\\n\\x0f\"'<>;&\\xff{}]" );
     protected static final Pattern EMAIL_PATTERN  = Pattern.compile( "^[0-9a-zA-Z-_\\.\\+]+@([0-9a-zA-Z-_]+\\.)+[a-zA-Z]+$" );
-
     protected static final Pattern UNSAFE_PATTERN = Pattern.compile( "[\\x00\\r\\n\\x0f\"':<>\\[\\];#&@\\xff{}\\$%\\\\]" );
 
-    /** Used when checking against IDs such as a full name when saving groups.
-     *  @since 2.4.82 */
-    protected static final Pattern ID_PATTERN     = Pattern.compile( "[\\x00\\r\\n\\x0f\"'<>;&\\xff{}]" );
-
-    private final String           m_form;
-
-    private final Session          m_session;
-
-    private final WikiContext      m_context;
+    private final String m_form;
+    private final Session m_session;
+    private final Context m_context;
 
     /**
      * Constructs a new input validator for a specific form and wiki session. When validation errors are detected, they will be added to
@@ -66,7 +63,7 @@ public final class InputValidator {
      * @param form the ID or name of the form this validator should be associated with
      * @param context the wiki context
      */
-    public InputValidator( final String form, final WikiContext context ) {
+    public InputValidator( final String form, final Context context ) {
         m_form = form;
         m_context = context;
         m_session = context.getWikiSession();
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 95faf07..0a065fd 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
@@ -19,7 +19,7 @@
 package org.apache.wiki.ui.admin;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.management.SimpleMBean;
 
@@ -65,7 +65,7 @@ public abstract class SimpleAdminBean extends SimpleMBean implements AdminBean {
      *  The value is determined by the toString() method of the attribute.
      */
     @Override
-    public String doGet( final WikiContext context ) {
+    public String doGet( final Context context ) {
         final MBeanInfo info = getMBeanInfo();
         final MBeanAttributeInfo[] attributes = info.getAttributes();
         final StringBuilder sb = new StringBuilder();
@@ -97,7 +97,7 @@ public abstract class SimpleAdminBean extends SimpleMBean implements AdminBean {
      *  Not implemented yet.
      */
     @Override
-    public String doPost( final WikiContext context) {
+    public String doPost( final Context context) {
         return null;
     }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/WikiFormAdminBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/WikiFormAdminBean.java
index 3ca2668..533d612 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/WikiFormAdminBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/WikiFormAdminBean.java
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.ui.admin;
 
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.parser.WikiDocument;
 import org.apache.wiki.render.RenderingManager;
 
@@ -31,29 +31,22 @@ import java.util.Map;
  *  This class is still experimental.
  *
  */
-public abstract class WikiFormAdminBean
-    implements AdminBean
-{
-    public abstract String getForm( WikiContext context );
+public abstract class WikiFormAdminBean implements AdminBean {
+
+    public abstract String getForm( Context context );
     
-    public abstract void handleResponse( WikiContext context, Map< ?, ? > params );
+    public abstract void handleResponse( Context context, Map< ?, ? > params );
 
-    @Override public String doGet( final WikiContext context)
-    {
+    @Override
+    public String doGet( final Context context ) {
         String result = "";
-        
-        final String wikiMarkup = getForm(context);
-        
+        final String wikiMarkup = getForm( context );
         final RenderingManager mgr = context.getEngine().getManager( RenderingManager.class );
-        
         final WikiDocument doc;
-        try
-        {
+        try {
             doc = mgr.getParser( context, wikiMarkup ).parse();
-            result = mgr.getHTML(context, doc);
-        }
-        catch ( final IOException e)
-        {
+            result = mgr.getHTML( context, doc );
+        } catch( final IOException e ) {
             // TODO Auto-generated catch block
             e.printStackTrace();
         }
@@ -61,9 +54,9 @@ public abstract class WikiFormAdminBean
         return result;
     }
 
-    public String handlePost( final WikiContext context, final HttpServletRequest req, final HttpServletResponse resp)
-    {
-        return null;
+    public String handlePost( final Context context, final HttpServletRequest req, final HttpServletResponse resp ) {
         // FIXME: Not yet implemented
+        return null;
     }
+
 }
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 9266d1e..7a0ad84 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
@@ -21,6 +21,7 @@ package org.apache.wiki.ui.admin.beans;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.Release;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.ui.admin.SimpleAdminBean;
@@ -59,7 +60,7 @@ public abstract class ModuleBean extends SimpleAdminBean {
      * {@inheritDoc}
      */
     @Override
-    public String doGet( final WikiContext context ) {
+    public String doGet( final Context context ) {
         final Collection< WikiModuleInfo > filters = modules();
         final Element root = title();
         final Element tb = containerForModuleDetail( root );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PlainEditorAdminBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PlainEditorAdminBean.java
index 0ac1d9b..d6d8f14 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PlainEditorAdminBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/PlainEditorAdminBean.java
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.ui.admin.beans;
 
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.management.SimpleMBean;
 import org.apache.wiki.ui.admin.AdminBean;
@@ -48,74 +48,65 @@ public class PlainEditorAdminBean extends SimpleMBean implements AdminBean {
     public PlainEditorAdminBean() throws NotCompliantMBeanException {
     }
     
-    @Override public String doGet( final WikiContext context)
-    {
+    @Override
+    public String doGet( final Context context) {
         final HttpServletRequest req = context.getHttpRequest();
-        
-        if( req != null && req.getMethod().equals("POST") && getTitle().equals( req.getParameter("form") ) )
-        {
+        if( req != null && req.getMethod().equals("POST") && getTitle().equals( req.getParameter("form") ) ) {
             return doPost( context );
         }
         String base = TEMPLATE;
-        
         base = TextUtil.replaceString( base, "%checked", "checked='checked'" );
         base = TextUtil.replaceString( base, "%messages", "" );
-        
         return base;
     }
 
-    @Override public String doPost( final WikiContext context )
-    {
+    @Override
+    public String doPost( final Context context ) {
         final HttpServletRequest req = context.getHttpRequest();
-        
         final boolean checked = "checked".equals( req.getParameter( "id" ) );
         
         // Make changes
-        
         String base = TEMPLATE;
-        
         base = TextUtil.replaceString( base, "%checked", checked ? "checked='checked'" : "" );
         base = TextUtil.replaceString( base, "%messages", "<br /><font color='red'>Your settings have been saved</font>" );
-        
         return base;
     }
-    
-    @Override public String getTitle()
-    {
+
+    @Override
+    public String getTitle() {
         return "Plain editor";
     }
 
-    @Override public int getType()
-    {
+    @Override
+    public int getType() {
         return EDITOR;
     }
 
-    public boolean isEnabled()
-    {
+    public boolean isEnabled() {
         return true;
     }
 
-    @Override public String getId()
-    {
+    @Override
+    public String getId() {
         return "editor.plain";
     }
-    
-    public boolean getChecked()
-    {
+
+    public boolean getChecked() {
         return m_checked;
     }
-    
-    @Override public String[] getAttributeNames()
-    {
+
+    @Override
+    public String[] getAttributeNames() {
         return ATTRIBUTES;
     }
 
-    @Override public String[] getMethodNames()
-    {
+    @Override
+    public String[] getMethodNames() {
         return METHODS;
     }
 
-    @Override public void initialize( final Engine engine ) {
+    @Override
+    public void initialize( final Engine engine ) {
     }
 
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/SearchManagerBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/SearchManagerBean.java
index fd7f22e..f345ae2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/SearchManagerBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/SearchManagerBean.java
@@ -19,7 +19,7 @@
 package org.apache.wiki.ui.admin.beans;
 
 import org.apache.wiki.WikiBackgroundThread;
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Page;
 import org.apache.wiki.pages.PageManager;
@@ -126,7 +126,7 @@ public class SearchManagerBean extends SimpleAdminBean {
     }
 
     @Override
-    public String doGet( final WikiContext context ) {
+    public String doGet( final Context context ) {
         if( m_updater != null ) {
             return "Update already in progress ("+ context.getEngine().getManager( ProgressManager.class ).getProgress(PROGRESS_ID)+ "%)";
         }
@@ -136,7 +136,7 @@ public class SearchManagerBean extends SimpleAdminBean {
     }
 
     @Override
-    public String doPost( final WikiContext context ) {
+    public String doPost( final Context context ) {
         final String val = context.getHttpParameter( "searchmanagerbean-reload" );
         if( val != null ) {
             reload();
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
index 3574ba1..a7bfa05 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/admin/beans/UserBean.java
@@ -18,7 +18,7 @@
  */
 package org.apache.wiki.ui.admin.beans;
 
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.NoSuchPrincipalException;
@@ -53,7 +53,7 @@ public class UserBean extends SimpleAdminBean {
     }
 
     @Override
-    public String doPost( final WikiContext context ) {
+    public String doPost( final Context context ) {
         final HttpServletRequest request = context.getHttpRequest();
         final Session session = context.getWikiSession();
         final UserManager mgr = context.getEngine().getManager( UserManager.class );


[jspwiki] 16/36: update dependencies:

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

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

commit 6aef2325a4960dc7954aa06c18833783ea537262
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 00:17:31 2020 +0100

    update dependencies:
    
    * tomcat 9.0.33
    * tika 1.24
    * selenide 5.10.0
    * maven-javadoc-plugin 3.2.0
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 9f85a53..e88b179 100644
--- a/pom.xml
+++ b/pom.xml
@@ -70,11 +70,11 @@
     <nekohtml.version>1.9.22</nekohtml.version>
     <oro.version>2.0.8</oro.version>
     <sandler.version>0.5</sandler.version>
-    <selenide.version>5.7.0</selenide.version>
+    <selenide.version>5.10.0</selenide.version>
     <slf4j.version>1.7.30</slf4j.version>
     <stripes.version>1.7.0-async-beta</stripes.version>
-    <tika.version>1.23</tika.version>
-    <tomcat.version>9.0.31</tomcat.version>
+    <tika.version>1.24</tika.version>
+    <tomcat.version>9.0.33</tomcat.version>
     <wro4j.version>1.8.0</wro4j.version>
     <xmlrpc.version>2.0.1</xmlrpc.version>
 
@@ -88,7 +88,7 @@
     <plugin.idea.version>2.2.1</plugin.idea.version>
     <plugin.install.version>2.5.2</plugin.install.version>
     <plugin.jar.version>3.2.0</plugin.jar.version>
-    <plugin.javadoc.version>3.1.1</plugin.javadoc.version>
+    <plugin.javadoc.version>3.2.0</plugin.javadoc.version>
     <plugin.jxr.version>3.0.0</plugin.jxr.version>
     <plugin.project-info-reports.version>3.0.0</plugin.project-info-reports.version>
     <plugin.release.version>3.0.0-M1</plugin.release.version>


[jspwiki] 09/36: code format

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

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

commit 3c3dcea251950ab42c50dd4dfd6b3d671edcc5da
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 20 19:33:43 2020 +0100

    code format
---
 .../main/java/org/apache/wiki/content/DefaultPageRenamer.java | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
index f412f18..04db620 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/content/DefaultPageRenamer.java
@@ -66,7 +66,8 @@ public class DefaultPageRenamer implements PageRenamer {
      *  @return The final new name (in case it had to be modified)
      *  @throws WikiException If the page cannot be renamed.
      */
-    @Override public String renamePage( final WikiContext context, final String renameFrom, final String renameTo, final boolean changeReferrers ) throws WikiException {
+    @Override
+    public String renamePage( final WikiContext context, final String renameFrom, final String renameTo, final boolean changeReferrers ) throws WikiException {
         //  Sanity checks first
         if( renameFrom == null || renameFrom.length() == 0 ) {
             throw new WikiException( "From name may not be null or empty" );
@@ -149,7 +150,8 @@ public class DefaultPageRenamer implements PageRenamer {
      * @param oldName the former page name
      * @param newName the new page name
      */
-    @Override public void firePageRenameEvent( final String oldName, final String newName ) {
+    @Override
+    public void firePageRenameEvent( final String oldName, final String newName ) {
         if( WikiEventManager.isListening(this) ) {
             WikiEventManager.fireEvent(this, new WikiPageRenameEvent(this, oldName, newName ) );
         }
@@ -344,11 +346,10 @@ public class DefaultPageRenamer implements PageRenamer {
                 return original + "|" + newlink;
             }
             
-            return newlink +
-                   ( ( hash > 0 ) ? original.substring( hash ) : "" ) +
-                   ( ( slash > 0 ) ? original.substring( slash ) : "" ) ;
+            return newlink + ( ( hash > 0 ) ? original.substring( hash ) : "" ) + ( ( slash > 0 ) ? original.substring( slash ) : "" ) ;
         }
         
         return original;
     }
+
 }


[jspwiki] 06/36: JSPWIKI-303: move back to jspwiki-main o.a.w.search.QueryItem and o.a.w.search.SearchResult

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 3338f0c476560cfdb1db036c3940da3b0a9a2764
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 20 19:31:24 2020 +0100

    JSPWIKI-303: move back to jspwiki-main o.a.w.search.QueryItem and o.a.w.search.SearchResult
    
    as they will be needed there for page/attachment providers backward compatibility
    also, for the same reason, they extend again from their counterparts at o.a.w.api.search package
---
 .../main/java/org/apache/wiki/search/QueryItem.java    | 18 +-----------------
 .../java/org/apache/wiki/search/SearchMatcher.java     | 18 ++++++++++++++----
 .../main/java/org/apache/wiki/search/SearchResult.java | 17 +----------------
 3 files changed, 16 insertions(+), 37 deletions(-)

diff --git a/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/QueryItem.java b/jspwiki-main/src/main/java/org/apache/wiki/search/QueryItem.java
similarity index 67%
rename from jspwiki-210-adapters/src/main/java/org/apache/wiki/search/QueryItem.java
rename to jspwiki-main/src/main/java/org/apache/wiki/search/QueryItem.java
index 280c546..54b6dd7 100644
--- a/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/QueryItem.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/QueryItem.java
@@ -26,21 +26,5 @@ package org.apache.wiki.search;
  * @see org.apache.wiki.api.search.QueryItem
  */
 @Deprecated
-public class QueryItem {
-
-    /** The word is required to be in the pages */
-    public static final int REQUIRED  = 1;
-
-    /** The word may NOT be in the pages */
-    public static final int FORBIDDEN = -1;
-
-    /** The word should be in the pages, but the search engine may use its own discretion. */
-    public static final int REQUESTED = 0;
-
-    /** The word that is being searched */
-    public String word;
-
-    /** The type of the word.  See above for types.  The default is REQUESTED. */
-    public int type = REQUESTED;
-
+public class QueryItem extends org.apache.wiki.api.search.QueryItem {
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
index e0e4237..cfe5683 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
@@ -18,10 +18,10 @@
  */
 package org.apache.wiki.search;
 
+import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.search.QueryItem;
-import org.apache.wiki.api.search.SearchResult;
 
 import java.io.BufferedReader;
 import java.io.IOException;
@@ -42,7 +42,7 @@ public class SearchMatcher {
 
     /**
      *  Creates a new SearchMatcher.
-     *  
+     *
      *  @param engine The Engine
      *  @param queries A list of queries
      */
@@ -52,6 +52,16 @@ public class SearchMatcher {
     }
 
     /**
+     *  Creates a new SearchMatcher.
+     *
+     *  @param engine The Engine
+     *  @param queries A list of queries
+     */
+    public SearchMatcher( final WikiEngine engine, final org.apache.wiki.search.QueryItem[] queries ) {
+        this( ( Engine )engine, queries );
+    }
+
+    /**
      * Compares the page content, available through the given stream, to the query items of this matcher. Returns a search result
      * object describing the quality of the match.
      *
@@ -62,7 +72,7 @@ public class SearchMatcher {
      * @return A SearchResult item, or null, there are no queries
      * @throws IOException If reading page content fails
      */
-    public SearchResult matchPageContent( final String wikiname, final String pageText ) throws IOException {
+    public org.apache.wiki.search.SearchResult matchPageContent( final String wikiname, final String pageText ) throws IOException {
         if( m_queries == null ) {
             return null;
         }
@@ -116,7 +126,7 @@ public class SearchMatcher {
     /**
      *  A local search result.
      */
-    public class SearchResultImpl implements SearchResult {
+    public class SearchResultImpl implements org.apache.wiki.search.SearchResult {
     	
         int      m_score;
         WikiPage m_page;
diff --git a/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/SearchResult.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchResult.java
similarity index 74%
rename from jspwiki-210-adapters/src/main/java/org/apache/wiki/search/SearchResult.java
rename to jspwiki-main/src/main/java/org/apache/wiki/search/SearchResult.java
index ae677a9..dbb93ce 100644
--- a/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/SearchResult.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchResult.java
@@ -28,7 +28,7 @@ import org.apache.wiki.WikiPage;
  * @see org.apache.wiki.api.search.SearchResult
  */
 @Deprecated
-public interface SearchResult {
+public interface SearchResult extends org.apache.wiki.api.search.SearchResult {
     
 	/**
      *  Return the page.
@@ -37,19 +37,4 @@ public interface SearchResult {
      */
     WikiPage getPage();
 
-    /**
-     *  Returns the score.
-     *
-     *  @return A positive score value.  Note that there is no upper limit for the score.
-     */
-    int getScore();
-
-    /**
-     * Collection of XHTML fragments representing some contexts in which the match was made (a.k.a., "snippets").
-     *
-     * @return the search results
-     * @since 2.4
-     */
-    String[] getContexts();
-
 }


[jspwiki] 22/36: mark constructors using WikiEngine as deprecated

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 7c5fb153dcea1b83fece21c767417a8a07137427
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 14:15:26 2020 +0100

    mark constructors using WikiEngine as deprecated
---
 .../src/main/java/org/apache/wiki/search/SearchMatcher.java      | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
index cfe5683..f6f745d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchMatcher.java
@@ -52,11 +52,14 @@ public class SearchMatcher {
     }
 
     /**
-     *  Creates a new SearchMatcher.
+     * Creates a new SearchMatcher.
      *
-     *  @param engine The Engine
-     *  @param queries A list of queries
+     * @param engine The Engine
+     * @param queries A list of queries
+     * @deprecated kept for compatibility with page/attachment providers not using public API. Use {@code SearchMatcher(Engine, QueryItem)}
+     * instead.
      */
+    @Deprecated
     public SearchMatcher( final WikiEngine engine, final org.apache.wiki.search.QueryItem[] queries ) {
         this( ( Engine )engine, queries );
     }


[jspwiki] 08/36: add missing Apache License

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 9c00c581c947110fb09de0505b8d0d3a0280c9cc
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 20 19:33:16 2020 +0100

    add missing Apache License
---
 .../java/org/apache/wiki/providers/SearchAdapter.java  | 18 ++++++++++++++++++
 .../src/test/java/com/example/filters/TwoXFilter.java  | 18 ++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/SearchAdapter.java b/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/SearchAdapter.java
index 8df1676..4823fb1 100644
--- a/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/SearchAdapter.java
+++ b/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/SearchAdapter.java
@@ -1,3 +1,21 @@
+/*
+    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.providers;
 
 import org.apache.wiki.api.core.Page;
diff --git a/jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilter.java b/jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilter.java
index b9d7fe6..f8d11df 100644
--- a/jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilter.java
+++ b/jspwiki-210-test-adaptees/src/test/java/com/example/filters/TwoXFilter.java
@@ -1,3 +1,21 @@
+/*
+    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 com.example.filters;
 
 import org.apache.wiki.WikiContext;


[jspwiki] 20/36: extract all commands to its own class in order to break class cycles

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 a3bacfa69a61b147d86324923840edc91283e3ec
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 14:14:12 2020 +0100

    extract all commands to its own class in order to break class cycles
---
 .../java/org/apache/wiki/ui/AbstractCommand.java   | 56 ++++------------------
 .../main/java/org/apache/wiki/ui/AllCommands.java  | 49 +++++++++++++++++++
 .../java/org/apache/wiki/ui/CommandResolver.java   |  4 +-
 .../org/apache/wiki/ui/DefaultCommandResolver.java |  2 +-
 4 files changed, 60 insertions(+), 51 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/AbstractCommand.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/AbstractCommand.java
index 4bccec1..dfad8f6 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/AbstractCommand.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/AbstractCommand.java
@@ -29,37 +29,6 @@ import org.apache.wiki.util.TextUtil;
  */
 public abstract class AbstractCommand implements Command {
 
-    private static final Command[] ALL_COMMANDS = new Command[] {
-        PageCommand.ATTACH,
-        PageCommand.COMMENT,
-        PageCommand.CONFLICT,
-        PageCommand.DELETE,
-        PageCommand.DIFF,
-        PageCommand.EDIT,
-        PageCommand.INFO,
-        PageCommand.NONE,
-        PageCommand.OTHER,
-        PageCommand.PREVIEW,
-        PageCommand.RENAME,
-        PageCommand.RSS,
-        PageCommand.UPLOAD,
-        PageCommand.VIEW,
-        GroupCommand.DELETE_GROUP,
-        GroupCommand.EDIT_GROUP,
-        GroupCommand.VIEW_GROUP,
-        WikiCommand.CREATE_GROUP,
-        WikiCommand.ERROR,
-        WikiCommand.FIND,
-        WikiCommand.INSTALL,
-        WikiCommand.LOGIN,
-        WikiCommand.LOGOUT,
-        WikiCommand.MESSAGE,
-        WikiCommand.PREFS,
-        WikiCommand.WORKFLOW,
-        WikiCommand.ADMIN,
-        RedirectCommand.REDIRECT
-    };
-
     private static final String HTTPS = "HTTPS://";
     private static final String HTTP = "HTTP://";
 
@@ -88,7 +57,7 @@ public abstract class AbstractCommand implements Command {
         }
 
         m_requestContext = requestContext;
-        if ( urlPattern.toUpperCase().startsWith( HTTP ) || urlPattern.toUpperCase().endsWith( HTTPS ) ) {
+        if ( urlPattern.toUpperCase().startsWith( HTTP ) || urlPattern.toUpperCase().startsWith( HTTPS ) ) {
             // For an HTTP/HTTPS url, pass it through without modification
             m_jsp = urlPattern;
             m_jspFriendlyName = "Special Page";
@@ -131,54 +100,45 @@ public abstract class AbstractCommand implements Command {
     }
 
     /**
-     * Returns a defensively-created array of all static Commands.
-     *
-     * @return the array of commands
-     */
-    public static Command[] allCommands() {
-        return ALL_COMMANDS.clone();
-    }
-
-    /**
-     * @see org.apache.wiki.ui.Command#targetedCommand(Object)
+     * @see org.apache.wiki.api.core.Command#targetedCommand(Object)
      */
     public abstract Command targetedCommand( final Object target );
 
     /**
-     * @see org.apache.wiki.ui.Command#getContentTemplate()
+     * @see org.apache.wiki.api.core.Command#getContentTemplate()
      */
     public final String getContentTemplate() {
         return m_contentTemplate;
     }
 
     /**
-     * @see org.apache.wiki.ui.Command#getJSP()
+     * @see org.apache.wiki.api.core.Command#getJSP()
      */
     public final String getJSP() {
         return m_jsp;
     }
 
     /**
-     * @see org.apache.wiki.ui.Command#getName()
+     * @see org.apache.wiki.api.core.Command#getName()
      */
     public abstract String getName();
 
     /**
-     * @see org.apache.wiki.ui.Command#getRequestContext()
+     * @see org.apache.wiki.api.core.Command#getRequestContext()
      */
     public final String getRequestContext() {
         return m_requestContext;
     }
 
     /**
-     * @see org.apache.wiki.ui.Command#getTarget()
+     * @see org.apache.wiki.api.core.Command#getTarget()
      */
     public final Object getTarget() {
         return m_target;
     }
 
     /**
-     * @see org.apache.wiki.ui.Command#getURLPattern()
+     * @see org.apache.wiki.api.core.Command#getURLPattern()
      */
     public final String getURLPattern() {
         return m_urlPattern;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/AllCommands.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/AllCommands.java
new file mode 100644
index 0000000..19dbdc8
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/AllCommands.java
@@ -0,0 +1,49 @@
+package org.apache.wiki.ui;
+
+import org.apache.wiki.api.core.Command;
+
+
+/**
+ * Placeholder class for all Commands.
+ */
+public interface AllCommands {
+
+    /**
+     * Returns a defensively-created array of all static Commands.
+     *
+     * @return the array of commands
+     */
+    static Command[] get() {
+        return new Command[] {
+            GroupCommand.DELETE_GROUP,
+            GroupCommand.EDIT_GROUP,
+            GroupCommand.VIEW_GROUP,
+            PageCommand.ATTACH,
+            PageCommand.COMMENT,
+            PageCommand.CONFLICT,
+            PageCommand.DELETE,
+            PageCommand.DIFF,
+            PageCommand.EDIT,
+            PageCommand.INFO,
+            PageCommand.NONE,
+            PageCommand.OTHER,
+            PageCommand.PREVIEW,
+            PageCommand.RENAME,
+            PageCommand.RSS,
+            PageCommand.UPLOAD,
+            PageCommand.VIEW,
+            RedirectCommand.REDIRECT,
+            WikiCommand.CREATE_GROUP,
+            WikiCommand.ERROR,
+            WikiCommand.FIND,
+            WikiCommand.INSTALL,
+            WikiCommand.LOGIN,
+            WikiCommand.LOGOUT,
+            WikiCommand.MESSAGE,
+            WikiCommand.PREFS,
+            WikiCommand.WORKFLOW,
+            WikiCommand.ADMIN
+        };
+    }
+
+}
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 fd913c8..1a161b1 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
@@ -52,14 +52,14 @@ public interface CommandResolver {
 
     /**
      * Attempts to locate a wiki command for a supplied request context. The resolution technique is simple: we examine the list of
-     * Commands returned by {@link AbstractCommand#allCommands()} and return the one whose <code>requestContext</code> matches the
+     * Commands returned by {@link AllCommands#get()} and return the one whose <code>requestContext</code> matches the
      * supplied context. If the supplied context does not resolve to a known Command, this method throws an {@link IllegalArgumentException}.
      *
      * @param context the request context
      * @return the resolved context
      */
     static Command findCommand( final String context ) {
-        return Arrays.stream( AbstractCommand.allCommands() )
+        return Arrays.stream( AllCommands.get() )
                      .filter( c -> c.getRequestContext().equals( context ) )
                      .findFirst()
                      .orElseThrow( () -> new IllegalArgumentException( "Unsupported wiki context: " + context + "." ) );
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 c80aad5..e1d110e 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
@@ -56,7 +56,7 @@ public final class DefaultCommandResolver implements CommandResolver {
     static {
         CONTEXTS = new HashMap<>();
         JSPS = new HashMap<>();
-        final Command[] commands = AbstractCommand.allCommands();
+        final Command[] commands = AllCommands.get();
         for( final Command command : commands ) {
             JSPS.put( command.getJSP(), command );
             CONTEXTS.put( command.getRequestContext(), command );


[jspwiki] 25/36: refactor tests so they only build a TestEngine instance per class instead of per test

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 87581788162a787e42943f66d31ea41713ae4326
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 14:17:13 2020 +0100

    refactor tests so they only build a TestEngine instance per class instead of per test
---
 .../wiki/plugin/RecentChangesPluginTest.java       | 22 ++---
 .../providers/BasicAttachmentProviderTest.java     |  4 +-
 .../wiki/providers/FileSystemProviderTest.java     | 97 +++++++++++-----------
 3 files changed, 55 insertions(+), 68 deletions(-)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java
index fcc8f47..3a4c3ad 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/RecentChangesPluginTest.java
@@ -32,24 +32,17 @@ import java.util.Properties;
 
 public class RecentChangesPluginTest {
     Properties props = TestEngine.getTestProperties();
-
-    TestEngine testEngine;
+    TestEngine testEngine = TestEngine.build( props );
+    PluginManager manager = new DefaultPluginManager(testEngine, props);
 
     WikiContext context;
 
-    PluginManager manager;
-
     @BeforeEach
     public void setUp() throws Exception {
-        CacheManager.getInstance().removeAllCaches();
-        testEngine = new TestEngine(props);
-
         testEngine.saveText("TestPage01", "Some Text for testing 01");
         testEngine.saveText("TestPage02", "Some Text for testing 02");
         testEngine.saveText("TestPage03", "Some Text for testing 03");
         testEngine.saveText("TestPage04", "Some Text for testing 04");
-
-        manager = new DefaultPluginManager(testEngine, props);
     }
 
     @AfterEach
@@ -60,6 +53,7 @@ public class RecentChangesPluginTest {
         testEngine.deleteTestPage("TestPage04");
 
         TestEngine.emptyWorkDir();
+        CacheManager.getInstance().removeAllCaches();
     }
 
     /**
@@ -90,8 +84,7 @@ public class RecentChangesPluginTest {
     public void testParmInClude() throws Exception {
         context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage02"));
 
-        final String res = manager.execute( context,
-                                      "{INSERT org.apache.wiki.plugin.RecentChangesPlugin include='TestPage02*'}" );
+        final String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin include='TestPage02*'}" );
 
         Assertions.assertTrue(res.contains("<table class=\"recentchanges\" cellpadding=\"4\">"));
         Assertions.assertFalse(res.contains("<a href=\"/test/Wiki.jsp?page=TestPage01\">Test Page 01</a>"));
@@ -126,11 +119,10 @@ public class RecentChangesPluginTest {
     public void testNoRecentChanges() throws Exception {
         context = new WikiContext(testEngine, new WikiPage(testEngine, "TestPage04"));
 
-        final String res = manager.execute( context,
-                                      "{INSERT org.apache.wiki.plugin.RecentChangesPlugin since='-1'}" );
+        final String res = manager.execute( context, "{INSERT org.apache.wiki.plugin.RecentChangesPlugin since='-1'}" );
 
-        Assertions.assertTrue( "<table class=\"recentchanges\" cellpadding=\"4\"></table>".equals( res ) );
-        Assertions.assertFalse( "<table class=\"recentchanges\" cellpadding=\"4\" />".equals( res ) );
+        Assertions.assertEquals( "<table class=\"recentchanges\" cellpadding=\"4\"></table>", res );
+        Assertions.assertNotEquals( "<table class=\"recentchanges\" cellpadding=\"4\" />", res );
     }
 
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/providers/BasicAttachmentProviderTest.java b/jspwiki-main/src/test/java/org/apache/wiki/providers/BasicAttachmentProviderTest.java
index ff7809e..185fc08 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/providers/BasicAttachmentProviderTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/providers/BasicAttachmentProviderTest.java
@@ -45,7 +45,7 @@ public class BasicAttachmentProviderTest {
     public static final String NAME2 = "AfterFirstTestPage";
 
     Properties props = TestEngine.getTestProperties();
-    TestEngine m_engine;
+    TestEngine m_engine = TestEngine.build( props );
     BasicAttachmentProvider m_provider;
 
     /** This is the sound of my head hitting the keyboard. */
@@ -53,8 +53,6 @@ public class BasicAttachmentProviderTest {
 
     @BeforeEach
     public void setUp() throws Exception {
-        m_engine = new TestEngine( props );
-
         m_provider = new BasicAttachmentProvider();
         m_provider.initialize( m_engine, props );
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/providers/FileSystemProviderTest.java b/jspwiki-main/src/test/java/org/apache/wiki/providers/FileSystemProviderTest.java
index 30ea671..9cea2d2 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/providers/FileSystemProviderTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/providers/FileSystemProviderTest.java
@@ -18,10 +18,11 @@
  */
 
 package org.apache.wiki.providers;
-import org.apache.log4j.PropertyConfigurator;
+
 import org.apache.wiki.TestEngine;
-import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Page;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.util.FileUtil;
 import org.junit.jupiter.api.AfterEach;
@@ -34,31 +35,27 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.util.Properties;
 
+import static org.apache.wiki.TestEngine.with;
 
 
 public class FileSystemProviderTest {
 
     FileSystemProvider m_provider;
     FileSystemProvider m_providerUTF8;
-    String             m_pagedir;
     Properties props = TestEngine.getTestProperties();
 
-    TestEngine         m_engine;
+    Engine m_engine = TestEngine.build( with( PageManager.PROP_PAGEPROVIDER, "FileSystemProvider" ),
+                                        with( FileSystemProvider.PROP_PAGEDIR, "./target/jspwiki.test.pages" ) );
 
     @BeforeEach
     public void setUp() throws Exception {
-        m_pagedir = "./target/jspwiki.test.pages";
         props.setProperty( PageManager.PROP_PAGEPROVIDER, "FileSystemProvider" );
-        props.setProperty( FileSystemProvider.PROP_PAGEDIR, m_pagedir );
-
-        Properties props2 = new Properties();
-        PropertyConfigurator.configure( props2 );
+        props.setProperty( FileSystemProvider.PROP_PAGEDIR, "./target/jspwiki.test.pages" );
 
-        m_engine = new TestEngine(props);
         m_provider = new FileSystemProvider();
         m_provider.initialize( m_engine, props );
 
-        props.setProperty( WikiEngine.PROP_ENCODING, "UTF-8" );
+        props.setProperty( Engine.PROP_ENCODING, "UTF-8" );
         m_providerUTF8 = new FileSystemProvider();
         m_providerUTF8.initialize( m_engine, props );
     }
@@ -70,30 +67,30 @@ public class FileSystemProviderTest {
 
     @Test
     public void testScandinavianLetters() throws Exception {
-        WikiPage page = new WikiPage(m_engine, "\u00c5\u00e4Test");
+        final WikiPage page = new WikiPage(m_engine, "\u00c5\u00e4Test");
 
         m_provider.putPageText( page, "test" );
 
-        File resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) , "%C5%E4Test.txt" );
+        final File resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) , "%C5%E4Test.txt" );
 
         Assertions.assertTrue( resultfile.exists(), "No such file" );
 
-        String contents = FileUtil.readContents( new FileInputStream(resultfile), "ISO-8859-1" );
+        final String contents = FileUtil.readContents( new FileInputStream(resultfile), "ISO-8859-1" );
 
         Assertions.assertEquals( contents, "test", "Wrong contents" );
     }
 
     @Test
     public void testScandinavianLettersUTF8() throws Exception {
-        WikiPage page = new WikiPage(m_engine, "\u00c5\u00e4Test");
+        final WikiPage page = new WikiPage(m_engine, "\u00c5\u00e4Test");
 
         m_providerUTF8.putPageText( page, "test\u00d6" );
 
-        File resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) , "%C3%85%C3%A4Test.txt" );
+        final File resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) , "%C3%85%C3%A4Test.txt" );
 
         Assertions.assertTrue( resultfile.exists(), "No such file" );
 
-        String contents = FileUtil.readContents( new FileInputStream(resultfile),
+        final String contents = FileUtil.readContents( new FileInputStream(resultfile),
                                                  "UTF-8" );
 
         Assertions.assertEquals( contents, "test\u00d6", "Wrong contents" );
@@ -107,15 +104,15 @@ public class FileSystemProviderTest {
     public void testSlashesInPageNamesUTF8()
          throws Exception
     {
-        WikiPage page = new WikiPage(m_engine, "Test/Foobar");
+        final WikiPage page = new WikiPage(m_engine, "Test/Foobar");
 
         m_providerUTF8.putPageText( page, "test" );
 
-        File resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) , "Test%2FFoobar.txt" );
+        final File resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) , "Test%2FFoobar.txt" );
 
         Assertions.assertTrue( resultfile.exists(), "No such file" );
 
-        String contents = FileUtil.readContents( new FileInputStream(resultfile),
+        final String contents = FileUtil.readContents( new FileInputStream(resultfile),
                                                  "UTF-8" );
 
         Assertions.assertEquals( contents, "test", "Wrong contents" );
@@ -125,15 +122,15 @@ public class FileSystemProviderTest {
     public void testSlashesInPageNames()
          throws Exception
     {
-        WikiPage page = new WikiPage(m_engine, "Test/Foobar");
+        final WikiPage page = new WikiPage(m_engine, "Test/Foobar");
 
         m_provider.putPageText( page, "test" );
 
-        File resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) , "Test%2FFoobar.txt" );
+        final File resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) , "Test%2FFoobar.txt" );
 
         Assertions.assertTrue( resultfile.exists(), "No such file" );
 
-        String contents = FileUtil.readContents( new FileInputStream(resultfile),
+        final String contents = FileUtil.readContents( new FileInputStream(resultfile),
                                                  "ISO-8859-1" );
 
         Assertions.assertEquals( contents, "test", "Wrong contents" );
@@ -143,15 +140,15 @@ public class FileSystemProviderTest {
     public void testDotsInBeginning()
        throws Exception
     {
-        WikiPage page = new WikiPage(m_engine, ".Test");
+        final WikiPage page = new WikiPage(m_engine, ".Test");
 
         m_provider.putPageText( page, "test" );
 
-        File resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) , "%2ETest.txt" );
+        final File resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) , "%2ETest.txt" );
 
         Assertions.assertTrue( resultfile.exists(), "No such file" );
 
-        String contents = FileUtil.readContents( new FileInputStream(resultfile), "ISO-8859-1" );
+        final String contents = FileUtil.readContents( new FileInputStream(resultfile), "ISO-8859-1" );
 
         Assertions.assertEquals( contents, "test", "Wrong contents" );
     }
@@ -162,12 +159,12 @@ public class FileSystemProviderTest {
     {
         try
         {
-            WikiPage page = new WikiPage(m_engine, "\u00c5\u00e4Test");
+            final WikiPage page = new WikiPage(m_engine, "\u00c5\u00e4Test");
             page.setAuthor("Min\u00e4");
 
             m_provider.putPageText( page, "test" );
 
-            WikiPage page2 = m_provider.getPageInfo( "\u00c5\u00e4Test", 1 );
+            final Page page2 = m_provider.getPageInfo( "\u00c5\u00e4Test", 1 );
 
             Assertions.assertEquals( "Min\u00e4", page2.getAuthor() );
         }
@@ -176,32 +173,32 @@ public class FileSystemProviderTest {
             File resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ), "%C5%E4Test.txt" );
             try {
                 resultfile.delete();
-            } catch(Exception e) {}
+            } catch( final Exception e) {}
 
             resultfile = new File(  props.getProperty( FileSystemProvider.PROP_PAGEDIR ), "%C5%E4Test.properties" );
             try {
                 resultfile.delete();
-            } catch(Exception e) {}
+            } catch( final Exception e) {}
         }
     }
 
     @Test
     public void testNonExistantDirectory() throws Exception {
-        String tmpdir =  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) ;
-        String dirname = "non-existant-directory";
+        final String tmpdir =  props.getProperty( FileSystemProvider.PROP_PAGEDIR ) ;
+        final String dirname = "non-existant-directory";
 
-        String newdir = tmpdir + File.separator + dirname;
+        final String newdir = tmpdir + File.separator + dirname;
 
-        Properties pr = new Properties();
+        final Properties pr = new Properties();
 
         pr.setProperty( FileSystemProvider.PROP_PAGEDIR,
                            newdir );
 
-        FileSystemProvider test = new FileSystemProvider();
+        final FileSystemProvider test = new FileSystemProvider();
 
         test.initialize( m_engine, pr );
 
-        File f = new File( newdir );
+        final File f = new File( newdir );
 
         Assertions.assertTrue( f.exists(), "didn't create it" );
         Assertions.assertTrue( f.isDirectory(), "isn't a dir" );
@@ -219,11 +216,11 @@ public class FileSystemProviderTest {
         {
             tmpFile = FileUtil.newTmpFile("foobar"); // Content does not matter.
 
-            Properties pr = new Properties();
+            final Properties pr = new Properties();
 
             pr.setProperty( FileSystemProvider.PROP_PAGEDIR, tmpFile.getAbsolutePath() );
 
-            FileSystemProvider test = new FileSystemProvider();
+            final FileSystemProvider test = new FileSystemProvider();
 
             try
             {
@@ -231,7 +228,7 @@ public class FileSystemProviderTest {
 
                 Assertions.fail( "Wiki did not warn about wrong property." );
             }
-            catch( IOException e )
+            catch( final IOException e )
             {
                 // This is okay.
             }
@@ -249,9 +246,9 @@ public class FileSystemProviderTest {
     public void testDelete()
         throws Exception
     {
-        String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
+        final String files = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
 
-        WikiPage p = new WikiPage(m_engine,"Test");
+        final WikiPage p = new WikiPage(m_engine,"Test");
         p.setAuthor("AnonymousCoward");
 
         m_provider.putPageText( p, "v1" );
@@ -277,23 +274,23 @@ public class FileSystemProviderTest {
 
     @Test
     public void testCustomProperties() throws Exception {
-        String pageDir = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
-        String pageName = "CustomPropertiesTest";
-        String fileName = pageName+FileSystemProvider.FILE_EXT;
-        File file = new File (pageDir,fileName);
+        final String pageDir = props.getProperty( FileSystemProvider.PROP_PAGEDIR );
+        final String pageName = "CustomPropertiesTest";
+        final String fileName = pageName+FileSystemProvider.FILE_EXT;
+        final File file = new File (pageDir,fileName);
 
         Assertions.assertFalse( file.exists() );
-        WikiPage testPage = new WikiPage(m_engine,pageName);
+        final WikiPage testPage = new WikiPage(m_engine,pageName);
         testPage.setAuthor("TestAuthor");
         testPage.setAttribute("@test","Save Me");
         testPage.setAttribute("@test2","Save You");
         testPage.setAttribute("test3","Do not save");
         m_provider.putPageText( testPage, "This page has custom properties" );
         Assertions.assertTrue( file.exists(), "No such file" );
-        WikiPage pageRetrieved = m_provider.getPageInfo( pageName, -1 );
-        String value = pageRetrieved.getAttribute("@test");
-        String value2 = pageRetrieved.getAttribute("@test2");
-        String value3 = pageRetrieved.getAttribute("test3");
+        final Page pageRetrieved = m_provider.getPageInfo( pageName, -1 );
+        final String value = pageRetrieved.getAttribute("@test");
+        final String value2 = pageRetrieved.getAttribute("@test2");
+        final String value3 = pageRetrieved.getAttribute("test3");
         Assertions.assertNotNull(value);
         Assertions.assertNotNull(value2);
         Assertions.assertNull(value3);


[jspwiki] 30/36: use getManager( XYZ.class ) instead of getXYZManager methods 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 3d9931919e36d831b27fa89c0281adf6bd1d50b2
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 16:18:51 2020 +0100

    use getManager( XYZ.class ) instead of getXYZManager methods of WikiEngine
---
 .../wiki/ajax/WikiAjaxDispatcherServlet.java       |  2 +-
 .../test/java/org/apache/wiki/WikiEngineTest.java  | 26 ++++---
 .../test/java/org/apache/wiki/WikiSessionTest.java |  4 +-
 .../wiki/attachment/AttachmentManagerTest.java     |  2 +-
 .../wiki/auth/AuthenticationManagerTest.java       |  6 +-
 .../apache/wiki/auth/AuthorizationManagerTest.java | 19 ++---
 .../java/org/apache/wiki/auth/UserManagerTest.java |  6 +-
 .../java/org/apache/wiki/auth/acl/AclImplTest.java | 76 ++++++------------
 .../auth/login/CookieAssertionLoginModuleTest.java | 63 +++++++--------
 .../org/apache/wiki/auth/user/UserProfileTest.java | 53 +++++--------
 .../org/apache/wiki/content/PageRenamerTest.java   | 58 +++++++-------
 .../apache/wiki/pages/DefaultPageManagerTest.java  | 15 ++--
 .../wiki/parser/JSPWikiMarkupParserTest.java       |  3 +-
 .../wiki/plugin/DefaultPluginManagerTest.java      |  3 +-
 .../java/org/apache/wiki/plugin/GroupsTest.java    |  3 +-
 .../java/org/apache/wiki/plugin/IfPluginTest.java  | 12 +--
 .../org/apache/wiki/plugin/PageViewPluginTest.java | 37 ++++-----
 .../wiki/references/ReferenceManagerTest.java      |  2 +-
 .../apache/wiki/render/RenderingManagerTest.java   | 16 ++--
 .../java/org/apache/wiki/rss/RSSGeneratorTest.java |  8 +-
 .../org/apache/wiki/search/SearchManagerTest.java  |  2 +-
 .../apache/wiki/stress/MassiveRepositoryTest.java  |  3 +-
 .../org/apache/wiki/ui/CommandResolverTest.java    |  2 +-
 .../apache/wiki/workflow/ApprovalWorkflowTest.java | 10 +--
 .../apache/wiki/workflow/DecisionQueueTest.java    |  6 +-
 .../java/org/apache/wiki/workflow/OutcomeTest.java | 91 +++++++++-------------
 .../apache/wiki/workflow/WorkflowManagerTest.java  | 22 +++---
 .../org/apache/wiki/xmlrpc/RPCHandlerTest.java     |  5 +-
 .../wiki/render/markdown/MarkdownRendererTest.java |  3 +-
 .../wiki/search/tika/TikaSearchProviderTest.java   |  3 +-
 30 files changed, 258 insertions(+), 303 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 8f055c8..70b872e 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
@@ -164,7 +164,7 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
         final WikiEngine e = WikiEngine.getInstance(req.getSession().getServletContext(), null);
         boolean valid = false;
         if( container != null ) {
-            valid = e.getAuthorizationManager().checkPermission( WikiSession.getWikiSession( e, req ), container.permission );
+            valid = e.getManager( AuthorizationManager.class ).checkPermission( WikiSession.getWikiSession( e, req ), container.permission );
         }
         return valid;
     }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
index f4d02eb..eb92bba 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -23,10 +23,12 @@ import net.sf.ehcache.CacheManager;
 import org.apache.wiki.api.core.Page;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.attachment.AttachmentManager;
+import org.apache.wiki.content.PageRenamer;
 import org.apache.wiki.modules.ModuleManager;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.providers.FileSystemProvider;
 import org.apache.wiki.references.ReferenceManager;
+import org.apache.wiki.render.RenderingManager;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
@@ -122,8 +124,8 @@ public class WikiEngineTest {
      */
     @Test
     public void testAttachmentRefs() throws Exception {
-        final ReferenceManager refMgr = m_engine.getReferenceManager();
-        final AttachmentManager attMgr = m_engine.getAttachmentManager();
+        final ReferenceManager refMgr = m_engine.getManager( ReferenceManager.class );
+        final AttachmentManager attMgr = m_engine.getManager( AttachmentManager.class );
         m_engine.saveText( NAME1, "fooBar");
 
         final Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
@@ -165,8 +167,8 @@ public class WikiEngineTest {
 
     @Test
     public void testAttachmentRefs2() throws Exception {
-        final ReferenceManager refMgr = m_engine.getReferenceManager();
-        final AttachmentManager attMgr = m_engine.getAttachmentManager();
+        final ReferenceManager refMgr = m_engine.getManager( ReferenceManager.class );
+        final AttachmentManager attMgr = m_engine.getManager( AttachmentManager.class );
 
         m_engine.saveText( NAME1, "[TestAtt.txt]");
 
@@ -206,8 +208,8 @@ public class WikiEngineTest {
      */
     @Test
     public void testAttachmentRefs3() throws Exception {
-        final ReferenceManager refMgr = m_engine.getReferenceManager();
-        final AttachmentManager attMgr = m_engine.getAttachmentManager();
+        final ReferenceManager refMgr = m_engine.getManager( ReferenceManager.class );
+        final AttachmentManager attMgr = m_engine.getManager( AttachmentManager.class );
 
         m_engine.saveText( NAME1, "fooBar");
 
@@ -231,8 +233,8 @@ public class WikiEngineTest {
      */
     @Test
     public void testAttachmentRefs4() throws Exception {
-        final ReferenceManager refMgr = m_engine.getReferenceManager();
-        final AttachmentManager attMgr = m_engine.getAttachmentManager();
+        final ReferenceManager refMgr = m_engine.getManager( ReferenceManager.class );
+        final AttachmentManager attMgr = m_engine.getManager( AttachmentManager.class );
 
         m_engine.saveText( NAME1, "[TestPage2]");
 
@@ -279,7 +281,7 @@ public class WikiEngineTest {
     @Test
     public void testParsedVariables() throws Exception {
         m_engine.saveText( "TestPage", "[{SET foo=bar}][{SamplePlugin text='{$foo}'}]");
-        final String res = m_engine.getRenderingManager().getHTML( "TestPage" );
+        final String res = m_engine.getManager( RenderingManager.class ).getHTML( "TestPage" );
 
         Assertions.assertEquals( "bar\n", res );
     }
@@ -292,16 +294,16 @@ public class WikiEngineTest {
         m_engine.saveText( "RenameBugTestPage", "Mary had a little generic object" );
         m_engine.saveText( "OldNameTestPage", "Linked to RenameBugTestPage" );
 
-        Collection< String > pages = m_engine.getReferenceManager().findReferrers( "RenameBugTestPage" );
+        Collection< String > pages = m_engine.getManager( ReferenceManager.class ).findReferrers( "RenameBugTestPage" );
         Assertions.assertEquals( "OldNameTestPage", pages.iterator().next(), "has one" );
 
         final WikiContext ctx = new WikiContext( m_engine, m_engine.getManager( PageManager.class ).getPage("OldNameTestPage") );
-        m_engine.getPageRenamer().renamePage( ctx, "OldNameTestPage", "NewNameTestPage", true );
+        m_engine.getManager( PageRenamer.class ).renamePage( ctx, "OldNameTestPage", "NewNameTestPage", true );
 
         Assertions.assertFalse( m_engine.getManager( PageManager.class ).wikiPageExists( "OldNameTestPage"), "did not vanish" );
         Assertions.assertTrue( m_engine.getManager( PageManager.class ).wikiPageExists( "NewNameTestPage"), "did not appear" );
 
-        pages = m_engine.getReferenceManager().findReferrers( "RenameBugTestPage" );
+        pages = m_engine.getManager( ReferenceManager.class ).findReferrers( "RenameBugTestPage" );
         Assertions.assertEquals( 1, pages.size(),  "wrong # of referrers" );
         Assertions.assertEquals( "NewNameTestPage", pages.iterator().next(), "has wrong referrer" );
     }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/WikiSessionTest.java b/jspwiki-main/src/test/java/org/apache/wiki/WikiSessionTest.java
index 1fea90b..a49ca99 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiSessionTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiSessionTest.java
@@ -252,7 +252,7 @@ public class WikiSessionTest
     public static Session assertedSession( final TestEngine engine, final String name, final Principal[] roles ) throws Exception
     {
         // We can use cookies right?
-        if ( !engine.getAuthenticationManager().allowsCookieAssertions() )
+        if ( !engine.getManager( AuthenticationManager.class ).allowsCookieAssertions() )
         {
             throw new IllegalStateException( "Couldn't set up asserted user: login config doesn't allow cookies." );
         }
@@ -292,7 +292,7 @@ public class WikiSessionTest
 
         // Log in the user with credentials
         final Session session = WikiSession.getWikiSession( engine, request );
-        engine.getAuthenticationManager().login( session, request, id, password );
+        engine.getManager( AuthenticationManager.class ).login( session, request, id, password );
 
         // Make sure the user is actually authenticated
         if ( !session.isAuthenticated() )
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
index 0e37e82..2fb931f 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/attachment/AttachmentManagerTest.java
@@ -48,7 +48,7 @@ public class AttachmentManagerTest {
     @BeforeEach
     public void setUp() throws Exception {
         m_engine  = TestEngine.build();
-        m_manager = m_engine.getAttachmentManager();
+        m_manager = m_engine.getManager( AttachmentManager.class );
 
         m_engine.saveText( NAME1, "Foobar" );
         m_engine.saveText( NAMEU, "Foobar" );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthenticationManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthenticationManagerTest.java
index b8da2f6..37971e9 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthenticationManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthenticationManagerTest.java
@@ -89,7 +89,7 @@ public class AuthenticationManagerTest {
     public void setUp() throws Exception {
         final Properties props = TestEngine.getTestProperties();
         m_engine = new TestEngine( props );
-        m_auth = m_engine.getAuthenticationManager();
+        m_auth = m_engine.getManager( AuthenticationManager.class );
         m_groupMgr = m_engine.getGroupManager();
         m_session = WikiSessionTest.adminSession( m_engine );
     }
@@ -138,7 +138,7 @@ public class AuthenticationManagerTest {
         // Init the engine and verify that we initialized with a custom auth
         // login module
         final WikiEngine engine = new TestEngine( props );
-        final DefaultAuthenticationManager authMgr = ( DefaultAuthenticationManager )engine.getAuthenticationManager();
+        final DefaultAuthenticationManager authMgr = ( DefaultAuthenticationManager )engine.getManager( AuthenticationManager.class );
         Assertions.assertEquals( CookieAssertionLoginModule.class, authMgr.m_loginModuleClass );
     }
 
@@ -154,7 +154,7 @@ public class AuthenticationManagerTest {
         // Init the engine and verify that we initialized with the correct
         // options
         final WikiEngine engine = new TestEngine( props );
-        final DefaultAuthenticationManager authMgr = ( DefaultAuthenticationManager )engine.getAuthenticationManager();
+        final DefaultAuthenticationManager authMgr = ( DefaultAuthenticationManager )engine.getManager( AuthenticationManager.class );
         final Map<String, String> options = authMgr.m_loginModuleOptions;
         Assertions.assertEquals( 3, options.size() );
         Assertions.assertTrue( options.containsKey( "key1" ) );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
index f2b2b8a..2f86374 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/AuthorizationManagerTest.java
@@ -26,6 +26,7 @@ import org.apache.wiki.api.core.Session;
 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.acl.UnresolvedPrincipal;
 import org.apache.wiki.auth.authorize.Group;
 import org.apache.wiki.auth.authorize.GroupManager;
@@ -84,7 +85,7 @@ public class AuthorizationManagerTest
 
         // Initialize the test engine
         m_engine = new TestEngine( props );
-        m_auth = m_engine.getAuthorizationManager();
+        m_auth = m_engine.getManager( AuthorizationManager.class );
         m_groupMgr = m_engine.getGroupManager();
         m_session = WikiSessionTest.adminSession( m_engine );
     }
@@ -265,7 +266,7 @@ public class AuthorizationManagerTest
         final File f = m_engine.makeAttachmentFile();
         final Attachment att = new Attachment( m_engine, "Test", "test1.txt" );
         att.setAuthor( "FirstPost" );
-        m_engine.getAttachmentManager().storeAttachment( att, f );
+        m_engine.getManager( AttachmentManager.class ).storeAttachment( att, f );
 
         final Attachment p = (Attachment) m_engine.getManager( PageManager.class ).getPage( "Test/test1.txt" );
         final Permission view = PermissionFactory.getPagePermission( p, "view" );
@@ -282,7 +283,7 @@ public class AuthorizationManagerTest
         Assertions.assertFalse( m_auth.checkPermission( session, edit ), "Bob !view Test/test1.txt" );
 
         // Delete test page & attachment
-        m_engine.getAttachmentManager().deleteAttachment( att );
+        m_engine.getManager( AttachmentManager.class ).deleteAttachment( att );
         m_engine.getManager( PageManager.class ).deletePage( "Test" );
     }
 
@@ -296,7 +297,7 @@ public class AuthorizationManagerTest
         final File f = m_engine.makeAttachmentFile();
         final Attachment att = new Attachment( m_engine, "Test", "test1.txt" );
         att.setAuthor( "FirstPost" );
-        m_engine.getAttachmentManager().storeAttachment( att, f );
+        m_engine.getManager( AttachmentManager.class ).storeAttachment( att, f );
 
         final Attachment p = (Attachment) m_engine.getManager( PageManager.class ).getPage( "Test/test1.txt" );
         final Permission view = PermissionFactory.getPagePermission( p, "view" );
@@ -313,7 +314,7 @@ public class AuthorizationManagerTest
         Assertions.assertFalse( m_auth.checkPermission( session, view ), "Bar !edit Test" );
 
         // Delete test page & attachment
-        m_engine.getAttachmentManager().deleteAttachment( att );
+        m_engine.getManager( AttachmentManager.class ).deleteAttachment( att );
         m_engine.getManager( PageManager.class ).deletePage( "Test" );
     }
 
@@ -510,13 +511,13 @@ public class AuthorizationManagerTest
     public void testResolveUsers() throws WikiException
     {
         // We should be able to resolve a user by login, user, or wiki name
-        final UserProfile profile = m_engine.getUserManager().getUserDatabase().newProfile();
+        final UserProfile profile = m_engine.getManager( UserManager.class ).getUserDatabase().newProfile();
         profile.setEmail( "authmanagertest@tester.net" );
         profile.setFullname( "AuthorizationManagerTest User" );
         profile.setLoginName( "authmanagertest" );
         try
         {
-            m_engine.getUserManager().getUserDatabase().save( profile );
+            m_engine.getManager( UserManager.class ).getUserDatabase().save( profile );
         }
         catch( final WikiSecurityException e )
         {
@@ -527,7 +528,7 @@ public class AuthorizationManagerTest
         Assertions.assertEquals( new WikiPrincipal( "AuthorizationManagerTestUser", WikiPrincipal.WIKI_NAME ), m_auth.resolvePrincipal( "AuthorizationManagerTestUser" ) );
         try
         {
-            m_engine.getUserManager().getUserDatabase().deleteByLoginName( "authmanagertest" );
+            m_engine.getManager( UserManager.class ).getUserDatabase().deleteByLoginName( "authmanagertest" );
         }
         catch( final WikiSecurityException e )
         {
@@ -668,7 +669,7 @@ public class AuthorizationManagerTest
 
         // Initialize the test engine
         m_engine = new TestEngine( props );
-        m_auth = m_engine.getAuthorizationManager();
+        m_auth = m_engine.getManager( AuthorizationManager.class );
         m_groupMgr = m_engine.getGroupManager();
         m_session = WikiSessionTest.adminSession( m_engine );
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
index 1f3d189..3849b5a 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/UserManagerTest.java
@@ -102,7 +102,7 @@ public class UserManagerTest {
         final int oldUserCount = m_db.getWikiNames().length;
         final GroupManager groupManager = m_engine.getGroupManager();
         final PageManager pageManager = m_engine.getManager( PageManager.class );
-        final AuthorizationManager authManager = m_engine.getAuthorizationManager();
+        final AuthorizationManager authManager = m_engine.getManager( AuthorizationManager.class );
         final int oldGroupCount = groupManager.getRoles().length;
         final int oldPageCount = pageManager.getTotalPageCount();
 
@@ -315,7 +315,7 @@ public class UserManagerTest {
         Assertions.assertEquals( oldUserCount, m_db.getWikiNames().length );
 
         // Now, look in Admin's queue, and verify there's a pending Decision there
-        final DecisionQueue dq = m_engine.getWorkflowManager().getDecisionQueue();
+        final DecisionQueue dq = m_engine.getManager( WorkflowManager.class ).getDecisionQueue();
         final Collection< Decision > decisions = dq.getActorDecisions( m_engine.adminSession() );
         Assertions.assertEquals( 1, decisions.size() );
 
@@ -366,7 +366,7 @@ public class UserManagerTest {
         Assertions.assertEquals( oldUserCount, m_db.getWikiNames().length );
 
         // Now, look in Admin's queue, and verify there's a pending Decision there
-        final DecisionQueue dq = m_engine.getWorkflowManager().getDecisionQueue();
+        final DecisionQueue dq = m_engine.getManager( WorkflowManager.class ).getDecisionQueue();
         final Collection< Decision > decisions = dq.getActorDecisions( m_engine.adminSession() );
         Assertions.assertEquals( 1, decisions.size() );
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/AclImplTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/AclImplTest.java
index 4a072ea..c213463 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/AclImplTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/AclImplTest.java
@@ -39,19 +39,15 @@ import java.io.ObjectOutputStream;
 import java.security.Principal;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.Properties;
 
-public class AclImplTest
-{
-    private AclImpl m_acl;
-
-    private AclImpl m_aclGroup;
-
-    private Map<String, Group> m_groups;
+public class AclImplTest {
 
-    private GroupManager m_groupMgr;
+    final TestEngine engine = TestEngine.build();
+    final GroupManager m_groupMgr = engine.getManager( GroupManager.class );
 
-    private Session m_session;
+    private AclImpl m_acl;
+    private AclImpl m_aclGroup;
+    private Map< String, Group > m_groups;
 
     /**
      * We setup the following rules: Alice = may view Bob = may view, may edit
@@ -59,14 +55,8 @@ public class AclImplTest
      * Alice, Bob - may edit BarGroup = Bob, Charlie - may view
      */
     @BeforeEach
-    public void setUp() throws Exception
-    {
-
-        final Properties props = TestEngine.getTestProperties();
-        final TestEngine engine  = new TestEngine( props );
-        m_groupMgr = engine.getGroupManager();
-        m_session = WikiSessionTest.adminSession( engine );
-
+    public void setUp() throws Exception {
+        final Session m_session = WikiSessionTest.adminSession( engine );
         m_acl = new AclImpl();
         m_aclGroup = new AclImpl();
         m_groups = new HashMap<>();
@@ -127,34 +117,26 @@ public class AclImplTest
     }
 
     @AfterEach
-    public void tearDown() throws Exception
-    {
+    public void tearDown() throws Exception {
         m_groupMgr.removeGroup( "FooGroup" );
         m_groupMgr.removeGroup( "BarGroup" );
     }
 
-    private boolean inArray( final Object[] array, final Object key )
-    {
-        for( int i = 0; i < array.length; i++ )
-        {
-            if ( array[i].equals( key ) )
-            {
+    private boolean inArray( final Object[] array, final Object key ) {
+        for( final Object o : array ) {
+            if( o.equals( key ) ) {
                 return true;
             }
         }
         return false;
     }
 
-    private boolean inGroup( final Object[] array, final Principal key )
-    {
-        for( int i = 0; i < array.length; i++ )
-        {
-            if ( array[i] instanceof GroupPrincipal )
-            {
-                final String groupName = ((GroupPrincipal)array[i]).getName();
+    private boolean inGroup( final Object[] array, final Principal key ) {
+        for( final Object o : array ) {
+            if( o instanceof GroupPrincipal ) {
+                final String groupName = ( ( GroupPrincipal )o ).getName();
                 final Group group = m_groups.get( groupName );
-                if ( group != null && group.isMember( key ) )
-                {
+                if( group != null && group.isMember( key ) ) {
                     return true;
                 }
             }
@@ -163,8 +145,7 @@ public class AclImplTest
     }
 
     @Test
-    public void testAlice()
-    {
+    public void testAlice() {
         // Alice should be able to view but not edit or comment
         final Principal wup = new WikiPrincipal( "Alice" );
         Assertions.assertTrue( inArray( m_acl.findPrincipals( PagePermission.VIEW ), wup ) );
@@ -173,8 +154,7 @@ public class AclImplTest
     }
 
     @Test
-    public void testBob()
-    {
+    public void testBob() {
         // Bob should be able to view, edit, and comment but not delete
         final Principal wup = new WikiPrincipal( "Bob" );
         Assertions.assertTrue( inArray( m_acl.findPrincipals( PagePermission.VIEW ), wup ) );
@@ -184,8 +164,7 @@ public class AclImplTest
     }
 
     @Test
-    public void testCharlie()
-    {
+    public void testCharlie() {
         // Charlie should be able to view, but not edit, comment or delete
         final Principal wup = new WikiPrincipal( "Charlie" );
         Assertions.assertTrue( inArray( m_acl.findPrincipals( PagePermission.VIEW ), wup ) );
@@ -195,8 +174,7 @@ public class AclImplTest
     }
 
     @Test
-    public void testDave()
-    {
+    public void testDave() {
         // Dave should be able to view and comment but not edit or delete
         final Principal wup = new WikiPrincipal( "Dave" );
         Assertions.assertTrue( inArray( m_acl.findPrincipals( PagePermission.VIEW ), wup ) );
@@ -206,8 +184,7 @@ public class AclImplTest
     }
 
     @Test
-    public void testGroups()
-    {
+    public void testGroups() {
         Principal wup = new WikiPrincipal( "Alice" );
         Assertions.assertTrue( inGroup( m_aclGroup.findPrincipals( PagePermission.VIEW ), wup ), "Alice view" );
         Assertions.assertTrue( inGroup( m_aclGroup.findPrincipals( PagePermission.EDIT ), wup ), "Alice edit" );
@@ -234,20 +211,13 @@ public class AclImplTest
     }
 
     @Test
-    public void testSerialization() throws IOException, ClassNotFoundException
-    {
+    public void testSerialization() throws IOException, ClassNotFoundException {
         final ByteArrayOutputStream out = new ByteArrayOutputStream();
-
         final ObjectOutputStream out2 = new ObjectOutputStream(out);
-
         out2.writeObject( m_acl );
-
         out2.close();
-
         final byte[] stuff = out.toByteArray();
-
         final ObjectInputStream in = new ObjectInputStream( new ByteArrayInputStream(stuff) );
-
         final AclImpl newacl = (AclImpl) in.readObject();
         Assertions.assertEquals( newacl.toString(), m_acl.toString() );
     }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/login/CookieAssertionLoginModuleTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/login/CookieAssertionLoginModuleTest.java
index a67e029..3547a29 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/login/CookieAssertionLoginModuleTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/login/CookieAssertionLoginModuleTest.java
@@ -17,28 +17,27 @@
     under the License.
  */
 package org.apache.wiki.auth.login;
-import java.security.Principal;
-import java.util.HashMap;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.security.auth.Subject;
-import javax.security.auth.callback.CallbackHandler;
-import javax.security.auth.login.LoginException;
-import javax.security.auth.spi.LoginModule;
-import javax.servlet.http.Cookie;
-
+import net.sourceforge.stripes.mock.MockHttpServletRequest;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
+import org.apache.wiki.auth.AuthenticationManager;
 import org.apache.wiki.auth.WikiPrincipal;
 import org.apache.wiki.auth.authorize.Role;
 import org.apache.wiki.auth.user.UserDatabase;
 import org.apache.wiki.auth.user.XMLUserDatabase;
-import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
-import net.sourceforge.stripes.mock.MockHttpServletRequest;
+import javax.security.auth.Subject;
+import javax.security.auth.callback.CallbackHandler;
+import javax.security.auth.login.LoginException;
+import javax.security.auth.spi.LoginModule;
+import javax.servlet.http.Cookie;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.Properties;
+import java.util.Set;
 
 /**
  */
@@ -53,30 +52,28 @@ public class CookieAssertionLoginModuleTest
     @Test
     public final void testLogin()
     {
-        MockHttpServletRequest request = m_engine.newHttpRequest();
+        final MockHttpServletRequest request = m_engine.newHttpRequest();
         try
         {
             // We can use cookies right?
-            Assertions.assertTrue( m_engine.getAuthenticationManager().allowsCookieAssertions() );
+            Assertions.assertTrue( m_engine.getManager( AuthenticationManager.class ).allowsCookieAssertions() );
 
             // Test using Cookie and IP address (AnonymousLoginModule succeeds)
-            Cookie cookie = new Cookie( CookieAssertionLoginModule.PREFS_COOKIE_NAME, "Bullwinkle" );
+            final Cookie cookie = new Cookie( CookieAssertionLoginModule.PREFS_COOKIE_NAME, "Bullwinkle" );
             request.setCookies( new Cookie[] { cookie } );
             m_subject = new Subject();
-            CallbackHandler handler = new WebContainerCallbackHandler( m_engine, request );
-            LoginModule module = new CookieAssertionLoginModule();
-            module.initialize( m_subject, handler,
-                              new HashMap<String, Object>(),
-                              new HashMap<String, Object>() );
+            final CallbackHandler handler = new WebContainerCallbackHandler( m_engine, request );
+            final LoginModule module = new CookieAssertionLoginModule();
+            module.initialize( m_subject, handler, new HashMap<>(), new HashMap<>() );
             module.login();
             module.commit();
-            Set< Principal > principals = m_subject.getPrincipals();
+            final Set< Principal > principals = m_subject.getPrincipals();
             Assertions.assertEquals( 1, principals.size() );
             Assertions.assertTrue( principals.contains( new WikiPrincipal( "Bullwinkle" ) ) );
             Assertions.assertFalse( principals.contains( Role.ASSERTED ) );
             Assertions.assertFalse( principals.contains( Role.ALL ) );
         }
-        catch( LoginException e )
+        catch( final LoginException e )
         {
             System.err.println( e.getMessage() );
             Assertions.assertTrue( false );
@@ -86,19 +83,17 @@ public class CookieAssertionLoginModuleTest
     @Test
     public final void testLogout()
     {
-        MockHttpServletRequest request = m_engine.newHttpRequest();
-        Cookie cookie = new Cookie( CookieAssertionLoginModule.PREFS_COOKIE_NAME, "Bullwinkle" );
+        final MockHttpServletRequest request = m_engine.newHttpRequest();
+        final Cookie cookie = new Cookie( CookieAssertionLoginModule.PREFS_COOKIE_NAME, "Bullwinkle" );
         request.setCookies( new Cookie[] { cookie } );
         try
         {
-            CallbackHandler handler = new WebContainerCallbackHandler( m_engine, request );
-            LoginModule module = new CookieAssertionLoginModule();
-            module.initialize( m_subject, handler,
-                              new HashMap<String, Object>(),
-                              new HashMap<String, Object>() );
+            final CallbackHandler handler = new WebContainerCallbackHandler( m_engine, request );
+            final LoginModule module = new CookieAssertionLoginModule();
+            module.initialize( m_subject, handler, new HashMap<>(), new HashMap<>() );
             module.login();
             module.commit();
-            Set< Principal > principals = m_subject.getPrincipals();
+            final Set< Principal > principals = m_subject.getPrincipals();
             Assertions.assertEquals( 1, principals.size() );
             Assertions.assertTrue( principals.contains( new WikiPrincipal( "Bullwinkle" ) ) );
             Assertions.assertFalse( principals.contains( Role.ANONYMOUS ) );
@@ -106,7 +101,7 @@ public class CookieAssertionLoginModuleTest
             module.logout();
             Assertions.assertEquals( 0, principals.size() );
         }
-        catch( LoginException e )
+        catch( final LoginException e )
         {
             System.err.println( e.getMessage() );
             Assertions.assertTrue( false );
@@ -119,7 +114,7 @@ public class CookieAssertionLoginModuleTest
     @BeforeEach
     public void setUp() throws Exception
     {
-        Properties props = TestEngine.getTestProperties();
+        final Properties props = TestEngine.getTestProperties();
         props.put(XMLUserDatabase.PROP_USERDATABASE, "target/test-classes/userdatabase.xml" );
         m_engine = new TestEngine(props);
         m_db = new XMLUserDatabase();
@@ -128,7 +123,7 @@ public class CookieAssertionLoginModuleTest
         {
             m_db.initialize( m_engine, props );
         }
-        catch( NoRequiredPropertyException e )
+        catch( final NoRequiredPropertyException e )
         {
             System.err.println( e.getMessage() );
             Assertions.assertTrue( false );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/user/UserProfileTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/user/UserProfileTest.java
index f17c0ef..adc6209 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/user/UserProfileTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/user/UserProfileTest.java
@@ -18,9 +18,8 @@
  */
 package org.apache.wiki.auth.user;
 import org.apache.wiki.TestEngine;
-import org.apache.wiki.WikiEngine;
+import org.apache.wiki.auth.UserManager;
 import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import java.util.Date;
@@ -28,22 +27,14 @@ import java.util.Date;
 /**
  *  Tests the DefaultUserProfile class.
  */
-public class UserProfileTest
-{
-    private UserDatabase m_db;
-
-    @BeforeEach
-    public void setUp()
-        throws Exception
-    {
-            WikiEngine engine  = new TestEngine();
-            m_db = engine.getUserManager().getUserDatabase();
-    }
+public class UserProfileTest {
+
+    TestEngine engine = TestEngine.build();
+    UserDatabase m_db = engine.getManager( UserManager.class ).getUserDatabase();
 
     @Test
-    public void testSetAttribute()
-    {
-        UserProfile p = m_db.newProfile();
+    public void testSetAttribute() {
+        final UserProfile p = m_db.newProfile();
         Assertions.assertEquals( 0, p.getAttributes().size() );
 
         p.getAttributes().put( "MyAttribute", "some arbitrary value." );
@@ -59,9 +50,8 @@ public class UserProfileTest
     }
 
     @Test
-    public void testSetLockExpiry()
-    {
-        UserProfile p = m_db.newProfile();
+    public void testSetLockExpiry() {
+        final UserProfile p = m_db.newProfile();
         Assertions.assertNull( p.getLockExpiry() );
         Assertions.assertFalse( p.isLocked() );
 
@@ -76,7 +66,7 @@ public class UserProfileTest
         Assertions.assertNull( p.getLockExpiry() );
 
         // Now set a lock for 100 seconds in the future; lock should be reported correctly
-        Date future = new Date( System.currentTimeMillis() + 100000 );
+        final Date future = new Date( System.currentTimeMillis() + 100000 );
         p.setLockExpiry( future );
         Assertions.assertTrue( p.isLocked() );
         Assertions.assertEquals( future, p.getLockExpiry() );
@@ -88,36 +78,33 @@ public class UserProfileTest
     }
 
     @Test
-    public void testSetUid()
-    {
-        UserProfile p = m_db.newProfile();
+    public void testSetUid() {
+        final UserProfile p = m_db.newProfile();
         Assertions.assertNotSame( "1234567890", p.getUid() );
         p.setUid( "1234567890" );
         Assertions.assertEquals( "1234567890", p.getUid() );
     }
 
     @Test
-    public void testEquals()
-    {
-        UserProfile p = m_db.newProfile();
-        UserProfile p2 = m_db.newProfile();
+    public void testEquals() {
+        final UserProfile p = m_db.newProfile();
+        final UserProfile p2 = m_db.newProfile();
 
         p.setFullname("Alice");
         p2.setFullname("Bob");
 
-        Assertions.assertFalse( p.equals( p2 ) );
+        Assertions.assertNotEquals( p, p2 );
     }
 
     @Test
-    public void testEquals2()
-    {
-        UserProfile p = m_db.newProfile();
-        UserProfile p2 = m_db.newProfile();
+    public void testEquals2() {
+        final UserProfile p = m_db.newProfile();
+        final UserProfile p2 = m_db.newProfile();
 
         p.setFullname("Alice");
         p2.setFullname("Alice");
 
-        Assertions.assertTrue( p.equals( p2 ) );
+        Assertions.assertEquals( p, p2 );
     }
 
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
index 3653c5d..b748798 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/content/PageRenamerTest.java
@@ -26,7 +26,9 @@ import org.apache.wiki.api.core.Attachment;
 import org.apache.wiki.api.core.Page;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.api.providers.WikiProvider;
+import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.pages.PageManager;
+import org.apache.wiki.references.ReferenceManager;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
@@ -73,7 +75,7 @@ public class PageRenamerTest
     @Test
     public void testSimpleRename() throws Exception {
         // Count the number of existing references
-        final int refCount = m_engine.getReferenceManager().findCreated().size();
+        final int refCount = m_engine.getManager( ReferenceManager.class ).findCreated().size();
 
         m_engine.saveText("TestPage", "the big lazy dog thing" );
 
@@ -81,7 +83,7 @@ public class PageRenamerTest
 
         final WikiContext context = new WikiContext(m_engine, p);
 
-        m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", false);
+        m_engine.getManager( PageRenamer.class ).renamePage(context, "TestPage", "FooTest", false);
 
         final Page newpage = m_engine.getManager( PageManager.class ).getPage("FooTest");
 
@@ -89,7 +91,7 @@ public class PageRenamerTest
         Assertions.assertNull( m_engine.getManager( PageManager.class ).getPage("TestPage"), "old page not gone" );
 
         // Refmgr
-        final Collection< String > refs = m_engine.getReferenceManager().findCreated();
+        final Collection< String > refs = m_engine.getManager( ReferenceManager.class ).findCreated();
 
         Assertions.assertTrue( refs.contains("FooTest"), "FooTest does not exist" );
         Assertions.assertFalse( refs.contains("TestPage"), "TestPage exists" );
@@ -107,17 +109,17 @@ public class PageRenamerTest
 
         final WikiContext context = new WikiContext(m_engine, p);
 
-        m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", true);
+        m_engine.getManager( PageRenamer.class ).renamePage(context, "TestPage", "FooTest", true);
 
         final String data = m_engine.getManager( PageManager.class ).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
 
         Assertions.assertEquals( "[FooTest]", data.trim(), "no rename" );
 
-        Collection< String > refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        Collection< String > refs = m_engine.getManager( ReferenceManager.class ).findReferrers("TestPage");
 
         Assertions.assertNull( refs, "oldpage" );
 
-        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        refs = m_engine.getManager( ReferenceManager.class ).findReferrers( "FooTest" );
         Assertions.assertEquals( 1, refs.size(), "new size" );
         Assertions.assertEquals( "TestPage2", refs.iterator().next(), "wrong ref" );
     }
@@ -133,16 +135,16 @@ public class PageRenamerTest
 
         final WikiContext context = new WikiContext(m_engine, p);
 
-        m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", true);
+        m_engine.getManager( PageRenamer.class ).renamePage(context, "TestPage", "FooTest", true);
 
         final String data = m_engine.getManager( PageManager.class ).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
 
         Assertions.assertEquals( "FooTest", data.trim(), "no rename" );
-        Collection< String > refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        Collection< String > refs = m_engine.getManager( ReferenceManager.class ).findReferrers("TestPage");
 
         Assertions.assertNull( refs, "oldpage" );
 
-        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        refs = m_engine.getManager( ReferenceManager.class ).findReferrers( "FooTest" );
         Assertions.assertEquals( 1, refs.size(), "new size" );
         Assertions.assertEquals( "TestPage2", refs.iterator().next(), "wrong ref" );
     }
@@ -158,16 +160,16 @@ public class PageRenamerTest
 
         final WikiContext context = new WikiContext(m_engine, p);
 
-        m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", true);
+        m_engine.getManager( PageRenamer.class ).renamePage(context, "TestPage", "FooTest", true);
 
         final String data = m_engine.getManager( PageManager.class ).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
 
         Assertions.assertEquals( "[FooTest#heading1]", data.trim(), "no rename" );
-        Collection< String > refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        Collection< String > refs = m_engine.getManager( ReferenceManager.class ).findReferrers("TestPage");
 
         Assertions.assertNull( refs, "oldpage" );
 
-        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        refs = m_engine.getManager( ReferenceManager.class ).findReferrers( "FooTest" );
         Assertions.assertEquals( 1, refs.size(), "new size" );
         Assertions.assertEquals( "TestPage2", refs.iterator().next(), "wrong ref" );
     }
@@ -183,7 +185,7 @@ public class PageRenamerTest
 
         final WikiContext context = new WikiContext(m_engine, p);
 
-        m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", true);
+        m_engine.getManager( PageRenamer.class ).renamePage(context, "TestPage", "FooTest", true);
 
         final String data = m_engine.getManager( PageManager.class ).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
 
@@ -191,11 +193,11 @@ public class PageRenamerTest
                                  data.trim(), 
                                  "no rename" );
 
-        Collection< String > refs = m_engine.getReferenceManager().findReferrers("TestPage");
+        Collection< String > refs = m_engine.getManager( ReferenceManager.class ).findReferrers("TestPage");
 
         Assertions.assertNull( refs, "oldpage" );
 
-        refs = m_engine.getReferenceManager().findReferrers( "FooTest" );
+        refs = m_engine.getManager( ReferenceManager.class ).findReferrers( "FooTest" );
         Assertions.assertEquals( 1, refs.size(), "new size" );
         Assertions.assertEquals( "TestPage2", refs.iterator().next(), "wrong ref" );
     }
@@ -211,7 +213,7 @@ public class PageRenamerTest
 
         final WikiContext context = new WikiContext(m_engine, p);
 
-        m_engine.getPageRenamer().renamePage(context, "Test", "TestPage", true);
+        m_engine.getManager( PageRenamer.class ).renamePage(context, "Test", "TestPage", true);
 
         final String data = m_engine.getManager( PageManager.class ).getPureText("TestPage2", WikiProvider.LATEST_VERSION );
 
@@ -231,29 +233,29 @@ public class PageRenamerTest
 
         final WikiContext context = new WikiContext(m_engine, p);
 
-        m_engine.getPageRenamer().renamePage(context, "TestPage", "FooTest", true);
+        m_engine.getManager( PageRenamer.class ).renamePage(context, "TestPage", "FooTest", true);
 
         final String data = m_engine.getManager( PageManager.class ).getPureText("TestPage2", WikiProvider.LATEST_VERSION);
 
         Assertions.assertEquals( "[FooTest/foo.txt] [linktext|FooTest/bar.jpg]", data.trim(), "no rename" );
 
-        Attachment att = m_engine.getAttachmentManager().getAttachmentInfo("FooTest/foo.txt");
+        Attachment att = m_engine.getManager( AttachmentManager.class ).getAttachmentInfo("FooTest/foo.txt");
         Assertions.assertNotNull( att, "footext" );
 
-        att = m_engine.getAttachmentManager().getAttachmentInfo("FooTest/bar.jpg");
+        att = m_engine.getManager( AttachmentManager.class ).getAttachmentInfo("FooTest/bar.jpg");
         Assertions.assertNotNull( att, "barjpg" );
 
-        att = m_engine.getAttachmentManager().getAttachmentInfo("TestPage/bar.jpg");
+        att = m_engine.getManager( AttachmentManager.class ).getAttachmentInfo("TestPage/bar.jpg");
         Assertions.assertNull( att, "testpage/bar.jpg exists" );
 
-        att = m_engine.getAttachmentManager().getAttachmentInfo("TestPage/foo.txt");
+        att = m_engine.getManager( AttachmentManager.class ).getAttachmentInfo("TestPage/foo.txt");
         Assertions.assertNull( att, "testpage/foo.txt exists" );
 
-        Collection< String > refs = m_engine.getReferenceManager().findReferrers("TestPage/bar.jpg");
+        Collection< String > refs = m_engine.getManager( ReferenceManager.class ).findReferrers("TestPage/bar.jpg");
 
         Assertions.assertNull( refs, "oldpage" );
 
-        refs = m_engine.getReferenceManager().findReferrers( "FooTest/bar.jpg" );
+        refs = m_engine.getManager( ReferenceManager.class ).findReferrers( "FooTest/bar.jpg" );
         Assertions.assertEquals( 1, refs.size(), "new size" );
         Assertions.assertEquals( "TestPage2", refs.iterator().next(), "wrong ref" );
     }
@@ -310,7 +312,7 @@ public class PageRenamerTest
 
         final WikiContext context = new WikiContext(m_engine, p);
 
-        m_engine.getPageRenamer().renamePage(context, src, dst, true);
+        m_engine.getManager( PageRenamer.class ).renamePage(context, src, dst, true);
     }
 
     @Test
@@ -486,10 +488,10 @@ public class PageRenamerTest
         final String data = m_engine.getManager( PageManager.class ).getPureText( "TestPageReferring", WikiProvider.LATEST_VERSION );
         Assertions.assertEquals( "[Test Page Referred|TestPageReferredNew]", data.trim(), "page not renamed" );
 
-        Collection< String > refs = m_engine.getReferenceManager().findReferrers( "TestPageReferred" );
+        Collection< String > refs = m_engine.getManager( ReferenceManager.class ).findReferrers( "TestPageReferred" );
         Assertions.assertNull( refs, "oldpage" );
 
-        refs = m_engine.getReferenceManager().findReferrers( "TestPageReferredNew" );
+        refs = m_engine.getManager( ReferenceManager.class ).findReferrers( "TestPageReferredNew" );
         Assertions.assertEquals( 1, refs.size(), "new size" );
         Assertions.assertEquals( "TestPageReferring", refs.iterator().next(), "wrong ref" );
     }
@@ -507,10 +509,10 @@ public class PageRenamerTest
         final String data = m_engine.getManager( PageManager.class ).getPureText( "RenameTest", WikiProvider.LATEST_VERSION );
         Assertions.assertEquals( "[link one|Link uno] [link two]", data.trim(), "page not renamed" );
 
-        Collection< String > refs = m_engine.getReferenceManager().findReferrers( "Link one" );
+        Collection< String > refs = m_engine.getManager( ReferenceManager.class ).findReferrers( "Link one" );
         Assertions.assertNull( refs, "oldpage" );
 
-        refs = m_engine.getReferenceManager().findReferrers( "Link uno" );
+        refs = m_engine.getManager( ReferenceManager.class ).findReferrers( "Link uno" );
         Assertions.assertEquals( 1, refs.size(), "new size" );
         Assertions.assertEquals( "RenameTest", refs.iterator().next() , "wrong ref");
     }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
index 30e5c56..593d75b 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
@@ -27,9 +27,12 @@ import org.apache.wiki.api.core.Attachment;
 import org.apache.wiki.api.core.Page;
 import org.apache.wiki.api.providers.AttachmentProvider;
 import org.apache.wiki.api.providers.WikiProvider;
+import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.providers.CachingProvider;
 import org.apache.wiki.providers.FileSystemProvider;
 import org.apache.wiki.providers.VerySimpleProvider;
+import org.apache.wiki.references.ReferenceManager;
+import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.util.TextUtil;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
@@ -108,7 +111,7 @@ public class DefaultPageManagerTest {
         engine.saveText( NAME1, "Test" );
         final Attachment att = new org.apache.wiki.attachment.Attachment( engine, NAME1, "TestAtt.txt" );
         att.setAuthor( "FirstPost" );
-        engine.getAttachmentManager().storeAttachment( att, engine.makeAttachmentFile() );
+        engine.getManager( AttachmentManager.class ).storeAttachment( att, engine.makeAttachmentFile() );
 
         final String files = engine.getWikiProperties().getProperty( FileSystemProvider.PROP_PAGEDIR );
         final File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );
@@ -132,7 +135,7 @@ public class DefaultPageManagerTest {
         engine.saveText( NAME1, "Test" );
         Attachment att = new org.apache.wiki.attachment.Attachment( engine, NAME1, "TestAtt.txt" );
         att.setAuthor( "FirstPost" );
-        engine.getAttachmentManager().storeAttachment( att, engine.makeAttachmentFile() );
+        engine.getManager( AttachmentManager.class ).storeAttachment( att, engine.makeAttachmentFile() );
 
         final String files = engine.getWikiProperties().getProperty( FileSystemProvider.PROP_PAGEDIR );
         final File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );
@@ -146,13 +149,13 @@ public class DefaultPageManagerTest {
         final Page page = engine.getManager( PageManager.class ).getPage( NAME1, WikiProvider.LATEST_VERSION );
         Assertions.assertNotNull( page, "page" );
 
-        att = engine.getAttachmentManager().getAttachmentInfo(NAME1+"/TestAtt.txt");
+        att = engine.getManager( AttachmentManager.class ).getAttachmentInfo(NAME1+"/TestAtt.txt");
         engine.getManager( PageManager.class ).deletePage(att.getName());
         engine.getManager( PageManager.class ).deletePage( NAME1 );
         Assertions.assertNull( engine.getManager( PageManager.class ).getPage(NAME1), "Page not removed" );
         Assertions.assertNull( engine.getManager( PageManager.class ).getPage(NAME1+"/TestAtt.txt"), "Att not removed" );
 
-        final Collection< String > refs = engine.getReferenceManager().findReferrers(NAME1);
+        final Collection< String > refs = engine.getManager( ReferenceManager.class ).findReferrers(NAME1);
         Assertions.assertNull( refs, "referrers" );
     }
 
@@ -225,7 +228,7 @@ public class DefaultPageManagerTest {
         props.setProperty( "jspwiki.pageProvider", "org.apache.wiki.providers.VerySimpleProvider" );
         props.setProperty( "jspwiki.usePageCache", "false" );
         final WikiEngine engine = new TestEngine( props );
-        final String p = engine.getRenderingManager().getHTML( "test", -1 );
+        final String p = engine.getManager( RenderingManager.class ).getHTML( "test", -1 );
         final VerySimpleProvider vsp = (VerySimpleProvider) engine.getManager( PageManager.class ).getProvider();
 
         Assertions.assertEquals( "test", vsp.m_latestReq, "wrong page" );
@@ -239,7 +242,7 @@ public class DefaultPageManagerTest {
         props.setProperty( "jspwiki.pageProvider", "org.apache.wiki.providers.VerySimpleProvider" );
         props.setProperty( "jspwiki.usePageCache", "true" );
         final WikiEngine engine = new TestEngine( props );
-        final String p = engine.getRenderingManager().getHTML( VerySimpleProvider.PAGENAME, -1 );
+        final String p = engine.getManager( RenderingManager.class ).getHTML( VerySimpleProvider.PAGENAME, -1 );
         final CachingProvider cp = (CachingProvider)engine.getManager( PageManager.class ).getProvider();
         final VerySimpleProvider vsp = (VerySimpleProvider) cp.getRealProvider();
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java b/jspwiki-main/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
index e13cbf4..7c85001 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
@@ -30,6 +30,7 @@ import org.apache.wiki.api.providers.AttachmentProvider;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.providers.BasicAttachmentProvider;
+import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.render.XHTMLRenderer;
 import org.apache.wiki.stress.Benchmark;
 import org.apache.wiki.util.TextUtil;
@@ -806,7 +807,7 @@ public class JSPWikiMarkupParserTest
 
         testEngine2.getAttachmentManager().storeAttachment( att, testEngine.makeAttachmentFile() );
 
-        final String src = "["+testEngine2.getRenderingManager().beautifyTitle("TestPage/TestAtt.txt")+"]";
+        final String src = "["+testEngine2.getManager( RenderingManager.class ).beautifyTitle("TestPage/TestAtt.txt")+"]";
 
         Assertions.assertEquals( "<a class=\"attachment\" href=\"/test/attach/TestPage/TestAtt.txt\">Test Page/TestAtt.txt</a>"+
                       "<a href=\"/test/PageInfo.jsp?page=TestPage/TestAtt.txt\" class=\"infolink\"><img src=\"/test/images/attachment_small.png\" border=\"0\" alt=\"(info)\" /></a>",
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
index 2a7717e..cbd97a0 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/DefaultPluginManagerTest.java
@@ -25,6 +25,7 @@ import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.pages.PageManager;
+import org.apache.wiki.render.RenderingManager;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
@@ -148,7 +149,7 @@ public class DefaultPluginManagerTest {
     @Test
     public void testParserPlugin() throws Exception {
         engine.getManager( PageManager.class ).saveText(context, "[{SamplePlugin render=true}]");
-        engine.getRenderingManager().getHTML( "Testpage" );
+        engine.getManager( RenderingManager.class ).getHTML( "Testpage" );
         Assertions.assertTrue( SamplePlugin.c_rendered );
     }
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/GroupsTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/GroupsTest.java
index 21619b2..104c1ed 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/GroupsTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/GroupsTest.java
@@ -21,6 +21,7 @@ package org.apache.wiki.plugin;
 
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.pages.PageManager;
+import org.apache.wiki.render.RenderingManager;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
@@ -41,7 +42,7 @@ public class GroupsTest {
 
         testEngine.saveText( "Test", src );
 
-        final String res = testEngine.getRenderingManager().getHTML( "Test" );
+        final String res = testEngine.getManager( RenderingManager.class ).getHTML( "Test" );
 
         Assertions.assertEquals( "<a href=\"/test/Group.jsp?group=Admin\">Admin</a>, "
                 + "<a href=\"/test/Group.jsp?group=Art\">Art</a>, "
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
index 22eaeea..4560e93 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/IfPluginTest.java
@@ -27,8 +27,10 @@ import org.apache.wiki.api.core.Page;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.api.providers.PageProvider;
+import org.apache.wiki.auth.AuthenticationManager;
 import org.apache.wiki.auth.Users;
 import org.apache.wiki.pages.PageManager;
+import org.apache.wiki.render.RenderingManager;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
@@ -52,7 +54,7 @@ public class IfPluginTest {
     WikiContext getJanneBasedWikiContextFor( final Page page ) throws WikiException {
         final MockHttpServletRequest request = testEngine.newHttpRequest();
         final Session session =  WikiSession.getWikiSession( testEngine, request );
-        testEngine.getAuthenticationManager().login( session, request, Users.JANNE, Users.JANNE_PASS );
+        testEngine.getManager( AuthenticationManager.class ).login( session, request, Users.JANNE, Users.JANNE_PASS );
         return new WikiContext( testEngine, request, page );
     }
 
@@ -71,7 +73,7 @@ public class IfPluginTest {
         final Page page = testEngine.getManager( PageManager.class ).getPage( "Test", PageProvider.LATEST_VERSION );
         final WikiContext context = getJanneBasedWikiContextFor( page );
 
-        final String res = testEngine.getRenderingManager().getHTML( context, page );
+        final String res = testEngine.getManager( RenderingManager.class ).getHTML( context, page );
         Assertions.assertEquals( expected, res );
     }
 
@@ -90,7 +92,7 @@ public class IfPluginTest {
         final Page page = testEngine.getManager( PageManager.class ).getPage( "Test", PageProvider.LATEST_VERSION );
         final WikiContext context = getJanneBasedWikiContextFor( page );
 
-        final String res = testEngine.getRenderingManager().getHTML( context, page );
+        final String res = testEngine.getManager( RenderingManager.class ).getHTML( context, page );
         Assertions.assertEquals( expected, res );
     }
 
@@ -108,7 +110,7 @@ public class IfPluginTest {
         final Page page = testEngine.getManager( PageManager.class ).getPage( "Test", PageProvider.LATEST_VERSION );
         final WikiContext context = getJanneBasedWikiContextFor( page );
 
-        final String res = testEngine.getRenderingManager().getHTML( context, page );
+        final String res = testEngine.getManager( RenderingManager.class ).getHTML( context, page );
         Assertions.assertEquals( expected, res );
     }
 
@@ -126,7 +128,7 @@ public class IfPluginTest {
         final Page page = testEngine.getManager( PageManager.class ).getPage( "Test", PageProvider.LATEST_VERSION );
         final WikiContext context = getJanneBasedWikiContextFor( page );
 
-        final String res = testEngine.getRenderingManager().getHTML( context, page );
+        final String res = testEngine.getManager( RenderingManager.class ).getHTML( context, page );
         Assertions.assertEquals( expected, res );
     }
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java b/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java
index 7a3c6a4..4ca9548 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/plugin/PageViewPluginTest.java
@@ -23,6 +23,7 @@ import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.api.core.Page;
 import org.apache.wiki.pages.PageManager;
+import org.apache.wiki.render.RenderingManager;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
@@ -71,9 +72,9 @@ public class PageViewPluginTest
         final WikiContext context2 = new WikiContext( testEngine, page2 );
 
         // generate counts:
-        testEngine.getRenderingManager().getHTML( context1, page1 );
-        testEngine.getRenderingManager().getHTML( context2, page2 );
-        testEngine.getRenderingManager().getHTML( context2, page2 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context1, page1 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context2, page2 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context2, page2 );
 
         // mind the double \n in the following string:
         final String pageViewPageContent = "[{PageViewPlugin show='list''\n\n* {1} ({2} views)\n}]";
@@ -82,7 +83,7 @@ public class PageViewPluginTest
         final Page pageviews = testEngine.getManager( PageManager.class ).getPage( "PageViews" );
         final WikiContext contextPV = new WikiContext( testEngine, pageviews );
 
-        final String result = testEngine.getRenderingManager().getHTML( contextPV, pageviews );
+        final String result = testEngine.getManager( RenderingManager.class ).getHTML( contextPV, pageviews );
 //        System.out.println( result );
 
         Assertions.assertTrue( result.contains( "Test Page 01 (2 views)" ) );
@@ -101,9 +102,9 @@ public class PageViewPluginTest
         final WikiContext context2 = new WikiContext( testEngine, page2 );
 
         // generate counts:
-        testEngine.getRenderingManager().getHTML( context1, page1 );
-        testEngine.getRenderingManager().getHTML( context2, page2 );
-        testEngine.getRenderingManager().getHTML( context2, page2 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context1, page1 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context2, page2 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context2, page2 );
 
         // mind the double \n in the following string:
         final String pageViewPageContent = "[{PageViewPlugin show='list' exclude='TestPageExcl*' '\n\n* {1} ({2} views)\n}]";
@@ -112,7 +113,7 @@ public class PageViewPluginTest
         final Page pageviews = testEngine.getManager( PageManager.class ).getPage( "PageViews" );
         final WikiContext contextPV = new WikiContext( testEngine, pageviews );
 
-        final String result = testEngine.getRenderingManager().getHTML( contextPV, pageviews );
+        final String result = testEngine.getManager( RenderingManager.class ).getHTML( contextPV, pageviews );
 //        System.out.println( result );
 
         Assertions.assertTrue( result.contains( "Test Page 01" ) );
@@ -132,9 +133,9 @@ public class PageViewPluginTest
         final WikiContext context2 = new WikiContext( testEngine, page2 );
 
         // generate counts:
-        testEngine.getRenderingManager().getHTML( context1, page1 );
-        testEngine.getRenderingManager().getHTML( context2, page2 );
-        testEngine.getRenderingManager().getHTML( context2, page2 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context1, page1 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context2, page2 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context2, page2 );
 
         // mind the double \n in the following string:
         final String pageViewPageContent = "[{PageViewPlugin show='list' sort=count '\n\n* {1} ({2} views)\n}]";
@@ -143,7 +144,7 @@ public class PageViewPluginTest
         final Page pageviews = testEngine.getManager( PageManager.class ).getPage( "PageViews" );
         final WikiContext contextPV = new WikiContext( testEngine, pageviews );
 
-        final String result = testEngine.getRenderingManager().getHTML( contextPV, pageviews );
+        final String result = testEngine.getManager( RenderingManager.class ).getHTML( contextPV, pageviews );
 //        System.out.println( result );
 
         final int start1 = result.indexOf( "Test Page 01" );
@@ -170,11 +171,11 @@ public class PageViewPluginTest
         final WikiContext context4 = new WikiContext( testEngine, page4 );
 
         // generate counts:
-        testEngine.getRenderingManager().getHTML( context1, page1 );
-        testEngine.getRenderingManager().getHTML( context2, page2 );
-        testEngine.getRenderingManager().getHTML( context2, page2 );
-        testEngine.getRenderingManager().getHTML( context3, page3 );
-        testEngine.getRenderingManager().getHTML( context4, page4 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context1, page1 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context2, page2 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context2, page2 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context3, page3 );
+        testEngine.getManager( RenderingManager.class ).getHTML( context4, page4 );
 
         // mind the double \n in the following string:
         final String pageViewPageContent = "[{PageViewPlugin show='list' entries=3'\n\n* {1} ({2} views)\n}]";
@@ -183,7 +184,7 @@ public class PageViewPluginTest
         final Page pageviews = testEngine.getManager( PageManager.class ).getPage( "PageViews" );
         final WikiContext contextPV = new WikiContext( testEngine, pageviews );
 
-        final String result = testEngine.getRenderingManager().getHTML( contextPV, pageviews );
+        final String result = testEngine.getManager( RenderingManager.class ).getHTML( contextPV, pageviews );
 //        System.out.println( result );
 
         Assertions.assertTrue( result.contains( "Test Page 03" ) );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/references/ReferenceManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/references/ReferenceManagerTest.java
index f520822..a438df5 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/references/ReferenceManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/references/ReferenceManagerTest.java
@@ -48,7 +48,7 @@ public class ReferenceManagerTest  {
         engine.saveText( "TestPage", "Reference to [Foobar]." );
         engine.saveText( "Foobar", "Reference to [Foobar2], [Foobars], [Foobar]" );
 
-        mgr = engine.getReferenceManager();
+        mgr = engine.getManager( ReferenceManager.class );
     }
 
     @AfterEach
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
index c1ebf33..86d0009 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/render/RenderingManagerTest.java
@@ -33,7 +33,7 @@ import org.junit.jupiter.api.Test;
 public class RenderingManagerTest {
 
     TestEngine       m_engine = TestEngine.build();
-    RenderingManager m_manager = m_engine.getRenderingManager();
+    RenderingManager m_manager = m_engine.getManager( RenderingManager.class );
 
     @AfterEach
     public void tearDown() throws Exception {
@@ -44,7 +44,7 @@ public class RenderingManagerTest {
     @Test
     public void testBeautifyTitle() {
         final String src = "WikiNameThingy";
-        Assertions.assertEquals("Wiki Name Thingy", m_engine.getRenderingManager().beautifyTitle( src ) );
+        Assertions.assertEquals("Wiki Name Thingy", m_engine.getManager( RenderingManager.class ).beautifyTitle( src ) );
     }
 
     /**
@@ -53,7 +53,7 @@ public class RenderingManagerTest {
     @Test
     public void testBeautifyTitleAcronym() {
         final String src = "JSPWikiPage";
-        Assertions.assertEquals("JSP Wiki Page", m_engine.getRenderingManager().beautifyTitle( src ) );
+        Assertions.assertEquals("JSP Wiki Page", m_engine.getManager( RenderingManager.class ).beautifyTitle( src ) );
     }
 
     /**
@@ -62,19 +62,19 @@ public class RenderingManagerTest {
     @Test
     public void testBeautifyTitleAcronym2() {
         final String src = "DELETEME";
-        Assertions.assertEquals("DELETEME", m_engine.getRenderingManager().beautifyTitle( src ) );
+        Assertions.assertEquals("DELETEME", m_engine.getManager( RenderingManager.class ).beautifyTitle( src ) );
     }
 
     @Test
     public void testBeautifyTitleAcronym3() {
         final String src = "JSPWikiFAQ";
-        Assertions.assertEquals("JSP Wiki FAQ", m_engine.getRenderingManager().beautifyTitle( src ) );
+        Assertions.assertEquals("JSP Wiki FAQ", m_engine.getManager( RenderingManager.class ).beautifyTitle( src ) );
     }
 
     @Test
     public void testBeautifyTitleNumbers() {
         final String src = "TestPage12";
-        Assertions.assertEquals("Test Page 12", m_engine.getRenderingManager().beautifyTitle( src ) );
+        Assertions.assertEquals("Test Page 12", m_engine.getManager( RenderingManager.class ).beautifyTitle( src ) );
     }
 
     /**
@@ -83,7 +83,7 @@ public class RenderingManagerTest {
     @Test
     public void testBeautifyTitleArticle() {
         final String src = "ThisIsAPage";
-        Assertions.assertEquals("This Is A Page", m_engine.getRenderingManager().beautifyTitle( src ) );
+        Assertions.assertEquals("This Is A Page", m_engine.getManager( RenderingManager.class ).beautifyTitle( src ) );
     }
 
     @Test
@@ -92,7 +92,7 @@ public class RenderingManagerTest {
         final String name = "Test1";
         m_engine.saveText( name, text );
 
-        final String data = m_engine.getRenderingManager().getHTML( name );
+        final String data = m_engine.getManager( RenderingManager.class ).getHTML( name );
         Assertions.assertEquals( "<i>Foobar.</i>\n", data );
     }
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/rss/RSSGeneratorTest.java b/jspwiki-main/src/test/java/org/apache/wiki/rss/RSSGeneratorTest.java
index ae6b754..763ba95 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/rss/RSSGeneratorTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/rss/RSSGeneratorTest.java
@@ -75,7 +75,7 @@ public class RSSGeneratorTest {
         newPage = plugin.getNewEntryPage( m_testEngine, "TestBlog" );
         m_testEngine.saveText( newPage, "!Title2\r\n__Bar__" );
 
-        final RSSGenerator gen = m_testEngine.getRSSGenerator();
+        final RSSGenerator gen = m_testEngine.getManager( RSSGenerator.class );
 
         final WikiContext context = new WikiContext( m_testEngine, m_testEngine.getManager( PageManager.class ).getPage("TestBlog") );
 
@@ -89,8 +89,8 @@ public class RSSGeneratorTest {
         final Feed feed = new RSS10Feed( context );
         final String blog = gen.generateBlogRSS( context, entries, feed );
 
-        Assertions.assertTrue( blog.indexOf("<description>Foo</description>") != -1, "has Foo" );
-        Assertions.assertTrue( blog.indexOf("&lt;b&gt;Bar&lt;/b&gt;") != -1, "has proper Bar" );
+        Assertions.assertTrue( blog.contains( "<description>Foo</description>" ), "has Foo" );
+        Assertions.assertTrue( blog.contains( "&lt;b&gt;Bar&lt;/b&gt;" ), "has proper Bar" );
     }
 
     @Test
@@ -106,7 +106,7 @@ public class RSSGeneratorTest {
         newPage = plugin.getNewEntryPage( m_testEngine, "TestBlog" );
         m_testEngine.saveText( newPage, "!Title2\r\n__Bar__" );
 
-        final RSSGenerator gen = m_testEngine.getRSSGenerator();
+        final RSSGenerator gen = m_testEngine.getManager( RSSGenerator.class );
 
         final WikiContext context = new WikiContext( m_testEngine, m_testEngine.getManager( PageManager.class ).getPage("TestBlog") );
 
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
index 1f7374e..527cd85 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/search/SearchManagerTest.java
@@ -55,7 +55,7 @@ public class SearchManagerTest {
 
         CacheManager.getInstance().removeAllCaches();
         m_engine = new TestEngine( props );
-        m_mgr = m_engine.getSearchManager();
+        m_mgr = m_engine.getManager( SearchManager.class );
     }
 
     @AfterEach
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java b/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java
index 4ed3d08..5d842b3 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/stress/MassiveRepositoryTest.java
@@ -24,6 +24,7 @@ import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.api.providers.WikiProvider;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.providers.FileSystemProvider;
+import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.util.TextUtil;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Assertions;
@@ -163,7 +164,7 @@ public class MassiveRepositoryTest {
         {
             final String page = getName( random.nextInt( numPages ) );
             
-            final String content = engine.getRenderingManager().getHTML( page, WikiProvider.LATEST_VERSION );
+            final String content = engine.getManager( RenderingManager.class ).getHTML( page, WikiProvider.LATEST_VERSION );
               
             Assertions.assertNotNull(content);
             
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java b/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java
index acafb5e..ee45442 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/ui/CommandResolverTest.java
@@ -48,7 +48,7 @@ public class CommandResolverTest {
         final Properties props = TestEngine.getTestProperties();
         props.setProperty( WikiEngine.PROP_MATCHPLURALS, "yes" );
         m_engine = new TestEngine( props );
-        resolver = m_engine.getCommandResolver();
+        resolver = m_engine.getManager( CommandResolver.class );
         m_engine.saveText( "SinglePage", "This is a test." );
         m_engine.saveText( "PluralPages", "This is a test." );
     }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
index 5bbdd5d..d5772d5 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/ApprovalWorkflowTest.java
@@ -53,7 +53,7 @@ public class ApprovalWorkflowTest {
 
         // Start the wiki engine
         m_engine = new TestEngine( props );
-        m_wm = m_engine.getWorkflowManager();
+        m_wm = m_engine.getManager( WorkflowManager.class );
         m_dq = m_wm.getDecisionQueue();
         m_builder = WorkflowBuilder.getBuilder( m_engine );
     }
@@ -75,7 +75,7 @@ public class ApprovalWorkflowTest {
         final Workflow w = m_builder.buildApprovalWorkflow(submitter, workflowApproverKey,
                                                    prepTask, decisionKey, facts,
                                                    completionTask, rejectedMessageKey);
-        w.setWorkflowManager( m_engine.getWorkflowManager() );
+        w.setWorkflowManager( m_engine.getManager( WorkflowManager.class ) );
 
         // Check to see if the workflow built correctly
         Assertions.assertFalse( w.isStarted() || w.isCompleted() || w.isAborted() );
@@ -83,7 +83,7 @@ public class ApprovalWorkflowTest {
         Assertions.assertEquals( "workflow.approvalWorkflow", w.getMessageKey() );
         Assertions.assertEquals( Workflow.CREATED, w.getCurrentState() );
         Assertions.assertEquals( new WikiPrincipal("Submitter"), w.getOwner() );
-        Assertions.assertEquals( m_engine.getWorkflowManager(), w.getWorkflowManager() );
+        Assertions.assertEquals( m_engine.getManager( WorkflowManager.class ), w.getWorkflowManager() );
         Assertions.assertEquals( 0, w.getHistory().size() );
 
         // Our dummy "task complete" attributes should still be null
@@ -149,7 +149,7 @@ public class ApprovalWorkflowTest {
         final Workflow w = m_builder.buildApprovalWorkflow(submitter, workflowApproverKey,
                                                    prepTask, decisionKey, facts,
                                                    completionTask, rejectedMessageKey);
-        w.setWorkflowManager( m_engine.getWorkflowManager() );
+        w.setWorkflowManager( m_engine.getManager( WorkflowManager.class ) );
 
         // Start the workflow
         w.start();
@@ -242,7 +242,7 @@ public class ApprovalWorkflowTest {
     @Test
     public void testSaveWikiPageWithException() {
         // Add a PageFilter that rejects all save attempts
-        final FilterManager fm = m_engine.getFilterManager();
+        final FilterManager fm = m_engine.getManager( FilterManager.class );
         fm.addPageFilter( new AbortFilter(), 0 );
 
         // Create a sample test page and try to save it
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/DecisionQueueTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/DecisionQueueTest.java
index cb34b85..0f3eab4 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/DecisionQueueTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/DecisionQueueTest.java
@@ -56,11 +56,11 @@ public class DecisionQueueTest
 
         final Properties props = TestEngine.getTestProperties();
         m_engine = new TestEngine(props);
-        m_queue = m_engine.getWorkflowManager().getDecisionQueue();
+        m_queue = m_engine.getManager( WorkflowManager.class ).getDecisionQueue();
         adminSession = m_engine.adminSession();
         janneSession = m_engine.janneSession();
         w = new Workflow("workflow.key", new WikiPrincipal("Owner1"));
-        w.setWorkflowManager(m_engine.getWorkflowManager());
+        w.setWorkflowManager( m_engine.getManager( WorkflowManager.class ) );
         d1 = new SimpleDecision(w, "decision1.key", new GroupPrincipal("Admin"));
         d2 = new SimpleDecision(w, "decision2.key", new WikiPrincipal("Owner2"));
         d3 = new SimpleDecision(w, "decision3.key", janneSession.getUserPrincipal());
@@ -168,7 +168,7 @@ public class DecisionQueueTest
 
         // Create a workflow with 3 steps, with a Decision for Janne in the middle
         w = new Workflow("workflow.key", new WikiPrincipal("Owner1"));
-        w.setWorkflowManager(m_engine.getWorkflowManager());
+        w.setWorkflowManager( m_engine.getManager( WorkflowManager.class ) );
         final Step startTask = new TaskTest.NormalTask(w);
         final Step endTask = new TaskTest.NormalTask(w);
         final Decision decision = new SimpleDecision(w, "decision.Actor1Decision", janne);
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/OutcomeTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/OutcomeTest.java
index f4d6156..e9b229b 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/OutcomeTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/OutcomeTest.java
@@ -18,51 +18,44 @@
  */
 package org.apache.wiki.workflow;
 
-import java.util.Locale;
-import java.util.Properties;
-
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
-public class OutcomeTest
-{
+import java.util.Locale;
+
+public class OutcomeTest {
 
     @Test
-    public void testGetKey()
-    {
-        Assertions.assertEquals("outcome.decision.approve", Outcome.DECISION_APPROVE.getMessageKey());
-        Assertions.assertEquals("outcome.decision.hold", Outcome.DECISION_HOLD.getMessageKey());
-        Assertions.assertEquals("outcome.decision.deny", Outcome.DECISION_DENY.getMessageKey());
-        Assertions.assertEquals("outcome.decision.reassign", Outcome.DECISION_REASSIGN.getMessageKey());
+    public void testGetKey() {
+        Assertions.assertEquals( "outcome.decision.approve", Outcome.DECISION_APPROVE.getMessageKey() );
+        Assertions.assertEquals( "outcome.decision.hold", Outcome.DECISION_HOLD.getMessageKey() );
+        Assertions.assertEquals( "outcome.decision.deny", Outcome.DECISION_DENY.getMessageKey() );
+        Assertions.assertEquals( "outcome.decision.reassign", Outcome.DECISION_REASSIGN.getMessageKey() );
     }
 
     @Test
-    public void testHashCode()
-    {
-        Assertions.assertEquals("outcome.decision.approve".hashCode(), Outcome.DECISION_APPROVE.hashCode());
-        Assertions.assertEquals("outcome.decision.hold".hashCode()*2, Outcome.DECISION_HOLD.hashCode());
-        Assertions.assertEquals("outcome.decision.deny".hashCode(), Outcome.DECISION_DENY.hashCode());
-        Assertions.assertEquals("outcome.decision.reassign".hashCode()*2, Outcome.DECISION_REASSIGN.hashCode());
+    public void testHashCode() {
+        Assertions.assertEquals( "outcome.decision.approve".hashCode(), Outcome.DECISION_APPROVE.hashCode() );
+        Assertions.assertEquals( "outcome.decision.hold".hashCode() * 2, Outcome.DECISION_HOLD.hashCode() );
+        Assertions.assertEquals( "outcome.decision.deny".hashCode(), Outcome.DECISION_DENY.hashCode() );
+        Assertions.assertEquals( "outcome.decision.reassign".hashCode() * 2, Outcome.DECISION_REASSIGN.hashCode() );
     }
 
     @Test
-    public void testEquals()
-    {
-        Assertions.assertEquals(Outcome.DECISION_APPROVE, Outcome.DECISION_APPROVE);
-        Assertions.assertNotSame(Outcome.DECISION_APPROVE, Outcome.DECISION_REASSIGN);
+    public void testEquals() {
+        Assertions.assertEquals( Outcome.DECISION_APPROVE, Outcome.DECISION_APPROVE );
+        Assertions.assertNotSame( Outcome.DECISION_APPROVE, Outcome.DECISION_REASSIGN );
     }
 
     @Test
-    public void testMessage() throws Exception
-    {
-        Properties props = TestEngine.getTestProperties();
-        WikiEngine engine = new TestEngine(props);
-        InternationalizationManager i18n = engine.getInternationalizationManager();
-        String core = "templates.default";
-        Locale rootLocale = Locale.ROOT;
+    public void testMessage() {
+        final WikiEngine engine = TestEngine.build();
+        final InternationalizationManager i18n = engine.getManager( InternationalizationManager.class );
+        final String core = "templates.default";
+        final Locale rootLocale = Locale.ROOT;
         Outcome o;
 
         o = Outcome.DECISION_APPROVE;
@@ -79,8 +72,7 @@ public class OutcomeTest
     }
 
     @Test
-    public void testIsCompletion()
-    {
+    public void testIsCompletion() {
         Assertions.assertTrue(Outcome.DECISION_ACKNOWLEDGE.isCompletion());
         Assertions.assertTrue(Outcome.DECISION_APPROVE.isCompletion());
         Assertions.assertTrue(Outcome.DECISION_DENY.isCompletion());
@@ -92,36 +84,29 @@ public class OutcomeTest
     }
 
     @Test
-    public void testForName()
-    {
-        try
-        {
-            Assertions.assertEquals(Outcome.DECISION_ACKNOWLEDGE, Outcome.forName("outcome.decision.acknowledge"));
-            Assertions.assertEquals(Outcome.DECISION_APPROVE, Outcome.forName("outcome.decision.approve"));
-            Assertions.assertEquals(Outcome.DECISION_DENY, Outcome.forName("outcome.decision.deny"));
-            Assertions.assertEquals(Outcome.DECISION_HOLD, Outcome.forName("outcome.decision.hold"));
-            Assertions.assertEquals(Outcome.DECISION_REASSIGN, Outcome.forName("outcome.decision.reassign"));
-            Assertions.assertEquals(Outcome.STEP_ABORT, Outcome.forName("outcome.step.abort"));
-            Assertions.assertEquals(Outcome.STEP_COMPLETE, Outcome.forName("outcome.step.complete"));
-            Assertions.assertEquals(Outcome.STEP_CONTINUE, Outcome.forName("outcome.step.continue"));
-        }
-        catch (NoSuchOutcomeException e)
-        {
+    public void testForName() {
+        try {
+            Assertions.assertEquals( Outcome.DECISION_ACKNOWLEDGE, Outcome.forName( "outcome.decision.acknowledge" ) );
+            Assertions.assertEquals( Outcome.DECISION_APPROVE, Outcome.forName( "outcome.decision.approve" ) );
+            Assertions.assertEquals( Outcome.DECISION_DENY, Outcome.forName( "outcome.decision.deny" ) );
+            Assertions.assertEquals( Outcome.DECISION_HOLD, Outcome.forName( "outcome.decision.hold" ) );
+            Assertions.assertEquals( Outcome.DECISION_REASSIGN, Outcome.forName( "outcome.decision.reassign" ) );
+            Assertions.assertEquals( Outcome.STEP_ABORT, Outcome.forName( "outcome.step.abort" ) );
+            Assertions.assertEquals( Outcome.STEP_COMPLETE, Outcome.forName( "outcome.step.complete" ) );
+            Assertions.assertEquals( Outcome.STEP_CONTINUE, Outcome.forName( "outcome.step.continue" ) );
+        } catch( final NoSuchOutcomeException e ) {
             // We should never get here
-            Assertions.fail("Could not look up an Outcome...");
+            Assertions.fail( "Could not look up an Outcome..." );
         }
 
         // Look for a non-existent one
-        try
-        {
-            Outcome.forName("outcome.decision.nonexistent");
-        }
-        catch (NoSuchOutcomeException e)
-        {
+        try {
+            Outcome.forName( "outcome.decision.nonexistent" );
+        } catch( final NoSuchOutcomeException e ) {
             return;
         }
         // We should never get here
-        Assertions.fail("Could not look up an Outcome...");
+        Assertions.fail( "Could not look up an Outcome..." );
     }
 
 }
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowManagerTest.java
index fa90b73..f6b8a19 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/workflow/WorkflowManagerTest.java
@@ -18,8 +18,6 @@
  */
 package org.apache.wiki.workflow;
 
-import java.util.Properties;
-
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.exceptions.WikiException;
@@ -29,6 +27,8 @@ import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
+import java.util.Properties;
+
 public class WorkflowManagerTest
 {
     protected Workflow w;
@@ -38,15 +38,15 @@ public class WorkflowManagerTest
     @BeforeEach
     public void setUp() throws Exception
     {
-        Properties props = TestEngine.getTestProperties();
+        final Properties props = TestEngine.getTestProperties();
         m_engine = new TestEngine(props);
-        wm = m_engine.getWorkflowManager();
+        wm = m_engine.getManager( WorkflowManager.class );
         // Create a workflow with 3 steps, with a Decision in the middle
         w = new Workflow("workflow.key", new WikiPrincipal("Owner1"));
-        w.setWorkflowManager(m_engine.getWorkflowManager());
-        Step startTask = new TaskTest.NormalTask(w);
-        Step endTask = new TaskTest.NormalTask(w);
-        Decision decision = new SimpleDecision(w, "decision.editWikiApproval", new WikiPrincipal("Actor1"));
+        w.setWorkflowManager( m_engine.getManager( WorkflowManager.class ) );
+        final Step startTask = new TaskTest.NormalTask(w);
+        final Step endTask = new TaskTest.NormalTask(w);
+        final Decision decision = new SimpleDecision(w, "decision.editWikiApproval", new WikiPrincipal("Actor1"));
         startTask.addSuccessor(Outcome.STEP_COMPLETE, decision);
         decision.addSuccessor(Outcome.DECISION_APPROVE, endTask);
         w.setFirstStep(startTask);
@@ -78,12 +78,12 @@ public class WorkflowManagerTest
         wm.start(w);
         Assertions.assertEquals(1, wm.getWorkflows().size());
         Assertions.assertEquals(0, wm.getCompletedWorkflows().size());
-        Workflow workflow = (Workflow)wm.getWorkflows().iterator().next();
+        final Workflow workflow = (Workflow)wm.getWorkflows().iterator().next();
         Assertions.assertEquals(w, workflow);
         Assertions.assertEquals(1, workflow.getId());
 
         // After forcing a decision on step 2, the workflow should complete and vanish from the cache
-        Decision d = (Decision)w.getCurrentStep();
+        final Decision d = (Decision)w.getCurrentStep();
         d.decide(Outcome.DECISION_APPROVE);
         Assertions.assertEquals(0, wm.getWorkflows().size());
         Assertions.assertEquals(1, wm.getCompletedWorkflows().size());
@@ -110,7 +110,7 @@ public class WorkflowManagerTest
         {
             Assertions.assertEquals(new GroupPrincipal("Admin"), wm.getApprover("workflow.saveWikiPage"));
         }
-        catch (WikiException e)
+        catch ( final WikiException e)
         {
             // Swallow
             return;
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/xmlrpc/RPCHandlerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/xmlrpc/RPCHandlerTest.java
index 9491231..94a0250 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/xmlrpc/RPCHandlerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/xmlrpc/RPCHandlerTest.java
@@ -25,6 +25,7 @@ import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Page;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.pages.PageManager;
 import org.apache.xmlrpc.XmlRpcException;
 import org.junit.jupiter.api.AfterEach;
@@ -105,7 +106,7 @@ public class RPCHandlerTest
         m_engine.saveText( NAME1, "Foo" );
         final Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
         att.setAuthor( "FirstPost" );
-        m_engine.getAttachmentManager().storeAttachment( att, m_engine.makeAttachmentFile() );
+        m_engine.getManager( AttachmentManager.class ).storeAttachment( att, m_engine.makeAttachmentFile() );
         final Page directInfo = m_engine.getManager( PageManager.class ).getPage( NAME1 );
         time = getCalendarTime( directInfo.getLastModified() );
         final Vector recentChanges = m_handler.getRecentChanges( time );
@@ -176,7 +177,7 @@ public class RPCHandlerTest
 
         final Attachment att = new Attachment( m_engine, NAME1, "TestAtt.txt" );
         att.setAuthor( "FirstPost" );
-        m_engine.getAttachmentManager().storeAttachment( att, m_engine.makeAttachmentFile() );
+        m_engine.getManager( AttachmentManager.class ).storeAttachment( att, m_engine.makeAttachmentFile() );
 
         // Test.
 
diff --git a/jspwiki-markdown/src/test/java/org/apache/wiki/render/markdown/MarkdownRendererTest.java b/jspwiki-markdown/src/test/java/org/apache/wiki/render/markdown/MarkdownRendererTest.java
index 38d9f57..f400a82 100644
--- a/jspwiki-markdown/src/test/java/org/apache/wiki/render/markdown/MarkdownRendererTest.java
+++ b/jspwiki-markdown/src/test/java/org/apache/wiki/render/markdown/MarkdownRendererTest.java
@@ -25,6 +25,7 @@ import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.WikiException;
 import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.pages.PageManager;
 import org.apache.wiki.parser.markdown.MarkdownParser;
 import org.junit.jupiter.api.AfterEach;
@@ -195,7 +196,7 @@ public class MarkdownRendererTest {
 
         final Attachment att = new Attachment( testEngine, "Test", "TestAtt.txt" );
         att.setAuthor( "FirstPost" );
-        testEngine.getAttachmentManager().storeAttachment( att, testEngine.makeAttachmentFile() );
+        testEngine.getManager( AttachmentManager.class ).storeAttachment( att, testEngine.makeAttachmentFile() );
 
         Assertions.assertEquals( "<p>This should be an <a href=\"/test/attach/Test/TestAtt.txt\" class=\"attachment\">attachment link</a>" +
                                  "<a href=\"/test/PageInfo.jsp?page=Test/TestAtt.txt\" class=\"infolink\">" +
diff --git a/jspwiki-tika-searchprovider/src/test/java/org/apache/wiki/search/tika/TikaSearchProviderTest.java b/jspwiki-tika-searchprovider/src/test/java/org/apache/wiki/search/tika/TikaSearchProviderTest.java
index 8baa8df..464bd1c 100644
--- a/jspwiki-tika-searchprovider/src/test/java/org/apache/wiki/search/tika/TikaSearchProviderTest.java
+++ b/jspwiki-tika-searchprovider/src/test/java/org/apache/wiki/search/tika/TikaSearchProviderTest.java
@@ -20,6 +20,7 @@ import net.sf.ehcache.CacheManager;
 import org.apache.wiki.TestEngine;
 import org.apache.wiki.api.core.Attachment;
 import org.apache.wiki.attachment.AttachmentManager;
+import org.apache.wiki.search.SearchManager;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
@@ -53,7 +54,7 @@ public class TikaSearchProviderTest {
         engine.addAttachment( "Test-tika", "aaa-diagram.pdf", filePdf );
         engine.addAttachment( "Test-tika", "favicon.png", filePng );
 
-        final TikaSearchProvider tsp = ( TikaSearchProvider )engine.getSearchManager().getSearchEngine();
+        final TikaSearchProvider tsp = ( TikaSearchProvider )engine.getManager( SearchManager.class ).getSearchEngine();
 
         final Attachment attPdf = engine.getManager( AttachmentManager.class ).getAttachmentInfo( "Test-tika/aaa-diagram.pdf" );
         final String pdfIndexed = tsp.getAttachmentContent( attPdf );


[jspwiki] 11/36: change comment in jspwiki.properties so it aligns with property's default value

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 2bae34f1f67b8558bef4c57fb2f584c2a113060d
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 20 19:35:56 2020 +0100

    change comment in jspwiki.properties so it aligns with property's default value
---
 jspwiki-main/src/main/resources/ini/jspwiki.properties | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jspwiki-main/src/main/resources/ini/jspwiki.properties b/jspwiki-main/src/main/resources/ini/jspwiki.properties
index 60f9f88..9b7831f 100644
--- a/jspwiki-main/src/main/resources/ini/jspwiki.properties
+++ b/jspwiki-main/src/main/resources/ini/jspwiki.properties
@@ -74,7 +74,7 @@ jspwiki.pageProvider = FileSystemProvider
 #  Set to true, if you want to cache page data into memory.  This is
 #  in general a good idea.
 #
-#  Default is false (no cache).
+#  Default is true (use cache).
 #
 #  NB: This replaces the JSPWiki 1.x "CachingProvider" setting, since it
 #      probably was too confusing.


[jspwiki] 13/36: complete javadocs

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

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

commit 1f95c378a28498e2e1e713ebde76ff994d2a100a
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 20 19:55:16 2020 +0100

    complete javadocs
---
 .../src/main/java/org/apache/wiki/WikiProvider.java        | 14 ++++++++++++--
 .../main/java/org/apache/wiki/api/plugin/WikiPlugin.java   |  3 ++-
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/jspwiki-210-adapters/src/main/java/org/apache/wiki/WikiProvider.java b/jspwiki-210-adapters/src/main/java/org/apache/wiki/WikiProvider.java
index 355b7d3..63b5876 100644
--- a/jspwiki-210-adapters/src/main/java/org/apache/wiki/WikiProvider.java
+++ b/jspwiki-210-adapters/src/main/java/org/apache/wiki/WikiProvider.java
@@ -26,10 +26,12 @@ import java.util.Properties;
 
 
 /**
- *  A generic Wiki provider for all sorts of things that the Wiki can store.
+ * Hooks all WikiProviders not using the public API into it.
  *
- *  @since 2.0
+ * @deprecated - implement directly {@link org.apache.wiki.api.providers.WikiProvider}.
+ * @see org.apache.wiki.api.providers.WikiProvider
  */
+@Deprecated
 public interface WikiProvider extends org.apache.wiki.api.providers.WikiProvider {
 
     /**
@@ -45,6 +47,14 @@ public interface WikiProvider extends org.apache.wiki.api.providers.WikiProvider
         initialize( engine.adapt( WikiEngine.class ), properties );
     }
 
+    /**
+     *  Initializes the page 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
+     */
     default void initialize( final WikiEngine engine, final Properties properties ) throws NoRequiredPropertyException, IOException {}
 
 }
diff --git a/jspwiki-210-adapters/src/main/java/org/apache/wiki/api/plugin/WikiPlugin.java b/jspwiki-210-adapters/src/main/java/org/apache/wiki/api/plugin/WikiPlugin.java
index 14a7b53..453a8ca 100644
--- a/jspwiki-210-adapters/src/main/java/org/apache/wiki/api/plugin/WikiPlugin.java
+++ b/jspwiki-210-adapters/src/main/java/org/apache/wiki/api/plugin/WikiPlugin.java
@@ -27,7 +27,8 @@ import java.util.Map;
 
 
 /**
- *  Defines an interface for plugins.  Any instance of a wiki plugin should implement this interface.
+ * Defines an interface for plugins.  Any instance of a wiki plugin should implement this interface.
+ *
  * @deprecated use {@link Plugin} instead
  * @see Plugin
  */


[jspwiki] 27/36: use Context instead of WikiContext

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

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

commit 084c501eccc7493f583288947149d30202098ab0
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 14:32:37 2020 +0100

    use Context instead of WikiContext
---
 .../src/main/java/org/apache/wiki/ui/DefaultEditorManager.java      | 5 +++--
 jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java    | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultEditorManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultEditorManager.java
index e91e76a..8a3a11c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultEditorManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/DefaultEditorManager.java
@@ -20,6 +20,7 @@ package org.apache.wiki.ui;
 
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.exceptions.NoSuchVariableException;
 import org.apache.wiki.modules.BaseModuleManager;
@@ -93,7 +94,7 @@ public class DefaultEditorManager extends BaseModuleManager implements EditorMan
 
     /** {@inheritDoc} */
     @Override
-    public String getEditorName( final WikiContext context ) {
+    public String getEditorName( final Context context ) {
         if( context.getRequestContext().equals( WikiContext.PREVIEW ) ) {
             return EDITOR_PREVIEW;
         }
@@ -133,7 +134,7 @@ public class DefaultEditorManager extends BaseModuleManager implements EditorMan
 
     /** {@inheritDoc} */
     @Override
-    public String getEditorPath( final WikiContext context ) {
+    public String getEditorPath( final Context context ) {
         final String editor = getEditorName( context );
         final WikiEditorInfo ed = m_editors.get( editor );
         final String path;
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 b39f357..ed34db8 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,7 +18,7 @@
  */
 package org.apache.wiki.ui;
 
-import org.apache.wiki.WikiContext;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.modules.ModuleManager;
 
 import javax.servlet.jsp.PageContext;
@@ -83,7 +83,7 @@ public interface 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.
      */
-    String getEditorName( WikiContext context );
+    String getEditorName( Context context );
 
     /**
      *  Returns a list of editors as Strings of editor names.
@@ -98,7 +98,7 @@ public interface EditorManager extends ModuleManager {
      *  @param context WikiContext from where the editor name is retrieved.
      *  @return e.g. "editors/plain.jsp"
      */
-    String getEditorPath( WikiContext context );
+    String getEditorPath( Context context );
 
     /**
      *  Convenience function which examines the current context and attempts to figure out whether the edited text is in the HTTP


[jspwiki] 03/36: WikiPageProvider should extend o.a.w.WikiProvider, not o.a.w.api.providers.WikiProvider

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 8742454a59e6556fe7c550a28dec17d9c8dbbef6
Author: juanpablo <ju...@apache.org>
AuthorDate: Tue Mar 17 22:40:26 2020 +0100

    WikiPageProvider should extend o.a.w.WikiProvider, not o.a.w.api.providers.WikiProvider
---
 .../src/main/java/org/apache/wiki/providers/WikiPageProvider.java       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiPageProvider.java b/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiPageProvider.java
index 1a25535..49bba07 100644
--- a/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiPageProvider.java
+++ b/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiPageProvider.java
@@ -19,8 +19,8 @@
 package org.apache.wiki.providers;
 
 import org.apache.wiki.WikiPage;
+import org.apache.wiki.WikiProvider;
 import org.apache.wiki.api.exceptions.ProviderException;
-import org.apache.wiki.api.providers.WikiProvider;
 import org.apache.wiki.search.QueryItem;
 import org.apache.wiki.search.SearchResult;
 


[jspwiki] 26/36: add missing Apache License

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 4d443575667e4fea92d5e5fd3d73ba4c7e6ae89f
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 14:32:12 2020 +0100

    add missing Apache License
---
 .../src/main/java/org/apache/wiki/ui/AllCommands.java  | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/AllCommands.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/AllCommands.java
index 19dbdc8..2b20ae9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/AllCommands.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/AllCommands.java
@@ -1,3 +1,21 @@
+/*
+    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.wiki.api.core.Command;


[jspwiki] 02/36: catch rare NPE + provide some tests

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

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

commit bdab6f2ce4ad1cf5d601563c1982f6ec69cb5b12
Author: juanpablo <ju...@apache.org>
AuthorDate: Tue Mar 17 22:00:36 2020 +0100

    catch rare NPE + provide some tests
---
 .../src/main/java/org/apache/wiki/util/HttpUtil.java  | 13 ++++++-------
 .../test/java/org/apache/wiki/util/HttpUtilTest.java  | 19 +++++++++++++++++++
 2 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/jspwiki-util/src/main/java/org/apache/wiki/util/HttpUtil.java b/jspwiki-util/src/main/java/org/apache/wiki/util/HttpUtil.java
index 7ad7399..46ee931 100644
--- a/jspwiki-util/src/main/java/org/apache/wiki/util/HttpUtil.java
+++ b/jspwiki-util/src/main/java/org/apache/wiki/util/HttpUtil.java
@@ -70,12 +70,11 @@ public final class HttpUtil {
      */
     public static String retrieveCookieValue( final HttpServletRequest request, final String cookieName ) {
         final Cookie[] cookies = request.getCookies();
-
         if( cookies != null ) {
             for( final Cookie cookie : cookies ) {
                 if( cookie.getName().equals( cookieName ) ) {
                     String value = cookie.getValue();
-                    if( value.length() == 0 ) {
+                    if( value == null || value.length() == 0 ) {
                         return null;
                     }
                     if( value.charAt( 0 ) == '"' && value.charAt( value.length() - 1 ) == '"' ) {
@@ -180,7 +179,7 @@ public final class HttpUtil {
     }
 
 	static boolean notBeginningWithHttpOrHttps( final String uri ) {
-		return uri.length() > 0 && !( ( uri.startsWith("http://" ) || uri.startsWith( "https://" ) ) );
+		return uri.length() > 0 && !( uri.startsWith("http://" ) || uri.startsWith( "https://" ) );
 	}
 
     /**
@@ -203,12 +202,12 @@ public final class HttpUtil {
             // Ensure that the 'page=xyz' attribute is removed
             // FIXME: Is it really the mandate of this routine to do that?
             //
-            final int pos1 = res.indexOf("page=");
+            final int pos1 = res.indexOf( "page=" );
             if( pos1 >= 0 ) {
                 String tmpRes = res.substring( 0, pos1 );
-                final int pos2 = res.indexOf( "&",pos1 ) + 1;
-                if ( ( pos2 > 0 ) && ( pos2 < res.length() ) ) {
-                    tmpRes = tmpRes + res.substring(pos2);
+                final int pos2 = res.indexOf( '&', pos1 ) + 1;
+                if( ( pos2 > 0 ) && ( pos2 < res.length() ) ) {
+                    tmpRes = tmpRes + res.substring( pos2 );
                 }
                 res = tmpRes;
             }
diff --git a/jspwiki-util/src/test/java/org/apache/wiki/util/HttpUtilTest.java b/jspwiki-util/src/test/java/org/apache/wiki/util/HttpUtilTest.java
index 28d02d4..1afc63e 100644
--- a/jspwiki-util/src/test/java/org/apache/wiki/util/HttpUtilTest.java
+++ b/jspwiki-util/src/test/java/org/apache/wiki/util/HttpUtilTest.java
@@ -18,9 +18,12 @@
  */
 package org.apache.wiki.util;
 
+import net.sourceforge.stripes.mock.MockHttpServletRequest;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
+import javax.servlet.http.Cookie;
+
 
 public class HttpUtilTest {
 
@@ -47,4 +50,20 @@ public class HttpUtilTest {
         Assertions.assertTrue( HttpUtil.isIPV4Address( "123.123.123.123" ) );
     }
 
+    @Test
+    public void testRetrieveCookieValue() {
+        final Cookie[] cookies = new Cookie[] { new Cookie( "cookie1", "value1" ),
+                                                new Cookie( "cookie2", "\"value2\"" ),
+                                                new Cookie( "cookie3", "" ),
+                                                new Cookie( "cookie4", null ) };
+        final MockHttpServletRequest req = new MockHttpServletRequest( "/wiki", "/example" );
+        req.setCookies( cookies );
+
+        Assertions.assertEquals( "value1", HttpUtil.retrieveCookieValue( req, "cookie1" ) );
+        Assertions.assertEquals( "value2", HttpUtil.retrieveCookieValue( req, "cookie2" ) );
+        Assertions.assertNull( HttpUtil.retrieveCookieValue( req, "cookie3" ) );
+        Assertions.assertNull( HttpUtil.retrieveCookieValue( req, "cookie4" ) );
+        Assertions.assertNull( HttpUtil.retrieveCookieValue( req, "cookie5" ) );
+    }
+
 }


[jspwiki] 24/36: apply suggested format 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 445716e007347b4e5407c42a993a17aff3f6579d
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 14:16:07 2020 +0100

    apply suggested format by intellij
---
 .../org/apache/wiki/preferences/Preferences.java   | 126 ++++++++-------------
 1 file changed, 50 insertions(+), 76 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/preferences/Preferences.java b/jspwiki-main/src/main/java/org/apache/wiki/preferences/Preferences.java
index 868d8f5..7c3639a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/preferences/Preferences.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/preferences/Preferences.java
@@ -43,22 +43,20 @@ import java.util.Properties;
 import java.util.ResourceBundle;
 import java.util.TimeZone;
 
+
 /**
  *  Represents an object which is used to store user preferences.
- *
  */
-public class Preferences
-    extends HashMap<String,String>
-{
+public class Preferences extends HashMap< String,String > {
+
     private static final long serialVersionUID = 1L;
 
     /**
-     *  The name under which a Preferences object is stored in the HttpSession.
-     *  Its value is {@value}.
+     * The name under which a Preferences object is stored in the HttpSession. Its value is {@value}.
      */
     public static final String SESSIONPREFS = "prefs";
 
-    private static Logger log = Logger.getLogger( Preferences.class );
+    private static final Logger log = Logger.getLogger( Preferences.class );
 
     /**
      *  This is an utility method which is called to make sure that the
@@ -74,10 +72,8 @@ public class Preferences
      *
      *  @param pageContext The JSP PageContext.
      */
-    public static void setupPreferences( final PageContext pageContext )
-    {
+    public static void setupPreferences( final PageContext pageContext ) {
         //HttpSession session = pageContext.getSession();
-
         //if( session.getAttribute( SESSIONPREFS ) == null )
         //{
             reloadPreferences( pageContext );
@@ -94,8 +90,7 @@ public class Preferences
     //        happened to first arrive to the site with.  This, unfortunately, means that
     //        even if the user changes e.g. language preferences (like in a web cafe),
     //        the old preferences still remain in a site cookie.
-    public static void reloadPreferences( final PageContext pageContext )
-    {
+    public static void reloadPreferences( final PageContext pageContext ) {
         final Preferences prefs = new Preferences();
         final Properties props = PropertyReader.loadWebAppProps( pageContext.getServletContext() );
         final WikiContext ctx = WikiContext.findContext( pageContext );
@@ -122,20 +117,16 @@ public class Preferences
 
         // FIXME: editormanager reads jspwiki.editor -- which of both properties should continue
         prefs.put("editor", TextUtil.getStringProperty( props, "jspwiki.defaultprefs.template.editor", "plain" ) );
-
         parseJSONPreferences( (HttpServletRequest) pageContext.getRequest(), prefs );
-
         pageContext.getSession().setAttribute( SESSIONPREFS, prefs );
     }
 
 
     /**
-     *  Parses new-style preferences stored as JSON objects and stores them
-     *  in the session.  Everything in the cookie is stored.
-     *
-     *  @param request
-     *  @param prefs The default hashmap of preferences
+     * Parses new-style preferences stored as JSON objects and stores them in the session.  Everything in the cookie is stored.
      *
+     * @param request
+     * @param prefs The default hashmap of preferences
      */
 	private static void parseJSONPreferences( final HttpServletRequest request, final Preferences prefs ) {
         final String prefVal = TextUtil.urlDecodeUTF8( HttpUtil.retrieveCookieValue( request, "JSPWikiUserPrefs" ) );
@@ -184,17 +175,15 @@ public class Preferences
      *  @param name
      *  @return the preference value
      */
-    public static String getPreference( final PageContext pageContext, final String name )
-    {
-        final Preferences prefs = (Preferences)pageContext.getSession().getAttribute( SESSIONPREFS );
-
-        if( prefs != null )
+    public static String getPreference( final PageContext pageContext, final String name ) {
+        final Preferences prefs = ( Preferences )pageContext.getSession().getAttribute( SESSIONPREFS );
+        if( prefs != null ) {
             return prefs.get( name );
+        }
 
         return null;
     }
 
-
     /**
      * Get Locale according to user-preference settings or the user browser locale
      *
@@ -214,13 +203,14 @@ public class Preferences
             String variant  = "";
 
             final String[] res = StringUtils.split( langSetting, "-_" );
-
-            if( res.length > 2 ) variant = res[2];
-            if( res.length > 1 ) country = res[1];
-
+            if( res.length > 2 ) {
+                variant = res[ 2 ];
+            }
+            if( res.length > 1 ) {
+                country = res[ 1 ];
+            }
             if( res.length > 0 ) {
-                language = res[0];
-
+                language = res[ 0 ];
                 loc = new Locale( language, country, variant );
             }
         }
@@ -241,57 +231,48 @@ public class Preferences
             loc = ( request != null ) ? request.getLocale() : Locale.getDefault();
         }
 
-        log.debug( "using locale "+loc.toString() );
+        log.debug( "using locale " + loc.toString() );
         return loc;
     }
 
     /**
-     *  Locates the i18n ResourceBundle given.  This method interprets
-     *  the request locale, and uses that to figure out which language the
-     *  user wants.
-     *  @see org.apache.wiki.i18n.InternationalizationManager
-     *  @param context {@link WikiContext} holding the user's locale
-     *  @param bundle  The name of the bundle you are looking for.
-     *  @return A localized string (or from the default language, if not found)
-     *  @throws MissingResourceException If the bundle cannot be found
+     * Locates the i18n ResourceBundle given.  This method interprets the request locale, and uses that to figure out which language the
+     * user wants.
+     *
+     * @param context {@link WikiContext} holding the user's locale
+     * @param bundle  The name of the bundle you are looking for.
+     * @return A localized string (or from the default language, if not found)
+     * @throws MissingResourceException If the bundle cannot be found
+     * @see org.apache.wiki.i18n.InternationalizationManager
      */
-    public static ResourceBundle getBundle( final Context context, final String bundle )
-        throws MissingResourceException
-    {
+    public static ResourceBundle getBundle( final Context context, final String bundle ) throws MissingResourceException {
         final Locale loc = getLocale( context );
         final InternationalizationManager i18n = context.getEngine().getManager( InternationalizationManager.class );
         return i18n.getBundle( bundle, loc );
     }
 
     /**
-     *  Get SimpleTimeFormat according to user browser locale and preferred time
-     *  formats. If not found, it will revert to whichever format is set for the
-     *  default
+     * Get SimpleTimeFormat according to user browser locale and preferred time formats. If not found, it will revert to whichever format
+     * is set for the default.
      *
-     *  @param context WikiContext to use for rendering.
-     *  @param tf Which version of the dateformat you are looking for?
-     *  @return A SimpleTimeFormat object which you can use to render
-     *  @since 2.8
+     * @param context WikiContext to use for rendering.
+     * @param tf Which version of the dateformat you are looking for?
+     * @return A SimpleTimeFormat object which you can use to render
+     * @since 2.8
      */
-    public static SimpleDateFormat getDateFormat( final Context context, final TimeFormat tf )
-    {
+    public static SimpleDateFormat getDateFormat( final Context context, final TimeFormat tf ) {
         final InternationalizationManager imgr = context.getEngine().getManager( InternationalizationManager.class );
         final Locale clientLocale = getLocale( context );
         final String prefTimeZone = getPreference( context, "TimeZone" );
         String prefDateFormat;
 
         log.debug("Checking for preferences...");
-
-        switch( tf )
-        {
+        switch( tf ) {
             case DATETIME:
                 prefDateFormat = getPreference( context, "DateFormat" );
                 log.debug("Preferences fmt = "+prefDateFormat);
-                if( prefDateFormat == null )
-                {
-                    prefDateFormat = imgr.get( InternationalizationManager.CORE_BUNDLE,
-                                               clientLocale,
-                                               "common.datetimeformat" );
+                if( prefDateFormat == null ) {
+                    prefDateFormat = imgr.get( InternationalizationManager.CORE_BUNDLE, clientLocale,"common.datetimeformat" );
                     log.debug("Using locale-format = "+prefDateFormat);
                 }
                 break;
@@ -308,36 +289,29 @@ public class Preferences
                 throw new InternalWikiException( "Got a TimeFormat for which we have no value!" );
         }
 
-        try
-        {
+        try {
             final SimpleDateFormat fmt = new SimpleDateFormat( prefDateFormat, clientLocale );
-
-            if( prefTimeZone != null )
-            {
+            if( prefTimeZone != null ) {
                 final TimeZone tz = TimeZone.getTimeZone( prefTimeZone );
                 // TimeZone tz = TimeZone.getDefault();
                 // tz.setRawOffset(Integer.parseInt(prefTimeZone));
-
                 fmt.setTimeZone( tz );
             }
 
             return fmt;
-        }
-        catch( final Exception e )
-        {
+        } catch( final Exception e ) {
             return null;
         }
     }
 
     /**
-     *  A simple helper function to render a date based on the user preferences.
-     *  This is useful for example for all plugins.
+     * A simple helper function to render a date based on the user preferences. This is useful for example for all plugins.
      *
-     *  @param context  The context which is used to get the preferences
-     *  @param date     The date to render.
-     *  @param tf       In which format the date should be rendered.
-     *  @return A ready-rendered date.
-     *  @since 2.8
+     * @param context  The context which is used to get the preferences
+     * @param date     The date to render.
+     * @param tf       In which format the date should be rendered.
+     * @return A ready-rendered date.
+     * @since 2.8
      */
     public static String renderDate( final Context context, final Date date, final TimeFormat tf ) {
         final DateFormat df = getDateFormat( context, tf );


[jspwiki] 35/36: push default methods on GroupManager to implementation on DefaultGroupManager

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 1059775140675a4ae287d612b303f641c383b1e9
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 17:48:38 2020 +0100

    push default methods on GroupManager to implementation on DefaultGroupManager
---
 .../wiki/auth/authorize/DefaultGroupManager.java   | 34 ++++++++++++++++++++++
 .../apache/wiki/auth/authorize/GroupManager.java   | 33 ++-------------------
 2 files changed, 36 insertions(+), 31 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java
index b4f8d29..8ac7143 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/DefaultGroupManager.java
@@ -20,6 +20,7 @@ package org.apache.wiki.auth.authorize;
 
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.log4j.Logger;
+import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
@@ -321,6 +322,39 @@ public class DefaultGroupManager implements GroupManager, Authorizer, WikiEventL
         }
     }
 
+    /** {@inheritDoc} */
+    @Override
+    public void validateGroup( final Context context, final Group group ) {
+        final InputValidator validator = new InputValidator( MESSAGES_KEY, context );
+
+        // Name cannot be null or one of the restricted names
+        try {
+            checkGroupName( context, group.getName() );
+        } catch( final WikiSecurityException e ) {
+        }
+
+        // Member names must be "safe" strings
+        final Principal[] members = group.members();
+        for( final Principal member : members ) {
+            validator.validateNotNull( member.getName(), "Full name", InputValidator.ID );
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void checkGroupName( final Context context, final String name ) throws WikiSecurityException {
+        // TODO: groups cannot have the same name as a user
+
+        // Name cannot be null
+        final InputValidator validator = new InputValidator( MESSAGES_KEY, context );
+        validator.validateNotNull( name, "Group name" );
+
+        // Name cannot be one of the restricted names either
+        if( ArrayUtils.contains( Group.RESTRICTED_GROUPNAMES, name ) ) {
+            throw new WikiSecurityException( "The group name '" + name + "' is illegal. Choose another." );
+        }
+    }
+
     /**
      * Extracts carriage-return separated members into a Set of String objects.
      *
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
index f6986b3..3deea3a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupManager.java
@@ -18,7 +18,6 @@
  */
 package org.apache.wiki.auth.authorize;
 
-import org.apache.commons.lang3.ArrayUtils;
 import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.auth.Authorizer;
@@ -27,10 +26,8 @@ import org.apache.wiki.auth.WikiSecurityException;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiSecurityEvent;
-import org.apache.wiki.ui.InputValidator;
 
 import javax.servlet.http.HttpServletRequest;
-import java.security.Principal;
 
 
 /**
@@ -185,22 +182,7 @@ public interface GroupManager extends Authorizer, WikiEventListener {
      * @param context the current wiki context
      * @param group the supplied Group
      */
-    default void validateGroup( final Context context, final Group group ) {
-        final InputValidator validator = new InputValidator( MESSAGES_KEY, context );
-
-        // Name cannot be null or one of the restricted names
-        try {
-            checkGroupName( context, group.getName() );
-        } catch( final WikiSecurityException e ) {
-        }
-
-        // Member names must be "safe" strings
-        final Principal[] members = group.members();
-        for( final Principal member : members ) {
-            validator.validateNotNull( member.getName(), "Full name", InputValidator.ID );
-        }
-    }
-
+    void validateGroup( final Context context, final Group group );
 
     /**
      * Checks if a String is blank or a restricted Group name, and if it is, appends an error to the Session's message list.
@@ -210,18 +192,7 @@ public interface GroupManager extends Authorizer, WikiEventListener {
      * @throws WikiSecurityException if <code>session</code> is <code>null</code> or the Group name is illegal
      * @see Group#RESTRICTED_GROUPNAMES
      */
-    default void checkGroupName( final Context context, final String name ) throws WikiSecurityException {
-        // TODO: groups cannot have the same name as a user
-
-        // Name cannot be null
-        final InputValidator validator = new InputValidator( MESSAGES_KEY, context );
-        validator.validateNotNull( name, "Group name" );
-
-        // Name cannot be one of the restricted names either
-        if( ArrayUtils.contains( Group.RESTRICTED_GROUPNAMES, name ) ) {
-            throw new WikiSecurityException( "The group name '" + name + "' is illegal. Choose another." );
-        }
-    }
+    void checkGroupName( final Context context, final String name ) throws WikiSecurityException;
 
     // events processing .......................................................
 


[jspwiki] 14/36: add missing Apache License to tests

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

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

commit c92bb4d821fb3bbed8681806274da0e2cbccec55
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 20 19:55:48 2020 +0100

    add missing Apache License to tests
---
 .../org/apache/wiki/filters/FilterFrom210Test.java |  19 +++-
 .../org/apache/wiki/plugin/PluginFrom210Test.java  |  18 ++++
 .../apache/wiki/providers/SearchAdapterTest.java   |  18 ++++
 .../wiki/providers/WikiProviderAdaptersTest.java   | 113 +++++++++++++++++++++
 4 files changed, 167 insertions(+), 1 deletion(-)

diff --git a/jspwiki-210-adapters/src/test/java/org/apache/wiki/filters/FilterFrom210Test.java b/jspwiki-210-adapters/src/test/java/org/apache/wiki/filters/FilterFrom210Test.java
index c7c55a2..bb42575 100644
--- a/jspwiki-210-adapters/src/test/java/org/apache/wiki/filters/FilterFrom210Test.java
+++ b/jspwiki-210-adapters/src/test/java/org/apache/wiki/filters/FilterFrom210Test.java
@@ -1,3 +1,21 @@
+/*
+    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.filters;
 
 import com.example.filters.TwoXFilter;
@@ -32,7 +50,6 @@ public class FilterFrom210Test {
         final WikiContext context = new WikiContext( engine, new WikiPage( engine, "Testpage" ) );
         final String res = rm.textToHTML( context,"Incredible and super important content here" ); // test only pre / post translate
         Assertions.assertEquals( "see how I care about yor content - hmmm...", res );
-
     }
 
 }
diff --git a/jspwiki-210-adapters/src/test/java/org/apache/wiki/plugin/PluginFrom210Test.java b/jspwiki-210-adapters/src/test/java/org/apache/wiki/plugin/PluginFrom210Test.java
index bb3dd1f..134a3ad 100644
--- a/jspwiki-210-adapters/src/test/java/org/apache/wiki/plugin/PluginFrom210Test.java
+++ b/jspwiki-210-adapters/src/test/java/org/apache/wiki/plugin/PluginFrom210Test.java
@@ -1,3 +1,21 @@
+/*
+    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.plugin;
 
 import org.apache.wiki.TestEngine;
diff --git a/jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/SearchAdapterTest.java b/jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/SearchAdapterTest.java
index 40a9a35..387b21f 100644
--- a/jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/SearchAdapterTest.java
+++ b/jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/SearchAdapterTest.java
@@ -1,3 +1,21 @@
+/*
+    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.providers;
 
 import org.apache.wiki.WikiPage;
diff --git a/jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/WikiProviderAdaptersTest.java b/jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/WikiProviderAdaptersTest.java
new file mode 100644
index 0000000..e9368d1
--- /dev/null
+++ b/jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/WikiProviderAdaptersTest.java
@@ -0,0 +1,113 @@
+/*
+    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.providers;
+
+import org.apache.wiki.TestEngine;
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.providers.AttachmentProvider;
+import org.apache.wiki.api.providers.PageProvider;
+import org.apache.wiki.api.search.QueryItem;
+import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.attachment.AttachmentManager;
+import org.apache.wiki.pages.PageManager;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.io.ByteArrayInputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Date;
+
+import static org.apache.wiki.TestEngine.with;
+
+
+public class WikiProviderAdaptersTest {
+
+    TestEngine engine = TestEngine.build( with( "jspwiki.usePageCache", "false" ),
+                                          with( "jspwiki.pageProvider", "WikiPageAdapterProvider" ),
+                                          with( "jspwiki.attachmentProvider", "WikiAttachmentAdapterProvider" ),
+                                          with( "jspwiki.pageProvider.adapter.impl", "com.example.providers.TwoXWikiPageProvider" ),
+                                          with( "jspwiki.attachmentProvider.adapter.impl", "com.example.providers.TwoXWikiAttachmentProvider" ) );
+
+    @Test
+    public void testPageProvider() throws Exception {
+        final PageProvider pageProvider = engine.getManager( PageManager.class ).getProvider();
+        final QueryItem qi = new QueryItem();
+        qi.word = "blablablabla";
+        qi.type = QueryItem.REQUESTED;
+
+        Assertions.assertEquals( "com.example.providers.TwoXWikiPageProvider", pageProvider.getProviderInfo() );
+        Assertions.assertEquals( 3, pageProvider.getAllChangedSince( new Date( 0L ) ).size() );
+        Assertions.assertEquals( 3, pageProvider.getAllPages().size() );
+        Assertions.assertEquals( 3, pageProvider.getPageCount() );
+        Assertions.assertTrue( pageProvider.pageExists( "page1" ) );
+        Assertions.assertTrue( pageProvider.pageExists( "page1", 0 ) );
+
+        pageProvider.movePage( "page1", "page0" );
+        Assertions.assertTrue( pageProvider.pageExists( "page0" ) );
+        Assertions.assertFalse( pageProvider.pageExists( "page1" ) );
+
+        pageProvider.putPageText( new WikiPage( engine, "page4" ), "bloblobloblo" );
+        Assertions.assertTrue( pageProvider.pageExists( "page4" ) );
+        Assertions.assertEquals( 1, pageProvider.findPages( new QueryItem[] { qi } ).size() );
+        pageProvider.putPageText( new WikiPage( engine, "page4" ), "blublublublu" );
+        Assertions.assertEquals( 2, pageProvider.getVersionHistory( "page4" ).size() );
+        Assertions.assertEquals( "bloblobloblo", pageProvider.getPageText( "page4", 0 ) );
+        Assertions.assertEquals( "blublublublu", pageProvider.getPageText( "page4", 1 ) );
+        pageProvider.deleteVersion( "page4", 1 );
+        Assertions.assertEquals( 1, pageProvider.getVersionHistory( "page4" ).size() );
+        pageProvider.deletePage( "page4" );
+        Assertions.assertFalse( pageProvider.pageExists( "page4" ) );
+    }
+
+    @Test
+    public void testAttachmentProvider() throws Exception {
+        final AttachmentProvider attachmentProvider = engine.getManager( AttachmentManager.class ).getCurrentProvider();
+        final Attachment att11 = new Attachment( engine, "page1", "att11.txt" );
+        final Attachment att13 = new Attachment( engine, "page1", "att13.txt" );
+        final QueryItem qi = new QueryItem();
+        qi.word = "doesn't matter will be ignored";
+        qi.type = QueryItem.REQUESTED;
+
+        Assertions.assertEquals( "com.example.providers.TwoXWikiAttachmentProvider", attachmentProvider.getProviderInfo() );
+        Assertions.assertEquals( 2, attachmentProvider.listAttachments( new WikiPage( engine, "page1" ) ).size() );
+        final byte[] attDataArray = new byte[ attachmentProvider.getAttachmentData( att11 ).available() ];
+        attachmentProvider.getAttachmentData( att11 ).read( attDataArray );
+        Assertions.assertArrayEquals( "blurb".getBytes( StandardCharsets.UTF_8 ), attDataArray );
+        Assertions.assertEquals( 0, attachmentProvider.findAttachments( new QueryItem[]{ qi } ).size() );
+        Assertions.assertEquals( 3, attachmentProvider.listAllChanged( new Date( 0L ) ).size() );
+        Assertions.assertEquals( att11.getName(), attachmentProvider.getAttachmentInfo( new WikiPage( engine, "page1" ), "att11.txt", 0 ).getName() );
+        Assertions.assertEquals( 1, attachmentProvider.getVersionHistory( att11 ).size() );
+
+        attachmentProvider.putAttachmentData( att13, new ByteArrayInputStream( "blorb".getBytes( StandardCharsets.UTF_8 ) ) );
+        Assertions.assertEquals( 3, attachmentProvider.listAttachments( new WikiPage( engine, "page1" ) ).size() );
+
+        attachmentProvider.putAttachmentData( att13, new ByteArrayInputStream( "blorb".getBytes( StandardCharsets.UTF_8 ) ) );
+        Assertions.assertEquals( 2, attachmentProvider.getVersionHistory( att13 ).size() );
+        attachmentProvider.deleteVersion( attachmentProvider.getVersionHistory( att13 ).get( 1 ) );
+        Assertions.assertEquals( 1, attachmentProvider.getVersionHistory( att13 ).size() );
+        attachmentProvider.deleteAttachment( att13 );
+        Assertions.assertEquals( 0, attachmentProvider.getVersionHistory( att13 ).size() );
+
+        Assertions.assertEquals( 2, attachmentProvider.listAttachments( new WikiPage( engine, "page1" ) ).size() );
+        attachmentProvider.moveAttachmentsForPage( "page1", "page0" );
+        Assertions.assertEquals( 2, attachmentProvider.listAttachments( new WikiPage( engine, "page0" ) ).size() );
+        Assertions.assertEquals( 0, attachmentProvider.listAttachments( new WikiPage( engine, "page1" ) ).size() );
+    }
+
+}


[jspwiki] 36/36: 2.11.0-M7-git-14

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 3404df2c4222e125e9292687132e708abdd0066a
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 18:03:24 2020 +0100

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

diff --git a/ChangeLog.md b/ChangeLog.md
index 33541aa..f1d708e 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -17,6 +17,28 @@ specific language governing permissions and limitations
 under the License.
 -->
 
+**2020-03-21  Juan Pablo Santos (juanpablo AT apache DOT org)**
+
+* _2.11.0-M7-git-14_
+
+* [JSPWIKI-303](https://issues.apache.org/jira/browse/JSPWIKI-303): JSPWiki-API library creation
+    * added compatibility to page / attachment providers not using the public API
+        * `jspwiki.pageProvider` should be set to `WikiPageAdapterProvider` and then `jspwiki.pageProvider.adapter.impl` 
+        to the actual page provider
+        * `jspwiki.attachmentProvider` should be set to `WikiAttachmentAdapterProvider` and then `jspwiki.attachmentProvider.adapter.impl` 
+        to the actual attachment provider
+        * see `WikiProviderAdaptersTest` on the jspwiki-210-adapters module for an example
+    * `Page` does not deal with ACLs yet
+    * SPI to create objects from the `o.a.w.api.core` package still needs to be done
+
+* Added more helper methods to `TestEngine` to ease building customized instances (again, see `WikiProviderAdaptersTest` on the 
+jspwiki-210-adapters module for an example)
+
+* Dependency updates
+    * Tika to 1.24
+    * Tomcat to 9.0.33
+    * Selenide to 5.10.0
+
 **2020-03-16  Juan Pablo Santos (juanpablo AT apache DOT org)**
 
 * _2.11.0-M7-git-13_
diff --git a/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java b/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java
index 4862f62..61fd742 100644
--- a/jspwiki-api/src/main/java/org/apache/wiki/api/Release.java
+++ b/jspwiki-api/src/main/java/org/apache/wiki/api/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-13";
+    public static final String     BUILD         = "git-14";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of


[jspwiki] 17/36: update portable launchers to tomcat 9.0.33

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 559f94bd391d4cef3b800f8d169c899c2a4f726e
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 00:17:50 2020 +0100

    update portable launchers to tomcat 9.0.33
---
 .../tomcat/woas.app/Contents/Java/bootstrap.jar    | Bin 35071 -> 35071 bytes
 .../tomcat/woas.app/Contents/Java/tomcat-juli.jar  | Bin 47886 -> 49372 bytes
 .../src/overlay/launchers/tomcat/woas.exe          | Bin 3564962 -> 3575670 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 9ba6c4d..498c7ce 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 faea050..af0362c 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 0d0d9de..7dbe7ac 100644
Binary files a/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe and b/jspwiki-portable/src/overlay/launchers/tomcat/woas.exe differ


[jspwiki] 07/36: add back constructors to ensure page/attachment backwards compatibility

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 b48d88f979ac125d45e92ba9b7a092033d83575b
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 20 19:32:54 2020 +0100

    add back constructors to ensure page/attachment backwards compatibility
---
 jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java   | 14 ++++++++++++--
 .../main/java/org/apache/wiki/attachment/Attachment.java   | 12 ++++++++++++
 2 files changed, 24 insertions(+), 2 deletions(-)

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 1413923..36412f3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiPage.java
@@ -51,10 +51,10 @@ public class WikiPage implements Page {
     private final Map<String,Object> m_attributes = new HashMap<>();
     
     private Acl m_accessList = null;
-    
+
     /**
      *  Create a new WikiPage using a given engine and name.
-     *  
+     *
      *  @param engine The Engine that owns this page.
      *  @param name   The name of the page.
      */
@@ -65,6 +65,16 @@ public class WikiPage implements Page {
     }
 
     /**
+     *  Create a new WikiPage using a given engine and name.
+     *
+     *  @param engine The Engine that owns this page.
+     *  @param name   The name of the page.
+     */
+    public WikiPage( final WikiEngine engine, final String name ) {
+        this( ( Engine )engine, name );
+    }
+
+    /**
      *  Returns the name of the page.
      *  
      *  @return The page name.
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java b/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
index 7f9b068..3b47033 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/attachment/Attachment.java
@@ -18,6 +18,7 @@
  */
 package org.apache.wiki.attachment;
 
+import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Engine;
 
@@ -45,6 +46,17 @@ public class Attachment extends WikiPage implements org.apache.wiki.api.core.Att
     }
 
     /**
+     * Creates a new attachment.  The final name of the attachment will be a synthesis of the parent page name and the file name.
+     *
+     * @param engine     The Engine which is hosting this attachment.
+     * @param parentPage The page which will contain this attachment.
+     * @param fileName   The file name for the attachment.
+     */
+    public Attachment( final WikiEngine engine, final String parentPage, final String fileName ) {
+        this( ( Engine )engine, parentPage, fileName );
+    }
+
+    /**
      * Returns a human-readable, only-debugging-suitable description.
      *
      * @return A debugging string


[jspwiki] 10/36: use constant from AttachmentProvider

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 5a89dbaa3709b324c4d33ba0798d00e9483c8cec
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 20 19:34:36 2020 +0100

    use constant from AttachmentProvider
---
 .../java/org/apache/wiki/providers/BasicAttachmentProvider.java    | 7 ++-----
 jspwiki-main/src/main/java/org/apache/wiki/ui/Installer.java       | 4 ++--
 .../test/java/org/apache/wiki/pages/DefaultPageManagerTest.java    | 6 +++---
 .../test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java  | 3 ++-
 4 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/providers/BasicAttachmentProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/providers/BasicAttachmentProvider.java
index 20fe69e..186f8d8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/providers/BasicAttachmentProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/providers/BasicAttachmentProvider.java
@@ -83,9 +83,6 @@ public class BasicAttachmentProvider implements AttachmentProvider {
     private Engine m_engine;
     private String m_storageDir;
     
-    /** The property name for where the attachments should be stored.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_STORAGEDIR = "jspwiki.basicAttachmentProvider.storageDir";
-    
     /*
      * Disable client cache for files with patterns
      * since 2.5.96
@@ -466,7 +463,7 @@ public class BasicAttachmentProvider implements AttachmentProvider {
             att.setAuthor( props.getProperty( version+".author" ) );
             final String changeNote = props.getProperty( version+".changenote" );
             if( changeNote != null ) {
-                att.setAttribute( WikiPage.CHANGENOTE, changeNote );
+                att.setAttribute( Page.CHANGENOTE, changeNote );
             }
 
             final File f = findFile( dir, att );
@@ -569,7 +566,7 @@ public class BasicAttachmentProvider implements AttachmentProvider {
 
         // If it exists, we're overwriting an old page (this has already been confirmed at a higher level), so delete any existing attachments.
         if( destDir.exists() ) {
-            log.error( "Page rename failed because target dirctory " + destDir + " exists" );
+            log.error( "Page rename failed because target directory " + destDir + " exists" );
         } else {
             // destDir.getParentFile().mkdir();
             srcDir.renameTo( destDir );
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 f6968d2..0c8b40a 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
@@ -22,6 +22,7 @@ import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Session;
+import org.apache.wiki.api.providers.AttachmentProvider;
 import org.apache.wiki.auth.NoSuchPrincipalException;
 import org.apache.wiki.auth.UserManager;
 import org.apache.wiki.auth.WikiPrincipal;
@@ -32,7 +33,6 @@ import org.apache.wiki.auth.user.UserDatabase;
 import org.apache.wiki.auth.user.UserProfile;
 import org.apache.wiki.i18n.InternationalizationManager;
 import org.apache.wiki.pages.PageManager;
-import org.apache.wiki.providers.BasicAttachmentProvider;
 import org.apache.wiki.providers.FileSystemProvider;
 import org.apache.wiki.util.TextUtil;
 
@@ -61,7 +61,7 @@ public class Installer {
     public static final String INSTALL_ERROR = "Installer.Error";
     public static final String INSTALL_WARNING = "Installer.Warning";
     public static final String APP_NAME = Engine.PROP_APPNAME;
-    public static final String STORAGE_DIR = BasicAttachmentProvider.PROP_STORAGEDIR;
+    public static final String STORAGE_DIR = AttachmentProvider.PROP_STORAGEDIR;
     public static final String PAGE_DIR = FileSystemProvider.PROP_PAGEDIR;
     public static final String WORK_DIR = Engine.PROP_WORKDIR;
     public static final String ADMIN_GROUP = "Admin";
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
index 6b70bc4..30e5c56 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/pages/DefaultPageManagerTest.java
@@ -25,8 +25,8 @@ import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.core.Attachment;
 import org.apache.wiki.api.core.Page;
+import org.apache.wiki.api.providers.AttachmentProvider;
 import org.apache.wiki.api.providers.WikiProvider;
-import org.apache.wiki.providers.BasicAttachmentProvider;
 import org.apache.wiki.providers.CachingProvider;
 import org.apache.wiki.providers.FileSystemProvider;
 import org.apache.wiki.providers.VerySimpleProvider;
@@ -113,7 +113,7 @@ public class DefaultPageManagerTest {
         final String files = engine.getWikiProperties().getProperty( FileSystemProvider.PROP_PAGEDIR );
         final File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );
 
-        final String atts = engine.getWikiProperties().getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
+        final String atts = engine.getWikiProperties().getProperty( AttachmentProvider.PROP_STORAGEDIR );
         final File attfile = new File( atts, NAME1+"-att/TestAtt.txt-dir" );
 
         Assertions.assertTrue( saved.exists(), "Didn't create it!" );
@@ -137,7 +137,7 @@ public class DefaultPageManagerTest {
         final String files = engine.getWikiProperties().getProperty( FileSystemProvider.PROP_PAGEDIR );
         final File saved = new File( files, NAME1+FileSystemProvider.FILE_EXT );
 
-        final String atts = engine.getWikiProperties().getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
+        final String atts = engine.getWikiProperties().getProperty( AttachmentProvider.PROP_STORAGEDIR );
         final File attfile = new File( atts, NAME1+"-att/TestAtt.txt-dir" );
 
         Assertions.assertTrue( saved.exists(), "Didn't create it!" );
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java b/jspwiki-main/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
index 4becf60..e13cbf4 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/parser/JSPWikiMarkupParserTest.java
@@ -26,6 +26,7 @@ import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.api.exceptions.WikiException;
+import org.apache.wiki.api.providers.AttachmentProvider;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.providers.BasicAttachmentProvider;
@@ -2601,7 +2602,7 @@ public class JSPWikiMarkupParserTest
         }
         finally
         {
-            final String files = testEngine.getWikiProperties().getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
+            final String files = testEngine.getWikiProperties().getProperty( AttachmentProvider.PROP_STORAGEDIR );
             final File storagedir = new File( files, PAGE_NAME+BasicAttachmentProvider.DIR_EXTENSION );
 
             if( storagedir.exists() && storagedir.isDirectory() ) {


[jspwiki] 12/36: added new static methods on TestEngine to ease creation ofinstances with custom properties

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 0de5b151f82344d64dc5cf00af80d1e9ede0a966
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 20 19:37:06 2020 +0100

    added new static methods on TestEngine to ease creation ofinstances with custom properties
---
 .../src/test/java/org/apache/wiki/TestEngine.java  | 80 +++++++++++++++-------
 1 file changed, 55 insertions(+), 25 deletions(-)

diff --git a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
index 559c375..d096e06 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/TestEngine.java
@@ -28,6 +28,7 @@ import org.apache.wiki.api.core.Page;
 import org.apache.wiki.api.core.Session;
 import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.api.exceptions.WikiException;
+import org.apache.wiki.api.providers.AttachmentProvider;
 import org.apache.wiki.api.providers.PageProvider;
 import org.apache.wiki.attachment.Attachment;
 import org.apache.wiki.auth.AuthenticationManager;
@@ -49,15 +50,16 @@ import java.io.File;
 import java.io.FileWriter;
 import java.io.IOException;
 import java.io.StringReader;
+import java.util.AbstractMap;
 import java.util.Locale;
+import java.util.Map;
 import java.util.Properties;
 
 /**
  *  Simple test engine that always assumes pages are found.
  */
-public class TestEngine extends WikiEngine
-{
-    static Logger log = Logger.getLogger( TestEngine.class );
+public class TestEngine extends WikiEngine {
+    private static final Logger log = Logger.getLogger( TestEngine.class );
 
     private Session m_adminWikiSession = null;
     private Session m_janneWikiSession = null;
@@ -67,34 +69,28 @@ public class TestEngine extends WikiEngine
     private static Properties combinedProperties = null;
 
     /**
-     * Creates WikiSession with the privileges of the administrative user.
-     * For testing purposes, obviously.
+     * Creates WikiSession with the privileges of the administrative user. For testing purposes, obviously.
+     *
      * @return the wiki session
      * @throws WikiSecurityException
      */
-    public Session adminSession() throws WikiSecurityException
-    {
-        if ( m_adminWikiSession == null )
-        {
+    public Session adminSession() throws WikiSecurityException {
+        if ( m_adminWikiSession == null ) {
             // Set up long-running admin session
             final HttpServletRequest request = newHttpRequest();
             m_adminWikiSession = WikiSession.getWikiSession( this, request );
-            this.getAuthenticationManager().login( m_adminWikiSession, request,
-                                                   Users.ADMIN,
-                                                   Users.ADMIN_PASS );
+            this.getAuthenticationManager().login( m_adminWikiSession, request, Users.ADMIN, Users.ADMIN_PASS );
         }
         return m_adminWikiSession;
     }
 
     /**
-     * Creates guest WikiSession with the no privileges.
-     * For testing purposes, obviously.
+     * Creates guest WikiSession with the no privileges. For testing purposes, obviously.
+     *
      * @return the wiki session
      */
-    public Session guestSession()
-    {
-        if ( m_guestWikiSession == null )
-        {
+    public Session guestSession() {
+        if ( m_guestWikiSession == null ) {
             // Set up guest session
             final HttpServletRequest request = newHttpRequest();
             m_guestWikiSession = WikiSession.getWikiSession( this, request );
@@ -103,15 +99,13 @@ public class TestEngine extends WikiEngine
     }
 
     /**
-     * Creates WikiSession with the privileges of the Janne.
-     * For testing purposes, obviously.
+     * Creates WikiSession with the privileges of the Janne. For testing purposes, obviously.
+     *
      * @return the wiki session
      * @throws WikiSecurityException
      */
-    public Session janneSession() throws WikiSecurityException
-    {
-        if ( m_janneWikiSession == null )
-        {
+    public Session janneSession() throws WikiSecurityException {
+        if ( m_janneWikiSession == null ) {
             // Set up a test Janne session
             final HttpServletRequest request = newHttpRequest();
             m_janneWikiSession = WikiSession.getWikiSession( this, request );
@@ -120,10 +114,46 @@ public class TestEngine extends WikiEngine
         return m_janneWikiSession;
     }
 
+    /**
+     * Obtains a TestEngine using {@link #getTestProperties()}.
+     *
+     * @return TestEngine using {@link #getTestProperties()}.
+     */
     public static TestEngine build() {
         return build( getTestProperties() );
     }
 
+    /**
+     * Obtains a TestEngine using {@link #getTestProperties()} and additional configuration.
+     *
+     * @param entries additional configuration entries that may overwrite default test properties.
+     * @return TestEngine using {@link #getTestProperties()} and additional configuration.
+     */
+    public static TestEngine build( final Map.Entry< String, String >... entries ) {
+        final Properties properties = getTestProperties();
+        for( final Map.Entry< String, String > entry : entries ) {
+            properties.setProperty( entry.getKey(), entry.getValue() );
+        }
+        return build( properties );
+    }
+
+    /**
+     * Helper method, intended to be imported statically, to ease passing properties to {@link #build(Map.Entry[])}.
+     *
+     * @param prop property name.
+     * @param value property value.
+     * @return populated entry ready to be used in {@link #build(Map.Entry[])}.
+     */
+    public static Map.Entry< String, String > with( final String prop, final String value ) {
+        return new AbstractMap.SimpleEntry<>( prop, value );
+    }
+
+    /**
+     * Obtains a TestEngine using the provided properties.
+     *
+     * @param props configuration entries.
+     * @return TestEngine using the provided properties.
+     */
     public static TestEngine build( final Properties props ) {
         try {
             return new TestEngine( props );
@@ -333,7 +363,7 @@ public class TestEngine extends WikiEngine
         final Properties properties = getTestProperties();
 
         try {
-            final String files = properties.getProperty( BasicAttachmentProvider.PROP_STORAGEDIR );
+            final String files = properties.getProperty( AttachmentProvider.PROP_STORAGEDIR );
             final File f = new File( files, TextUtil.urlEncodeUTF8( page ) + BasicAttachmentProvider.DIR_EXTENSION );
 
             deleteAll( f );


[jspwiki] 05/36: added new adapter to convert classes between o.a.w.search and o.a.w.api.search

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 ced752b4a985dffaabc780459773e4ede97d2aab
Author: juanpablo <ju...@apache.org>
AuthorDate: Tue Mar 17 22:41:50 2020 +0100

    added new adapter to convert classes between o.a.w.search and o.a.w.api.search
---
 .../org/apache/wiki/providers/SearchAdapter.java   | 40 ++++++++++++++++++
 .../apache/wiki/providers/SearchAdapterTest.java   | 47 ++++++++++++++++++++++
 2 files changed, 87 insertions(+)

diff --git a/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/SearchAdapter.java b/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/SearchAdapter.java
new file mode 100644
index 0000000..8df1676
--- /dev/null
+++ b/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/SearchAdapter.java
@@ -0,0 +1,40 @@
+package org.apache.wiki.providers;
+
+import org.apache.wiki.api.core.Page;
+import org.apache.wiki.api.search.QueryItem;
+import org.apache.wiki.api.search.SearchResult;
+
+
+class SearchAdapter {
+
+    static org.apache.wiki.search.QueryItem oldQueryItemfrom( final QueryItem item ) {
+        final org.apache.wiki.search.QueryItem qi = new org.apache.wiki.search.QueryItem();
+        qi.type = item.type;
+        qi.word = item.word;
+        return qi;
+    }
+
+    static SearchResult newSearchResultFrom( final org.apache.wiki.search.SearchResult result ) {
+        return new SearchResult() {
+
+            /** {@inheritDoc} */
+            @Override
+            public Page getPage() {
+                return result.getPage();
+            }
+
+            /** {@inheritDoc} */
+            @Override
+            public int getScore() {
+                return result.getScore();
+            }
+
+            /** {@inheritDoc} */
+            @Override
+            public String[] getContexts() {
+                return result.getContexts();
+            }
+        };
+    }
+
+}
diff --git a/jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/SearchAdapterTest.java b/jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/SearchAdapterTest.java
new file mode 100644
index 0000000..40a9a35
--- /dev/null
+++ b/jspwiki-210-adapters/src/test/java/org/apache/wiki/providers/SearchAdapterTest.java
@@ -0,0 +1,47 @@
+package org.apache.wiki.providers;
+
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.search.QueryItem;
+import org.apache.wiki.api.search.SearchResult;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+
+public class SearchAdapterTest {
+
+    @Test
+    public void testOldQueryItemfrom() {
+        final QueryItem qi = new QueryItem();
+        qi.type = 1;
+        qi.word = "word";
+        final org.apache.wiki.search.QueryItem old = SearchAdapter.oldQueryItemfrom( qi );
+        Assertions.assertEquals( qi.type, old.type );
+        Assertions.assertEquals( qi.word, old.word );
+    }
+
+    @Test
+    public void testNewSearchResultFrom() {
+        final org.apache.wiki.search.SearchResult old = new org.apache.wiki.search.SearchResult() {
+
+            @Override
+            public WikiPage getPage() {
+                return null;
+            }
+
+            @Override
+            public int getScore() {
+                return 0;
+            }
+
+            @Override
+            public String[] getContexts() {
+                return new String[ 0 ];
+            }
+        };
+        final SearchResult sr = SearchAdapter.newSearchResultFrom( old );
+        Assertions.assertEquals( old.getPage(), sr.getPage() );
+        Assertions.assertEquals( old.getScore(), sr.getScore() );
+        Assertions.assertArrayEquals( old.getContexts(), sr.getContexts() );
+    }
+
+}


[jspwiki] 04/36: o.a.w.search classes don't need to extend their counterparts from o.a.w.api.search

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 466f2be2c443ccf1311ec926efb6c9f244e1f99c
Author: juanpablo <ju...@apache.org>
AuthorDate: Tue Mar 17 22:41:11 2020 +0100

    o.a.w.search classes don't need to extend their counterparts from o.a.w.api.search
---
 .../main/java/org/apache/wiki/search/QueryItem.java    | 18 +++++++++++++++++-
 .../main/java/org/apache/wiki/search/SearchResult.java | 17 ++++++++++++++++-
 2 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/QueryItem.java b/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/QueryItem.java
index 54b6dd7..280c546 100644
--- a/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/QueryItem.java
+++ b/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/QueryItem.java
@@ -26,5 +26,21 @@ package org.apache.wiki.search;
  * @see org.apache.wiki.api.search.QueryItem
  */
 @Deprecated
-public class QueryItem extends org.apache.wiki.api.search.QueryItem {
+public class QueryItem {
+
+    /** The word is required to be in the pages */
+    public static final int REQUIRED  = 1;
+
+    /** The word may NOT be in the pages */
+    public static final int FORBIDDEN = -1;
+
+    /** The word should be in the pages, but the search engine may use its own discretion. */
+    public static final int REQUESTED = 0;
+
+    /** The word that is being searched */
+    public String word;
+
+    /** The type of the word.  See above for types.  The default is REQUESTED. */
+    public int type = REQUESTED;
+
 }
diff --git a/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/SearchResult.java b/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/SearchResult.java
index dbb93ce..ae677a9 100644
--- a/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/SearchResult.java
+++ b/jspwiki-210-adapters/src/main/java/org/apache/wiki/search/SearchResult.java
@@ -28,7 +28,7 @@ import org.apache.wiki.WikiPage;
  * @see org.apache.wiki.api.search.SearchResult
  */
 @Deprecated
-public interface SearchResult extends org.apache.wiki.api.search.SearchResult {
+public interface SearchResult {
     
 	/**
      *  Return the page.
@@ -37,4 +37,19 @@ public interface SearchResult extends org.apache.wiki.api.search.SearchResult {
      */
     WikiPage getPage();
 
+    /**
+     *  Returns the score.
+     *
+     *  @return A positive score value.  Note that there is no upper limit for the score.
+     */
+    int getScore();
+
+    /**
+     * Collection of XHTML fragments representing some contexts in which the match was made (a.k.a., "snippets").
+     *
+     * @return the search results
+     * @since 2.4
+     */
+    String[] getContexts();
+
 }


[jspwiki] 15/36: JSPWIKI-303: provide backwards compatibility with public API for page/attachment providers not using it

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

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

commit cd501d28f79f0e91aa15995343db5504252f2ef6
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Mar 20 19:59:38 2020 +0100

    JSPWIKI-303: provide backwards compatibility with public API for page/attachment providers not using it
    
    to use page providers not using the public api, jspwiki.pageProvider must be set to WikiPageAdapterProvider and jspwiki.pageProvider.adapter.impl to the provider itself
    to use attachment providers not using the public api, jspwiki.attachmentProvider must be set to WikiAttachmentAdapterProvider and jspwiki.attachmentProvider.adapter.impl to the provider itself
    see WikiProviderAdaptersTest on the jspwiki-210-adapters module for an example configuration with these parameters
---
 .../providers/WikiAttachmentAdapterProvider.java   | 150 +++++++++++++++
 .../wiki/providers/WikiPageAdapterProvider.java    | 169 +++++++++++++++++
 .../providers/TwoXWikiAttachmentProvider.java      | 198 ++++++++++++++++++++
 .../example/providers/TwoXWikiPageProvider.java    | 206 +++++++++++++++++++++
 4 files changed, 723 insertions(+)

diff --git a/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiAttachmentAdapterProvider.java b/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiAttachmentAdapterProvider.java
new file mode 100644
index 0000000..e7b39a5
--- /dev/null
+++ b/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiAttachmentAdapterProvider.java
@@ -0,0 +1,150 @@
+/*
+    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.providers;
+
+import org.apache.log4j.Logger;
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Attachment;
+import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Page;
+import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
+import org.apache.wiki.api.exceptions.ProviderException;
+import org.apache.wiki.api.providers.AttachmentProvider;
+import org.apache.wiki.api.search.QueryItem;
+import org.apache.wiki.util.ClassUtil;
+import org.apache.wiki.util.TextUtil;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+import java.util.stream.Collectors;
+
+
+/**
+ * This provider ensures backward compatibility with attachment providers not using the public API. As providers should use the public API
+ * directly, the use of this class is considered deprecated.
+ *
+ * @deprecated adapted provider should use {@link AttachmentProvider} instead.
+ * @see AttachmentProvider
+ */
+@Deprecated
+public class WikiAttachmentAdapterProvider implements AttachmentProvider {
+
+    private static final Logger LOG = Logger.getLogger( WikiAttachmentAdapterProvider.class );
+    private static final String PROP_ADAPTER_IMPL = "jspwiki.attachmentProvider.adapter.impl";
+
+    WikiAttachmentProvider provider;
+
+    /** {@inheritDoc} */
+    @Override
+    public void initialize( final Engine engine, final Properties properties ) throws NoRequiredPropertyException, IOException {
+        LOG.warn( "Using an attachment provider through org.apache.wiki.providers.WikiAttachmentAdapterProvider" );
+        LOG.warn( "Please contact the attachment provider's author so there can be a new release of the provider " +
+                  "implementing the new org.apache.wiki.api.providers.AttachmentProvider public API" );
+        final String classname = TextUtil.getRequiredProperty( properties, PROP_ADAPTER_IMPL );
+        try {
+            LOG.debug( "Page provider class: '" + classname + "'" );
+            final Class<?> providerclass = ClassUtil.findClass("org.apache.wiki.providers", classname);
+            provider = ( WikiAttachmentProvider ) providerclass.newInstance();
+        } catch( final IllegalAccessException | InstantiationException | ClassNotFoundException e ) {
+            LOG.error( "Could not instantiate " + classname, e );
+            throw new IOException( e.getMessage(), e );
+        }
+
+        LOG.debug( "Initializing attachment provider class " + provider );
+        provider.initialize( engine, properties );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String getProviderInfo() {
+        return provider.getProviderInfo();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void putAttachmentData( final Attachment att, final InputStream data ) throws ProviderException, IOException {
+        provider.putAttachmentData( ( org.apache.wiki.attachment.Attachment )att, data );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public InputStream getAttachmentData( final Attachment att ) throws ProviderException, IOException {
+        return provider.getAttachmentData( ( org.apache.wiki.attachment.Attachment )att );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public List< Attachment > listAttachments( final Page page ) throws ProviderException {
+        return provider.listAttachments( ( WikiPage )page ).stream().map( att -> ( Attachment )att ).collect( Collectors.toList() );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Collection< Attachment > findAttachments( final QueryItem[] query ) {
+        final org.apache.wiki.search.QueryItem[] queryItems = Arrays.stream( query )
+                                                                    .map( SearchAdapter::oldQueryItemfrom )
+                                                                    .toArray( org.apache.wiki.search.QueryItem[]::new );
+        return provider.findAttachments( queryItems ).stream().map( att -> ( Attachment )att ).collect( Collectors.toList() );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public List< Attachment > listAllChanged( final Date timestamp ) throws ProviderException {
+        return provider.listAllChanged( timestamp ).stream().map( att -> ( Attachment )att ).collect( Collectors.toList() );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Attachment getAttachmentInfo( final Page page, final String name, final int version ) throws ProviderException {
+        return provider.getAttachmentInfo( ( WikiPage )page, name, version );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public List< Attachment > getVersionHistory( final Attachment att ) {
+        return provider.getVersionHistory( ( org.apache.wiki.attachment.Attachment )att )
+                       .stream()
+                       .map( attr -> ( Attachment )attr )
+                       .collect( Collectors.toList() );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void deleteVersion( final Attachment att ) throws ProviderException {
+        provider.deleteVersion( ( org.apache.wiki.attachment.Attachment )att );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void deleteAttachment( final Attachment att ) throws ProviderException {
+        provider.deleteAttachment( ( org.apache.wiki.attachment.Attachment )att );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void moveAttachmentsForPage( final String oldParent, final String newParent ) throws ProviderException {
+        provider.moveAttachmentsForPage( oldParent, newParent );
+    }
+
+}
diff --git a/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiPageAdapterProvider.java b/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiPageAdapterProvider.java
new file mode 100644
index 0000000..7558906
--- /dev/null
+++ b/jspwiki-210-adapters/src/main/java/org/apache/wiki/providers/WikiPageAdapterProvider.java
@@ -0,0 +1,169 @@
+/*
+    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.providers;
+
+import org.apache.log4j.Logger;
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.api.core.Engine;
+import org.apache.wiki.api.core.Page;
+import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
+import org.apache.wiki.api.exceptions.ProviderException;
+import org.apache.wiki.api.providers.PageProvider;
+import org.apache.wiki.api.search.QueryItem;
+import org.apache.wiki.api.search.SearchResult;
+import org.apache.wiki.search.SearchResultComparator;
+import org.apache.wiki.util.ClassUtil;
+import org.apache.wiki.util.TextUtil;
+
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
+
+
+/**
+ * This provider ensures backward compatibility with page providers not using the public API. As providers should use the public API
+ * directly, the use of this class is considered deprecated.
+ *
+ * @deprecated adapted provider should use {@link PageProvider} instead.
+ * @see PageProvider
+ */
+@Deprecated
+public class WikiPageAdapterProvider implements PageProvider {
+
+    private static final Logger LOG = Logger.getLogger( WikiPageAdapterProvider.class );
+    private static final String PROP_ADAPTER_IMPL = "jspwiki.pageProvider.adapter.impl";
+
+    WikiPageProvider provider;
+
+    /** {@inheritDoc} */
+    @Override
+    public void initialize( final Engine engine, final Properties properties ) throws NoRequiredPropertyException, IOException {
+        LOG.warn( "Using a page provider through org.apache.wiki.providers.WikiPageAdapterProviderAdapterProvider" );
+        LOG.warn( "Please contact the page provider's author so there can be a new release of the provider " +
+                  "implementing the new org.apache.wiki.api.providers.PageProvider public API" );
+        final String classname = TextUtil.getRequiredProperty( properties, PROP_ADAPTER_IMPL );
+        try {
+            LOG.debug( "Page provider class: '" + classname + "'" );
+            final Class<?> providerclass = ClassUtil.findClass("org.apache.wiki.providers", classname);
+            provider = ( WikiPageProvider ) providerclass.newInstance();
+        } catch( final IllegalAccessException | InstantiationException | ClassNotFoundException e ) {
+            LOG.error( "Could not instantiate " + classname, e );
+            throw new IOException( e.getMessage(), e );
+        }
+
+        LOG.debug( "Initializing page provider class " + provider );
+        provider.initialize( engine, properties );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String getProviderInfo() {
+        return provider.getProviderInfo();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void putPageText( final Page page, final String text ) throws ProviderException {
+        provider.putPageText( ( WikiPage )page, text );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean pageExists( final String page ) {
+        return provider.pageExists( page );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean pageExists( final String page, final int version ) {
+        return provider.pageExists( page, version );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Collection< SearchResult > findPages( final QueryItem[] query ) {
+        final org.apache.wiki.search.QueryItem[] queryItems = Arrays.stream( query )
+                                                                    .map( SearchAdapter::oldQueryItemfrom )
+                                                                    .toArray( org.apache.wiki.search.QueryItem[]::new );
+        final Collection< org.apache.wiki.search.SearchResult > results = provider.findPages( queryItems );
+        return results.stream()
+                      .map( SearchAdapter::newSearchResultFrom )
+                      .collect( Collectors.toCollection( () -> new TreeSet<>( new SearchResultComparator() ) ) );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Page getPageInfo( final String page, final int version ) throws ProviderException {
+        return provider.getPageInfo( page, version );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Collection< Page > getAllPages() throws ProviderException {
+        return provider.getAllPages().stream().map( wikiPage -> ( Page )wikiPage ).collect( Collectors.toList() );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Collection< Page > getAllChangedSince( final Date date ) {
+        return provider.getAllChangedSince( date ).stream().map( wikiPage -> ( Page )wikiPage ).collect( Collectors.toList() );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public int getPageCount() throws ProviderException {
+        return provider.getPageCount();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public List< Page > getVersionHistory( final String page ) throws ProviderException {
+        return provider.getVersionHistory( page ).stream().map( wikiPage -> ( Page )wikiPage ).collect( Collectors.toList() );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String getPageText( final String page, final int version ) throws ProviderException {
+        return provider.getPageText( page, version );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void deleteVersion( final String pageName, final int version ) throws ProviderException {
+        provider.deleteVersion( pageName, version );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void deletePage( final String pageName ) throws ProviderException {
+        provider.deletePage( pageName );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void movePage( final String from, final String to ) throws ProviderException {
+        provider.movePage( from, to );
+    }
+
+}
diff --git a/jspwiki-210-test-adaptees/src/test/java/com/example/providers/TwoXWikiAttachmentProvider.java b/jspwiki-210-test-adaptees/src/test/java/com/example/providers/TwoXWikiAttachmentProvider.java
new file mode 100644
index 0000000..7b6ba45
--- /dev/null
+++ b/jspwiki-210-test-adaptees/src/test/java/com/example/providers/TwoXWikiAttachmentProvider.java
@@ -0,0 +1,198 @@
+/*
+    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 com.example.providers;
+
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.WikiProvider;
+import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
+import org.apache.wiki.api.exceptions.ProviderException;
+import org.apache.wiki.attachment.Attachment;
+import org.apache.wiki.pages.PageTimeComparator;
+import org.apache.wiki.providers.WikiAttachmentProvider;
+import org.apache.wiki.search.QueryItem;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.stream.Collectors;
+
+
+public class TwoXWikiAttachmentProvider implements WikiAttachmentProvider {
+
+    WikiEngine engine;
+    Map< String, List < Attachment > > attachments = new ConcurrentHashMap<>();
+    Map< String, List < InputStream > > contents = new ConcurrentHashMap<>();
+
+    /** {@inheritDoc} */
+    @Override
+    public String getProviderInfo() {
+        return this.getClass().getName();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void initialize( final WikiEngine engine, final Properties properties ) throws NoRequiredPropertyException, IOException {
+        this.engine = engine;
+        try {
+            putAttachmentData( new Attachment( engine, "page1", "att11.txt" ), new ByteArrayInputStream( "blurb".getBytes( StandardCharsets.UTF_8 ) ) );
+            putAttachmentData( new Attachment( engine, "page1", "att12.txt" ), new ByteArrayInputStream( "blerb".getBytes( StandardCharsets.UTF_8) ) );
+            putAttachmentData( new Attachment( engine, "page2", "att21.txt" ), new ByteArrayInputStream( "blarb".getBytes( StandardCharsets.UTF_8) ) );
+        } catch( final ProviderException e ) {
+            throw new IOException( e.getMessage(), e );
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void putAttachmentData( final Attachment att, final InputStream data ) throws ProviderException, IOException {
+        att.setVersion( att.getVersion() + 1 );
+        att.setLastModified( new Date() );
+        if( attachmentExists( att ) ) {
+            attachments.get( att.getName() ).add( att );
+            contents.get( att.getName() ).add( data );
+        } else {
+            attachments.put( att.getName(), new ArrayList<>( Arrays.asList( att ) ) );
+            contents.put( att.getName(), new ArrayList<>( Arrays.asList( data ) ) );
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public InputStream getAttachmentData( final Attachment att ) throws ProviderException, IOException {
+        final int v = att.getVersion() == WikiProvider.LATEST_VERSION ? contents.get( att.getName() ).size() - 1 : att.getVersion();
+        return contents.get( att.getName() ).get( v );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public List< Attachment > listAttachments( final WikiPage page ) throws ProviderException {
+        return attachments.entrySet()
+                          .stream()
+                          .filter( e -> e.getKey().startsWith( page.getName() + "/" ) )
+                          .map( Map.Entry::getValue )
+                          .flatMap( List::stream )
+                          .collect( Collectors.toList() );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Collection< Attachment > findAttachments( final QueryItem[] query ) {
+        return new ArrayList<>();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public List< Attachment > listAllChanged( final Date timestamp ) throws ProviderException {
+        final List< Attachment > attachs = attachments.values()
+                                                      .stream()
+                                                      .map( attrs -> attrs.get( attrs.size() -1 ) )
+                                                      .filter( att -> att.getLastModified() != null && att.getLastModified().after( timestamp ) )
+                                                      .collect( Collectors.toList() );
+        attachs.sort( new PageTimeComparator() );
+        return attachs;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Attachment getAttachmentInfo( final WikiPage page, final String name, final int version ) throws ProviderException {
+        if( attachments.get( page.getName() + "/" + name ) != null ) {
+            final int v = version == WikiProvider.LATEST_VERSION ? contents.get( page.getName() + "/" + name ).size() - 1 : version;
+            return attachments.get( page.getName() + "/" + name ).get( v );
+        }
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public List< Attachment > getVersionHistory( final Attachment att ) {
+        if( att != null && attachments.get( att.getName() ) != null ) {
+            return attachments.get( att.getName() );
+        }
+        return Collections.emptyList();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void deleteVersion( final Attachment att ) throws ProviderException {
+        if( attachmentVersionExists( att ) ) {
+            attachments.get( att.getName() ).remove( att.getVersion() - 1 );
+            contents.get( att.getName() ).remove( att.getVersion() - 1 );
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void deleteAttachment( final Attachment att ) throws ProviderException {
+        if( att != null ) {
+            attachments.remove( att.getName() );
+            contents.remove( att.getName() );
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void moveAttachmentsForPage( final String oldParent, final String newParent ) throws ProviderException {
+        final Map< String, List < Attachment > > oldAttachments = attachments.entrySet()
+                                                                             .stream()
+                                                                             .filter( e -> e.getKey().startsWith( oldParent + "/" ) )
+                                                                             .collect( Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue ) );
+        final Map< String, List < InputStream > > oldContents = contents.entrySet()
+                                                                        .stream()
+                                                                        .filter( e -> e.getKey().startsWith( oldParent + "/" ) )
+                                                                        .collect( Collectors.toMap( Map.Entry::getKey, Map.Entry::getValue ) );
+
+        // If it exists, we're overwriting an old page (this has already been confirmed at a higher level), so delete any existing attachments.
+        oldAttachments.forEach( ( key, value ) -> {
+            final String newKey = newParent + "/" + key.substring( key.indexOf( '/' ) + 1 );
+            attachments.putIfAbsent( newKey, value );
+            if( attachments.get( key ) != null ) {
+                attachments.remove( key );
+            }
+        } );
+        oldContents.forEach( ( key, value ) -> {
+            final String newKey = newParent + "/" + key.substring( key.indexOf( '/' ) + 1 );
+            contents.putIfAbsent( newKey, value );
+            if( contents.get( key ) != null ) {
+                contents.remove( key );
+            }
+        } );
+    }
+
+    boolean attachmentExists( final Attachment att ) {
+        return att != null && attachments.get( att.getName() ) != null && contents.get( att.getName() ) != null;
+    }
+
+    boolean attachmentVersionExists( final Attachment att ) {
+        return attachmentExists( att ) &&
+               attachments.get( att.getName() ).size() >= att.getVersion() &&
+               contents.get( att.getName() ).size() >= att.getVersion();
+    }
+
+}
diff --git a/jspwiki-210-test-adaptees/src/test/java/com/example/providers/TwoXWikiPageProvider.java b/jspwiki-210-test-adaptees/src/test/java/com/example/providers/TwoXWikiPageProvider.java
new file mode 100644
index 0000000..0bde27c
--- /dev/null
+++ b/jspwiki-210-test-adaptees/src/test/java/com/example/providers/TwoXWikiPageProvider.java
@@ -0,0 +1,206 @@
+/*
+    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 com.example.providers;
+
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.WikiPage;
+import org.apache.wiki.WikiProvider;
+import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
+import org.apache.wiki.api.exceptions.ProviderException;
+import org.apache.wiki.providers.WikiPageProvider;
+import org.apache.wiki.search.QueryItem;
+import org.apache.wiki.search.SearchMatcher;
+import org.apache.wiki.search.SearchResult;
+import org.apache.wiki.search.SearchResultComparator;
+
+import java.io.IOException;
+import java.util.AbstractMap;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Supplier;
+import java.util.stream.Collectors;
+
+
+public class TwoXWikiPageProvider implements WikiPageProvider {
+
+    WikiEngine engine;
+    Map< String, List < WikiPage > > pages = new ConcurrentHashMap<>();
+    Map< String, List < String > > contents = new ConcurrentHashMap<>();
+
+    /** {@inheritDoc} */
+    @Override
+    public String getProviderInfo() {
+        return this.getClass().getName();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void initialize( final WikiEngine engine, final Properties properties ) throws NoRequiredPropertyException, IOException {
+        this.engine = engine;
+        try {
+            putPageText( new WikiPage( engine, "page1" ), "blablablabla" );
+            putPageText( new WikiPage( engine, "page2" ), "bleblebleble" );
+            putPageText( new WikiPage( engine, "page3" ), "blibliblibli" );
+        } catch( final ProviderException e ) {
+            throw new IOException( e.getMessage(), e );
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void putPageText( final WikiPage page, final String text ) throws ProviderException {
+        page.setVersion( page.getVersion() + 1 );
+        page.setLastModified( new Date() );
+        if( pageExists( page.getName() ) ) {
+            pages.get( page.getName() ).add( page );
+            contents.get( page.getName() ).add( text );
+        } else {
+            pages.put( page.getName(), new ArrayList<>( Arrays.asList( page ) ) );
+            contents.put( page.getName(), new ArrayList<>( Arrays.asList( text ) ) );
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean pageExists( final String page ) {
+        return pages.get( page ) != null && contents.get( page ) != null;
+    }
+
+    < S > S executeIfPageExists( final String page, final int version, final Supplier< S > s ) throws ProviderException {
+        if( pageExists( page, version ) ) {
+            try {
+                return s.get();
+            } catch( final Exception e ) {
+                throw new ProviderException( e.getMessage() );
+            }
+        }
+        return null;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public boolean pageExists( final String page, final int version ) {
+        return pages.get( page ) != null    && pages.get( page ).size() >= version &&
+               contents.get( page ) != null && contents.get( page ).size() >= version;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Collection< SearchResult > findPages( final QueryItem[] query ) {
+        final TreeSet< SearchResult > res = new TreeSet<>( new SearchResultComparator() );
+        final SearchMatcher matcher = new SearchMatcher( engine, query );
+        final Map< String, WikiPage > wikipages = pages.entrySet()
+                                                       .stream()
+                                                       .map( e -> new AbstractMap.SimpleEntry<>( e.getKey(), e.getValue().get( e.getValue().size() - 1 ) ) )
+                                                       .collect( Collectors.toMap( AbstractMap.SimpleEntry::getKey, AbstractMap.SimpleEntry::getValue ) );
+        for( final String wikipage : wikipages.keySet() ) {
+            final String pagetext = contents.get( wikipage ).get( contents.get( wikipage ).size() - 1 );
+            try {
+                final SearchResult comparison = matcher.matchPageContent( wikipage, pagetext );
+                if( comparison != null ) {
+                    res.add( comparison );
+                }
+            } catch( final IOException e ) {
+                // ok to ignore, shouldn't happen
+            }
+        }
+        return res;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public WikiPage getPageInfo( final String page, final int version ) throws ProviderException {
+        return executeIfPageExists( page, version, () -> pages.get( page ).get( version ) );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Collection< WikiPage > getAllPages() throws ProviderException {
+        return pages.values().stream().map( versions -> versions.get( versions.size() - 1 ) ).collect( Collectors.toList() );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public Collection< WikiPage > getAllChangedSince( final Date date ) {
+        try {
+            return getAllPages();
+        } catch( final ProviderException e ) {
+            return Collections.emptyList();
+        }
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public int getPageCount() throws ProviderException {
+        return pages.size();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public List< WikiPage > getVersionHistory( final String page ) throws ProviderException {
+        return pageExists( page ) ? pages.get( page ) : Collections.emptyList();
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public String getPageText( final String page, final int version ) throws ProviderException {
+        return executeIfPageExists( page, version, () -> {
+            final int v = version == WikiProvider.LATEST_VERSION ? contents.get( page ).size() - 1 : version;
+            return contents.get( page ).get( v );
+        } );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void deleteVersion( final String pageName, final int version ) throws ProviderException {
+        executeIfPageExists( pageName, version, () -> {
+            pages.get( pageName ).remove( version );
+            contents.get( pageName ).remove( version );
+            return null;
+        } );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void deletePage( final String pageName ) throws ProviderException {
+        pages.remove( pageName );
+        contents.remove( pageName );
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public void movePage( final String from, final String to ) throws ProviderException {
+        if( pageExists( to ) ) {
+            throw new ProviderException( to + " page already exists, can't move there" );
+        }
+        pages.put( to, pages.get( from ) );
+        contents.put( to, contents.get( from ) );
+        pages.remove( from );
+        contents.remove( from );
+    }
+
+}


[jspwiki] 23/36: use Page insead of WikiPage

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 01b2adf008f959f7920c4434142a17a15f121451
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 14:15:45 2020 +0100

    use Page insead of WikiPage
---
 .../java/org/apache/wiki/providers/AbstractFileProvider.java   |  4 ++--
 .../java/org/apache/wiki/providers/FileSystemProvider.java     |  4 ++--
 .../java/org/apache/wiki/providers/VersioningFileProvider.java | 10 +++++-----
 3 files changed, 9 insertions(+), 9 deletions(-)

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 cbad778..4304ef8 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
@@ -367,13 +367,13 @@ public abstract class AbstractFileProvider implements PageProvider {
      *  {@inheritDoc}
      */
     @Override
-    public WikiPage getPageInfo( final String page, final int version ) throws ProviderException {
+    public Page getPageInfo( final String page, final int version ) throws ProviderException {
         final File file = findPage( page );
         if( !file.exists() ) {
             return null;
         }
 
-        final WikiPage p = new WikiPage( m_engine, page );
+        final Page p = new WikiPage( m_engine, page );
         p.setLastModified( new Date( file.lastModified() ) );
 
         return p;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/providers/FileSystemProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/providers/FileSystemProvider.java
index 8368f10..f2b7f08 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/providers/FileSystemProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/providers/FileSystemProvider.java
@@ -120,8 +120,8 @@ public class FileSystemProvider extends AbstractFileProvider {
      *  {@inheritDoc}
      */
     @Override
-    public WikiPage getPageInfo( final String page, final int version ) throws ProviderException {
-        final WikiPage p = super.getPageInfo( page, version );
+    public Page getPageInfo( final String page, final int version ) throws ProviderException {
+        final Page p = super.getPageInfo( page, version );
         if( p != null ) {
             try {
                 getPageProperties( p );
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 cfa6af2..bf8364c 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
@@ -384,7 +384,7 @@ public class VersioningFileProvider extends AbstractFileProvider {
             page.setAuthor(newAuthor);
             props.setProperty( versionNumber + ".author", newAuthor );
 
-            final String changeNote = page.getAttribute(WikiPage.CHANGENOTE);
+            final String changeNote = page.getAttribute( Page.CHANGENOTE );
             if( changeNote != null ) {
                 props.setProperty( versionNumber + ".changenote", changeNote );
             }
@@ -402,11 +402,11 @@ public class VersioningFileProvider extends AbstractFileProvider {
      *  {@inheritDoc}
      */
     @Override
-    public WikiPage getPageInfo( final String page, final int version ) throws ProviderException {
+    public Page getPageInfo( final String page, final int version ) throws ProviderException {
         final int latest = findLatestVersion( page );
         final int realVersion;
 
-        WikiPage p = null;
+        Page p = null;
 
         if( version == PageProvider.LATEST_VERSION || version == latest || (version == 1 && latest == -1) ) {
             //
@@ -494,7 +494,7 @@ public class VersioningFileProvider extends AbstractFileProvider {
         final ArrayList< Page > list = new ArrayList<>();
         final int latest = findLatestVersion( page );
         for( int i = latest; i > 0; i-- ) {
-            final WikiPage info = getPageInfo( page, i );
+            final Page info = getPageInfo( page, i );
             if( info != null ) {
                 list.add( info );
             }
@@ -521,7 +521,7 @@ public class VersioningFileProvider extends AbstractFileProvider {
                 final Properties props = new Properties();
                 props.load( in );
 
-                final String originalAuthor = props.getProperty( WikiPage.AUTHOR );
+                final String originalAuthor = props.getProperty( Page.AUTHOR );
                 if ( originalAuthor.length() > 0 ) {
                     // simulate original author as if already versioned but put non-versioned property in special cache too
                     props.setProperty( "1.author", originalAuthor );


[jspwiki] 32/36: move rss initialization from WikiEngine into RSSGenerator

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 380600727195f334fcfb7475c94ef5896a681526
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 17:08:10 2020 +0100

    move rss initialization from WikiEngine into RSSGenerator
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 18 ++---------
 .../java/org/apache/wiki/rss/RSSGenerator.java     | 35 ++++++++++++++++++----
 2 files changed, 31 insertions(+), 22 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 5c5e7e2..f907fd7 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -45,7 +45,6 @@ import org.apache.wiki.plugin.PluginManager;
 import org.apache.wiki.references.ReferenceManager;
 import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.rss.RSSGenerator;
-import org.apache.wiki.rss.RSSThread;
 import org.apache.wiki.search.SearchManager;
 import org.apache.wiki.tasks.TasksManager;
 import org.apache.wiki.ui.CommandResolver;
@@ -518,26 +517,13 @@ public class WikiEngine implements Engine {
         try {
             if( TextUtil.getBooleanProperty( props, RSSGenerator.PROP_GENERATE_RSS,false ) ) {
                 m_rssGenerator = ClassUtil.getMappedObject( RSSGenerator.class.getName(), this, props );
+                m_rssGenerator.initialize( this, props );
                 managers.put( RSSGenerator.class, m_rssGenerator );
             }
         } catch( final Exception e ) {
             log.error( "Unable to start RSS generator - JSPWiki will still work, but there will be no RSS feed.", e );
         }
 
-        // Start the RSS generator & generator thread
-        if( m_rssGenerator != null ) {
-            m_rssFile = TextUtil.getStringProperty( props, RSSGenerator.PROP_RSSFILE, "rss.rdf" );
-            final File rssFile;
-            if( m_rssFile.startsWith( File.separator ) ) { // honor absolute pathnames:
-                rssFile = new File(m_rssFile );
-            } else { // relative path names are anchored from the webapp root path:
-                rssFile = new File( getRootPath(), m_rssFile );
-            }
-            final int rssInterval = TextUtil.getIntegerProperty( props, RSSGenerator.PROP_INTERVAL, 3600 );
-            final RSSThread rssThread = new RSSThread( this, rssFile, rssInterval );
-            rssThread.start();
-        }
-
         fireEvent( WikiEngineEvent.INITIALIZED ); // initialization complete
 
         log.info("WikiEngine configured.");
@@ -664,7 +650,7 @@ public class WikiEngine implements Engine {
     @Override
     public String getGlobalRSSURL() {
         if( m_rssGenerator != null && m_rssGenerator.isEnabled() ) {
-            return getBaseURL() + "/" + m_rssFile;
+            return getBaseURL() + "/" + m_rssGenerator.getRssFile();
         }
 
         return null;
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 827c99e..9b0e621 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
@@ -37,6 +37,7 @@ import org.apache.wiki.render.RenderingManager;
 import org.apache.wiki.util.TextUtil;
 import org.apache.wiki.variables.VariableManager;
 
+import java.io.File;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
@@ -63,6 +64,8 @@ public class RSSGenerator {
     private static final Logger log = Logger.getLogger( RSSGenerator.class );
     private Engine m_engine;
 
+    /** The RSS file to generate. */
+    private String m_rssFile;
     private String m_channelDescription = "";
     private String m_channelLanguage = "en-us";
     private boolean m_enabled = true;
@@ -136,6 +139,25 @@ public class RSSGenerator {
         m_engine = engine;
         m_channelDescription = properties.getProperty( PROP_CHANNEL_DESCRIPTION, m_channelDescription );
         m_channelLanguage = properties.getProperty( PROP_CHANNEL_LANGUAGE, m_channelLanguage );
+        m_rssFile = TextUtil.getStringProperty( properties, RSSGenerator.PROP_RSSFILE, "rss.rdf" );
+    }
+
+    /**
+     * Start the RSS generator & generator thread
+     *
+     * @param engine the engine
+     * @param properties the properties
+     */
+    public void initialize( final Engine engine, final Properties properties ) {
+        final File rssFile;
+        if( m_rssFile.startsWith( File.separator ) ) { // honor absolute pathnames
+            rssFile = new File( m_rssFile );
+        } else { // relative path names are anchored from the webapp root path
+            rssFile = new File( engine.getRootPath(), m_rssFile );
+        }
+        final int rssInterval = TextUtil.getIntegerProperty( properties, RSSGenerator.PROP_INTERVAL, 3600 );
+        final RSSThread rssThread = new RSSThread( engine, rssFile, rssInterval );
+        rssThread.start();
     }
 
     /**
@@ -214,8 +236,7 @@ public class RSSGenerator {
     }
 
     // FIXME: This should probably return something more intelligent
-    private String getEntryTitle( final Page page )
-    {
+    private String getEntryTitle( final Page page ) {
         return page.getName() + ", version " + page.getVersion();
     }
 
@@ -290,8 +311,7 @@ public class RSSGenerator {
      *
      * @return whether RSS generation is currently enabled
      */
-    public boolean isEnabled()
-    {
+    public boolean isEnabled() {
         return m_enabled;
     }
 
@@ -301,11 +321,14 @@ public class RSSGenerator {
      *
      * @param enabled whether RSS generation is considered enabled.
      */
-    public synchronized void setEnabled( final boolean enabled )
-    {
+    public synchronized void setEnabled( final boolean enabled ) {
         m_enabled = enabled;
     }
 
+    public String getRssFile() {
+        return m_rssFile;
+    }
+
     /**
      *  Generates an RSS feed for the entire wiki.  Each item should be an instance of the RSSItem class.
      *  


[jspwiki] 31/36: reorganized WikiEngine initialization, to ease generalization of managers' creation and configuration later on

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 a493a169b0e58ca3f06f2f98e3f0cd42bd888055
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 16:59:17 2020 +0100

    reorganized WikiEngine initialization, to ease generalization of managers' creation and configuration later on
---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 103 +++++++++++----------
 .../wiki/auth/acl/DefaultAclManagerTest.java       |   6 +-
 2 files changed, 55 insertions(+), 54 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
index 1af886b..5c5e7e2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -402,75 +402,91 @@ public class WikiEngine implements Engine {
         //
         // FIXME: This part of the code is getting unwieldy.  We must think of a better way to do the startup-sequence.
         try {
-            //  Initializes the CommandResolver
+            final String aclClassName = m_properties.getProperty( PROP_ACL_MANAGER_IMPL, ClassUtil.getMappedClass( AclManager.class.getName() ).getName() );
+            final String urlConstructorClassnName = TextUtil.getStringProperty( props, PROP_URLCONSTRUCTOR, "DefaultURLConstructor" );
+            final Class< ? > urlclass = ClassUtil.findClass( "org.apache.wiki.url", urlConstructorClassnName );
+
             m_commandResolver = ClassUtil.getMappedObject( CommandResolver.class.getName(), this, props );
-            final Class< ? > urlclass = ClassUtil.findClass( "org.apache.wiki.url",
-                                                             TextUtil.getStringProperty( props, PROP_URLCONSTRUCTOR, "DefaultURLConstructor" ) );
+            managers.put( CommandResolver.class, m_commandResolver );
+
             m_urlConstructor = ( URLConstructor ) urlclass.getDeclaredConstructor().newInstance();
             m_urlConstructor.initialize( this, props );
+            managers.put( URLConstructor.class, m_urlConstructor );
 
             m_pageManager           = ClassUtil.getMappedObject( PageManager.class.getName(), this, props );
+            managers.put( PageManager.class, m_pageManager );
+
             m_pluginManager         = ClassUtil.getMappedObject( PluginManager.class.getName(), this, props );
+            managers.put( PluginManager.class, m_pluginManager );
+
             m_differenceManager     = ClassUtil.getMappedObject( DifferenceManager.class.getName(), this, props );
+            managers.put( DifferenceManager.class, m_differenceManager );
+
             m_attachmentManager     = ClassUtil.getMappedObject( AttachmentManager.class.getName(), this, props );
+            managers.put( AttachmentManager.class, m_attachmentManager );
+
             m_variableManager       = ClassUtil.getMappedObject( VariableManager.class.getName(), props );
-            m_renderingManager      = ClassUtil.getMappedObject( RenderingManager.class.getName() );
+            managers.put( VariableManager.class, m_variableManager );
+
             m_searchManager         = ClassUtil.getMappedObject( SearchManager.class.getName(), this, props );
+            managers.put( SearchManager.class, m_searchManager );
+
             m_authenticationManager = ClassUtil.getMappedObject( AuthenticationManager.class.getName() );
+            m_authenticationManager.initialize( this, props );
+            managers.put( AuthenticationManager.class, m_authenticationManager );
+
             m_authorizationManager  = ClassUtil.getMappedObject( AuthorizationManager.class.getName() );
+            m_authorizationManager.initialize( this, props );
+            managers.put( AuthorizationManager.class, m_authorizationManager );
+
             m_userManager           = ClassUtil.getMappedObject( UserManager.class.getName() );
+            m_userManager.initialize( this, props );
+            managers.put( UserManager.class, m_userManager );
+
             m_groupManager          = ClassUtil.getMappedObject( GroupManager.class.getName() );
+            m_groupManager.initialize( this, props );
+            managers.put( GroupManager.class, m_groupManager );
+
             m_editorManager         = ClassUtil.getMappedObject( EditorManager.class.getName(), this );
-            m_progressManager       = ClassUtil.getMappedObject( ProgressManager.class.getName(), this );
             m_editorManager.initialize( props );
+            managers.put( EditorManager.class, m_editorManager );
 
-            // Initialize the authentication, authorization, user and acl managers
-            m_authenticationManager.initialize( this, props );
-            m_authorizationManager.initialize( this, props );
-
-            managers.put( CommandResolver.class, m_commandResolver );
-            managers.put( URLConstructor.class, m_urlConstructor );
-            managers.put( PageManager.class, m_pageManager );
-            managers.put( PluginManager.class, m_pluginManager );
-            managers.put( DifferenceManager.class, m_differenceManager );
-            managers.put( AttachmentManager.class, m_attachmentManager );
-            managers.put( VariableManager.class, m_variableManager );
-            managers.put( RenderingManager.class, m_renderingManager );
-            managers.put( SearchManager.class, m_searchManager );
-            managers.put( AuthenticationManager.class, m_authenticationManager );
-            managers.put( AuthorizationManager.class, m_authorizationManager );
-            managers.put( UserManager.class, m_userManager );
+            m_progressManager       = ClassUtil.getMappedObject( ProgressManager.class.getName(), this );
+            managers.put( ProgressManager.class, m_progressManager );
 
-            m_userManager.initialize( this, props );
-            m_groupManager.initialize( this, props );
-            m_aclManager = getAclManager();
+            m_aclManager = ClassUtil.getMappedObject( aclClassName ); // TODO: I am not sure whether this is the right call
+            m_aclManager.initialize( this, m_properties );
+            managers.put( AclManager.class, m_aclManager );
 
             // Start the Workflow manager
             m_workflowMgr = ClassUtil.getMappedObject(WorkflowManager.class.getName());
             m_workflowMgr.initialize(this, props);
+            managers.put( WorkflowManager.class, m_workflowMgr );
+
             m_tasksManager = ClassUtil.getMappedObject(TasksManager.class.getName());
+            managers.put( TasksManager.class, m_tasksManager );
 
             m_internationalizationManager = ClassUtil.getMappedObject(InternationalizationManager.class.getName(),this);
+            managers.put( InternationalizationManager.class, m_internationalizationManager );
+
             m_templateManager = ClassUtil.getMappedObject(TemplateManager.class.getName(), this, props );
+            managers.put( TemplateManager.class, m_templateManager );
 
             // Since we want to use a page filters initilize() method as a engine startup listener where we can initialize global event
             // listeners, it must be called lastly, so that all object references in the engine are availabe to the initialize() method
             m_filterManager = ClassUtil.getMappedObject(FilterManager.class.getName(), this, props );
-
-            managers.put( GroupManager.class, m_groupManager );
-            managers.put( EditorManager.class, m_editorManager );
-            managers.put( ProgressManager.class, m_progressManager );
-            managers.put( AclManager.class, m_aclManager );
-            managers.put( WorkflowManager.class, m_workflowMgr );
-            managers.put( TasksManager.class, m_tasksManager );
-            managers.put( InternationalizationManager.class, m_internationalizationManager );
-            managers.put( TemplateManager.class, m_templateManager );
             managers.put( FilterManager.class, m_filterManager );
 
             m_adminBeanManager = ClassUtil.getMappedObject(AdminBeanManager.class.getName(),this);
+            managers.put( AdminBeanManager.class, m_adminBeanManager );
+
+            m_pageRenamer = ClassUtil.getMappedObject( PageRenamer.class.getName(), this, props );
+            managers.put( PageRenamer.class, m_pageRenamer );
 
             // RenderingManager depends on FilterManager events.
+            m_renderingManager = ClassUtil.getMappedObject( RenderingManager.class.getName() );
             m_renderingManager.initialize( this, props );
+            managers.put( RenderingManager.class, m_renderingManager );
 
             //  ReferenceManager has the side effect of loading all pages.  Therefore after this point, all page attributes are available.
             //  initReferenceManager is indirectly using m_filterManager, therefore it has to be called after it was initialized.
@@ -479,12 +495,6 @@ public class WikiEngine implements Engine {
             //  Hook the different manager routines into the system.
             m_filterManager.addPageFilter( m_referenceManager, -1001 );
             m_filterManager.addPageFilter( m_searchManager, -1002 );
-
-            m_pageRenamer = ClassUtil.getMappedObject( PageRenamer.class.getName(), this, props );
-
-            managers.put( ReferenceManager.class, m_referenceManager );
-            managers.put( AdminBeanManager.class, m_adminBeanManager );
-            managers.put( PageRenamer.class, m_pageRenamer );
         } catch( final RuntimeException e ) {
             // RuntimeExceptions may occur here, even if they shouldn't.
             log.fatal( "Failed to start managers.", e );
@@ -508,6 +518,7 @@ public class WikiEngine implements Engine {
         try {
             if( TextUtil.getBooleanProperty( props, RSSGenerator.PROP_GENERATE_RSS,false ) ) {
                 m_rssGenerator = ClassUtil.getMappedObject( RSSGenerator.class.getName(), this, props );
+                managers.put( RSSGenerator.class, m_rssGenerator );
             }
         } catch( final Exception e ) {
             log.error( "Unable to start RSS generator - JSPWiki will still work, but there will be no RSS feed.", e );
@@ -515,7 +526,6 @@ public class WikiEngine implements Engine {
 
         // Start the RSS generator & generator thread
         if( m_rssGenerator != null ) {
-            managers.put( RSSGenerator.class, m_rssGenerator );
             m_rssFile = TextUtil.getStringProperty( props, RSSGenerator.PROP_RSSFILE, "rss.rdf" );
             final File rssFile;
             if( m_rssFile.startsWith( File.separator ) ) { // honor absolute pathnames:
@@ -601,6 +611,7 @@ public class WikiEngine implements Engine {
             if( m_referenceManager == null ) {
                 m_referenceManager = ClassUtil.getMappedObject(ReferenceManager.class.getName(), this );
                 m_referenceManager.initialize( pages );
+                managers.put( ReferenceManager.class, m_referenceManager );
             }
 
         } catch( final ProviderException e ) {
@@ -987,17 +998,7 @@ public class WikiEngine implements Engine {
      * @return The current AclManager.
      */
     public AclManager getAclManager()  {
-        if( m_aclManager == null ) {
-            try {
-                final String s = m_properties.getProperty( PROP_ACL_MANAGER_IMPL, ClassUtil.getMappedClass( AclManager.class.getName() ).getName() );
-                m_aclManager = ClassUtil.getMappedObject(s); // TODO: I am not sure whether this is the right call
-                m_aclManager.initialize( this, m_properties );
-            } catch( final ReflectiveOperationException | IllegalArgumentException e ) {
-                log.fatal( "unable to instantiate class for AclManager: " + e.getMessage() );
-                throw new InternalWikiException( "Cannot instantiate AclManager, please check logs.", e );
-            }
-        }
-        return m_aclManager;
+        return getManager( AclManager.class );
     }
 
     /**
diff --git a/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java b/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java
index 06b4d23..d1fccb7 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/auth/acl/DefaultAclManagerTest.java
@@ -56,12 +56,12 @@ public class DefaultAclManagerTest
     public void testGetPermissions()
     {
         WikiPage page = ( WikiPage )m_engine.getManager( PageManager.class ).getPage( "TestDefaultPage" );
-        Acl acl = m_engine.getAclManager().getPermissions( page );
+        Acl acl = m_engine.getManager( AclManager.class ).getPermissions( page );
         Assertions.assertNotNull( page.getAcl() );
         Assertions.assertTrue(page.getAcl().isEmpty());
 
         page = ( WikiPage )m_engine.getManager( PageManager.class ).getPage( "TestAclPage" );
-        acl = m_engine.getAclManager().getPermissions( page );
+        acl = m_engine.getManager( AclManager.class ).getPermissions( page );
         Assertions.assertNotNull( page.getAcl() );
         Assertions.assertFalse(page.getAcl().isEmpty());
 
@@ -162,7 +162,7 @@ public class DefaultAclManagerTest
     {
         // Verify that the printed Acl for the test page is OK
         final WikiPage page = ( WikiPage )m_engine.getManager( PageManager.class ).getPage( "TestAclPage" );
-        Acl acl = m_engine.getAclManager().getPermissions( page );
+        Acl acl = m_engine.getManager( AclManager.class ).getPermissions( page );
         final String aclString = DefaultAclManager.printAcl( acl );
         Assertions.assertEquals( "[{ALLOW edit Charlie,Herman}]\n", aclString );
 


[jspwiki] 28/36: extract isJSPWikiPermission to PermissionChecks class in order to break some class cycles

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 b7597bf5a5e514aa39dbf977501b70765d31b6c8
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 14:33:26 2020 +0100

    extract isJSPWikiPermission to PermissionChecks class in order to break some class cycles
---
 .../wiki/auth/permissions/AllPermission.java       | 111 ++++++++-------------
 .../auth/permissions/AllPermissionCollection.java  |  14 +--
 .../wiki/auth/permissions/PermissionChecks.java    |  42 ++++++++
 3 files changed, 91 insertions(+), 76 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/AllPermission.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/AllPermission.java
index 3ebfda0..2096f6a 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/AllPermission.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/AllPermission.java
@@ -28,78 +28,72 @@ import java.security.PermissionCollection;
  * </p>
  * @since 2.3.80
  */
-public final class AllPermission extends Permission implements Serializable
-{
-    private static final long   serialVersionUID = 1L;
+public final class AllPermission extends Permission implements Serializable {
 
-    private static final String WILDCARD         = "*";
+    private static final long serialVersionUID = 1L;
 
-    private final String        m_wiki;
+    private static final String WILDCARD = "*";
+
+    private final String m_wiki;
 
     /** For serialization purposes. */
-    protected AllPermission()
-    {
-        this(null);
+    protected AllPermission() {
+        this( null );
     }
-    
+
     /**
      * Creates a new AllPermission for the given wikis.
-     * 
+     *
      * @param wiki the wiki to which the permission should apply.  If null, will
      *             apply to all wikis.
      */
-    public AllPermission( String wiki )
-    {
+    public AllPermission( final String wiki ) {
         super( wiki );
         m_wiki = ( wiki == null ) ? WILDCARD : wiki;
     }
 
     /**
      * Two AllPermission objects are considered equal if their wikis are equal.
-     * @see java.lang.Object#equals(java.lang.Object)
-     * 
-     * @return {@inheritDoc}
+     *
      * @param obj {@inheritDoc}
+     * @return {@inheritDoc}
+     * @see java.lang.Object#equals(java.lang.Object)
      */
-    public boolean equals( Object obj )
-    {
-        if ( !( obj instanceof AllPermission ) )
-        {
+    public boolean equals( final Object obj ) {
+        if( !( obj instanceof AllPermission ) ) {
             return false;
         }
-        AllPermission p = (AllPermission) obj;
+        final AllPermission p = ( AllPermission )obj;
         return p.m_wiki != null && p.m_wiki.equals( m_wiki );
     }
 
     /**
      * No-op; always returns <code>null</code>
-     * @see java.security.Permission#getActions()
      *
      * @return Always null.
+     * @see java.security.Permission#getActions()
      */
-    public String getActions()
-    {
+    public String getActions() {
         return null;
     }
 
     /**
      * Returns the name of the wiki containing the page represented by this
      * permission; may return the wildcard string.
+     *
      * @return The wiki
      */
-    public String getWiki()
-    {
+    public String getWiki() {
         return m_wiki;
     }
 
     /**
      * Returns the hash code for this WikiPermission.
-     * @see java.lang.Object#hashCode()
-     * 
+     *
      * @return {@inheritDoc}
+     * @see java.lang.Object#hashCode()
      */
-    public int hashCode()
-    {
+    public int hashCode() {
         return m_wiki.hashCode();
     }
 
@@ -108,35 +102,29 @@ public final class AllPermission extends Permission implements Serializable
      * types are implied. One WikiPermission implies another if all of the other
      * WikiPermission's actions are equal to, or a subset of, those for this
      * permission.
+     *
      * @param permission the permission which may (or may not) be implied by
-     *            this instance
+     *                   this instance
      * @return <code>true</code> if the permission is implied,
-     *         <code>false</code> otherwise
+     * <code>false</code> otherwise
      * @see java.security.Permission#implies(java.security.Permission)
      */
-    public boolean implies( Permission permission )
-    {
+    public boolean implies( final Permission permission ) {
         // Permission must be a JSPWiki permission, PagePermission or AllPermission
-        if ( !isJSPWikiPermission( permission ) )
-        {
+        if( !PermissionChecks.isJSPWikiPermission( permission ) ) {
             return false;
         }
         String wiki = null;
-        if ( permission instanceof AllPermission )
-        {
-            wiki = ( (AllPermission) permission ).getWiki();
+        if( permission instanceof AllPermission ) {
+            wiki = ( ( AllPermission )permission ).getWiki();
+        } else if( permission instanceof PagePermission ) {
+            wiki = ( ( PagePermission )permission ).getWiki();
         }
-        else if ( permission instanceof PagePermission )
-        {
-            wiki = ( (PagePermission) permission ).getWiki();
+        if( permission instanceof WikiPermission ) {
+            wiki = ( ( WikiPermission )permission ).getWiki();
         }
-        if ( permission instanceof WikiPermission )
-        {
-            wiki = ( (WikiPermission) permission ).getWiki();
-        }
-        if ( permission instanceof GroupPermission )
-        {
-            wiki = ( (GroupPermission) permission ).getWiki();
+        if( permission instanceof GroupPermission ) {
+            wiki = ( ( GroupPermission )permission ).getWiki();
         }
 
         // If the wiki is implied, it's allowed
@@ -145,37 +133,22 @@ public final class AllPermission extends Permission implements Serializable
 
     /**
      * Returns a new {@link AllPermissionCollection}.
-     * @see java.security.Permission#newPermissionCollection()
-     * 
+     *
      * @return {@inheritDoc}
+     * @see java.security.Permission#newPermissionCollection()
      */
-    public PermissionCollection newPermissionCollection()
-    {
+    public PermissionCollection newPermissionCollection() {
         return new AllPermissionCollection();
     }
 
     /**
      * Prints a human-readable representation of this permission.
-     * @see java.lang.Object#toString()
+     *
      * @return {@inheritDoc}
+     * @see java.lang.Object#toString()
      */
-    public String toString()
-    {
+    public String toString() {
         return "(\"" + this.getClass().getName() + "\",\"" + m_wiki + "\")";
     }
 
-    /**
-     *  Checks if the given permission is one of ours.
-     *  
-     *  @param permission Permission to check
-     *  @return true, if the permission is a JSPWiki permission; false otherwise.
-     */
-    protected static boolean isJSPWikiPermission( Permission permission )
-    {
-        return   permission instanceof WikiPermission ||
-                 permission instanceof PagePermission ||
-                 permission instanceof GroupPermission ||
-                 permission instanceof AllPermission;
-    }
-
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/AllPermissionCollection.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/AllPermissionCollection.java
index 2af45cb..965a1fd 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/AllPermissionCollection.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/AllPermissionCollection.java
@@ -35,7 +35,7 @@ public class AllPermissionCollection extends PermissionCollection
 
     private boolean           m_readOnly      = false;
 
-    protected final Hashtable<Permission, Permission> m_permissions    = new Hashtable<Permission, Permission>();
+    protected final Hashtable<Permission, Permission> m_permissions    = new Hashtable<>();
 
     /**
      * Adds an AllPermission object to this AllPermissionCollection. If this
@@ -47,9 +47,9 @@ public class AllPermissionCollection extends PermissionCollection
      * @param permission {@inheritDoc}
      */
     @Override
-    public void add( Permission permission )
+    public void add( final Permission permission )
     {
-        if ( !AllPermission.isJSPWikiPermission( permission ) )
+        if ( !PermissionChecks.isJSPWikiPermission( permission ) )
         {
             throw new IllegalArgumentException(
                     "Permission must be of type org.apache.wiki.permissions.*Permission." );
@@ -96,7 +96,7 @@ public class AllPermissionCollection extends PermissionCollection
      * 
      * @return {@inheritDoc}
      */
-    public boolean implies( Permission permission )
+    public boolean implies( final Permission permission )
     {
         // If nothing in the collection yet, fail fast
         if ( !m_notEmpty )
@@ -105,16 +105,16 @@ public class AllPermissionCollection extends PermissionCollection
         }
 
         // If not one of our permission types, it's not implied
-        if ( !AllPermission.isJSPWikiPermission( permission ) )
+        if ( !PermissionChecks.isJSPWikiPermission( permission ) )
         {
             return false;
         }
 
         // Step through each AllPermission
-        Enumeration<Permission> permEnum = m_permissions.elements();
+        final Enumeration<Permission> permEnum = m_permissions.elements();
         while( permEnum.hasMoreElements() )
         {
-            Permission storedPermission = permEnum.nextElement();
+            final Permission storedPermission = permEnum.nextElement();
             if ( storedPermission.implies( permission ) )
             {
                 return true;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/PermissionChecks.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/PermissionChecks.java
new file mode 100644
index 0000000..7eceb96
--- /dev/null
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/permissions/PermissionChecks.java
@@ -0,0 +1,42 @@
+/*
+    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.auth.permissions;
+
+import java.security.Permission;
+
+
+/**
+ * Ususal permission checks
+ */
+class PermissionChecks {
+
+    /**
+     *  Checks if the given permission is one of ours.
+     *
+     *  @param permission Permission to check
+     *  @return true, if the permission is a JSPWiki permission; false otherwise.
+     */
+    static boolean isJSPWikiPermission( final Permission permission ) {
+        return permission instanceof WikiPermission  ||
+               permission instanceof PagePermission  ||
+               permission instanceof GroupPermission ||
+               permission instanceof AllPermission;
+    }
+
+}


[jspwiki] 34/36: Extract interface + rename from RSSGenerator

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 078122f6a54a3cdc87f2fcfe6204c7ff4927cd1c
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Mar 21 17:47:42 2020 +0100

    Extract interface + rename from RSSGenerator
---
 ...{RSSGenerator.java => DefaultRSSGenerator.java} | 195 ++--------
 .../java/org/apache/wiki/rss/RSSGenerator.java     | 431 +++------------------
 .../src/main/resources/ini/classmappings.xml       |   4 +
 3 files changed, 96 insertions(+), 534 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/DefaultRSSGenerator.java
similarity index 65%
copy from jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
copy to jspwiki-main/src/main/java/org/apache/wiki/rss/DefaultRSSGenerator.java
index 9b0e621..889484f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/DefaultRSSGenerator.java
@@ -43,25 +43,16 @@ import java.util.List;
 import java.util.Properties;
 import java.util.Set;
 
+
 /**
- *  The master class for generating different kinds of Feeds (including RSS1.0, 2.0 and Atom).
- *  <p>
- *  This class can produce quite a few different styles of feeds.  The following modes are available:
- *  
- *  <ul>
- *  <li><b>wiki</b> - All the changes to the given page are enumerated and announced as diffs.</li>
- *  <li><b>full</b> - Each page is only considered once.  This produces a very RecentChanges-style feed,
- *                   where each page is only listed once, even if it has changed multiple times.</li>
- *  <li><b>blog</b> - Each page change is assumed to be a blog entry, so no diffs are produced, but
- *                    the page content is always completely in the entry in rendered HTML.</li>
+ * Default implementation for {@link RSSGenerator}.
  *
- *  @since  1.7.5.
+ * {@inheritDoc}
  */
 // FIXME: Limit diff and page content size.
-// FIXME3.0: This class would need a bit of refactoring.  Method names, e.g. are confusing.
-public class RSSGenerator {
+public class DefaultRSSGenerator implements RSSGenerator {
 
-    private static final Logger log = Logger.getLogger( RSSGenerator.class );
+    private static final Logger log = Logger.getLogger( DefaultRSSGenerator.class );
     private Engine m_engine;
 
     /** The RSS file to generate. */
@@ -70,84 +61,23 @@ public class RSSGenerator {
     private String m_channelLanguage = "en-us";
     private boolean m_enabled = true;
 
-    /** Parameter value to represent RSS 1.0 feeds.  Value is <tt>{@value}</tt>. */
-    public static final String RSS10 = "rss10";
-
-    /** Parameter value to represent RSS 2.0 feeds.  Value is <tt>{@value}</tt>. */
-    public static final String RSS20 = "rss20";
-    
-    /** Parameter value to represent Atom feeds.  Value is <tt>{@value}</tt>.  */
-    public static final String ATOM  = "atom";
-
-    /** Parameter value to represent a 'blog' style feed. Value is <tt>{@value}</tt>. */
-    public static final String MODE_BLOG = "blog";
-    
-    /** Parameter value to represent a 'wiki' style feed. Value is <tt>{@value}</tt>. */
-    public static final String MODE_WIKI = "wiki";
-
-    /** Parameter value to represent a 'full' style feed. Value is <tt>{@value}</tt>. */
-    public static final String MODE_FULL = "full";
-
-    /**
-     *  Defines the property name for the RSS channel description.  Default value for the channel description is an empty string.
-     *  @since 1.7.6.
-     */
-    public static final String PROP_CHANNEL_DESCRIPTION = "jspwiki.rss.channelDescription";
-
-    /**
-     *  Defines the property name for the RSS channel language.  Default value for the language is "en-us".
-     *  @since 1.7.6.
-     */
-    public static final String PROP_CHANNEL_LANGUAGE = "jspwiki.rss.channelLanguage";
-
-    /** Defines the property name for the RSS channel title.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_CHANNEL_TITLE = "jspwiki.rss.channelTitle";
-
-    /**
-     *  Defines the property name for the RSS generator main switch.
-     *  @since 1.7.6.
-     */
-    public static final String PROP_GENERATE_RSS = "jspwiki.rss.generate";
-
-    /**
-     *  Defines the property name for the RSS file that the wiki should generate.
-     *  @since 1.7.6.
-     */
-    public static final String PROP_RSSFILE = "jspwiki.rss.fileName";
-
-    /**
-     *  Defines the property name for the RSS generation interval in seconds.
-     *  @since 1.7.6.
-     */
-    public static final String PROP_INTERVAL = "jspwiki.rss.interval";
-
-    /** Defines the property name for the RSS author.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_RSS_AUTHOR = "jspwiki.rss.author";
-
-    /** Defines the property name for the RSS author email.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_RSS_AUTHOREMAIL = "jspwiki.rss.author.email";
-
     private static final int MAX_CHARACTERS = Integer.MAX_VALUE-1;
 
     /**
-     *  Initialize the RSS generator for a given Engine.
+     *  Builds the RSS generator for a given Engine.
      *
      *  @param engine The Engine.
      *  @param properties The properties.
      */
-    public RSSGenerator( final Engine engine, final Properties properties ) {
+    public DefaultRSSGenerator( 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 );
-        m_rssFile = TextUtil.getStringProperty( properties, RSSGenerator.PROP_RSSFILE, "rss.rdf" );
+        m_rssFile = TextUtil.getStringProperty( properties, DefaultRSSGenerator.PROP_RSSFILE, "rss.rdf" );
     }
 
-    /**
-     * Start the RSS generator & generator thread
-     *
-     * @param engine the engine
-     * @param properties the properties
-     */
+    /** {@inheritDoc} */
+    @Override
     public void initialize( final Engine engine, final Properties properties ) {
         final File rssFile;
         if( m_rssFile.startsWith( File.separator ) ) { // honor absolute pathnames
@@ -155,26 +85,11 @@ public class RSSGenerator {
         } else { // relative path names are anchored from the webapp root path
             rssFile = new File( engine.getRootPath(), m_rssFile );
         }
-        final int rssInterval = TextUtil.getIntegerProperty( properties, RSSGenerator.PROP_INTERVAL, 3600 );
+        final int rssInterval = TextUtil.getIntegerProperty( properties, DefaultRSSGenerator.PROP_INTERVAL, 3600 );
         final RSSThread rssThread = new RSSThread( engine, rssFile, rssInterval );
         rssThread.start();
     }
 
-    /**
-     *  Does the required formatting and entity replacement for XML.
-     *  
-     *  @param s String to format.
-     *  @return A formatted string.
-     */
-    // FIXME: Replicates Feed.format().
-    public static String format( String s ) {
-        s = TextUtil.replaceString( s, "&", "&amp;" );
-        s = TextUtil.replaceString( s, "<", "&lt;" );
-        s = TextUtil.replaceString( s, "]]>", "]]&gt;" );
-
-        return s.trim();
-    }
-
     private String getAuthor( final Page page ) {
         String author = page.getAuthor();
         if( author == null ) {
@@ -240,11 +155,8 @@ public class RSSGenerator {
         return page.getName() + ", version " + page.getVersion();
     }
 
-    /**
-     *  Generates the RSS resource.  You probably want to output this result into a file or something, or serve as output from a servlet.
-     *  
-     *  @return A RSS 1.0 feed in the "full" mode.
-     */
+    /** {@inheritDoc} */
+    @Override
     public String generate() {
         final WikiContext context = new WikiContext( m_engine, new WikiPage( m_engine, "__DUMMY" ) );
         context.setRequestContext( WikiContext.RSS );
@@ -252,33 +164,8 @@ public class RSSGenerator {
         return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + generateFullWikiRSS( context, feed );
     }
 
-    /**
-     * Returns the content type of this RSS feed.
-     *
-     * @since 2.3.15
-     * @param mode the RSS mode: {@link #RSS10}, {@link #RSS20} or {@link #ATOM}.
-     * @return the content type
-     */
-    public static String getContentType( final String mode ) {
-        if( mode.equals( RSS10 ) || mode.equals( RSS20 ) ) {
-            return "application/rss+xml";
-        } else if( mode.equals( ATOM ) ) {
-            return "application/atom+xml";
-        }
-
-        return "application/octet-stream"; // Unknown type
-    }
-
-    /**
-     * Generates a feed based on a context and list of changes.
-     *
-     * @param wikiContext The WikiContext
-     * @param changed A list of Entry objects
-     * @param mode The mode (wiki/blog)
-     * @param type The type (RSS10, RSS20, ATOM).  Default is RSS 1.0
-     * @return Fully formed XML.
-     * @throws IllegalArgumentException If an illegal mode is given.
-     */
+    /** {@inheritDoc} */
+    @Override
     public String generateFeed( final Context wikiContext, final List< Page > changed, final String mode, final String type ) throws IllegalArgumentException {
         final Feed feed;
         final String res;
@@ -306,37 +193,27 @@ public class RSSGenerator {
         return res;
     }
 
-    /**
-     * Returns <code>true</code> if RSS generation is enabled.
-     *
-     * @return whether RSS generation is currently enabled
-     */
+    /** {@inheritDoc} */
+    @Override
     public boolean isEnabled() {
         return m_enabled;
     }
 
-    /**
-     * Turns RSS generation on or off. This setting is used to set the "enabled" flag only for use by callers, and does not
-     * actually affect whether the {@link #generate()} or {@link #generateFeed(Context, List, String, String)} methods output anything.
-     *
-     * @param enabled whether RSS generation is considered enabled.
-     */
+    /** {@inheritDoc} */
+    @Override
     public synchronized void setEnabled( final boolean enabled ) {
         m_enabled = enabled;
     }
 
+    /** {@inheritDoc} */
+    @Override
     public String getRssFile() {
         return m_rssFile;
     }
 
-    /**
-     *  Generates an RSS feed for the entire wiki.  Each item should be an instance of the RSSItem class.
-     *  
-     *  @param wikiContext A WikiContext
-     *  @param feed A Feed to generate the feed to.
-     *  @return feed.getString().
-     */
-    protected String generateFullWikiRSS( final Context wikiContext, final Feed feed ) {
+    /** {@inheritDoc} */
+    @Override
+    public String generateFullWikiRSS( final Context wikiContext, final Feed feed ) {
         feed.setChannelTitle( m_engine.getApplicationName() );
         feed.setFeedURL( m_engine.getBaseURL() );
         feed.setChannelLanguage( m_channelLanguage );
@@ -375,15 +252,9 @@ public class RSSGenerator {
         return feed.getString();
     }
 
-    /**
-     * Create RSS/Atom as if this page was a wikipage (in contrast to Blog mode).
-     *
-     * @param wikiContext The WikiContext
-     * @param changed A List of changed WikiPages.
-     * @param feed A Feed object to fill.
-     * @return the RSS representation of the wiki context
-     */
-    protected String generateWikiPageRSS( final Context wikiContext, final List< Page > changed, final Feed feed ) {
+    /** {@inheritDoc} */
+    @Override
+    public String generateWikiPageRSS( final Context wikiContext, final List< Page > changed, final Feed feed ) {
         feed.setChannelTitle( m_engine.getApplicationName()+": "+wikiContext.getPage().getName() );
         feed.setFeedURL( wikiContext.getViewURL( wikiContext.getPage().getName() ) );
         final String language = m_engine.getManager( VariableManager.class ).getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
@@ -428,15 +299,9 @@ public class RSSGenerator {
     }
 
 
-    /**
-     *  Creates RSS from modifications as if this page was a blog (using the WeblogPlugin).
-     *
-     *  @param wikiContext The WikiContext, as usual.
-     *  @param changed A list of the changed pages.
-     *  @param feed A valid Feed object.  The feed will be used to create the RSS/Atom, depending on which kind of an object you want to put in it.
-     *  @return A String of valid RSS or Atom.
-     */
-    protected String generateBlogRSS( final Context wikiContext, final List< Page > changed, final Feed feed ) {
+    /** {@inheritDoc} */
+    @Override
+    public String generateBlogRSS( final Context wikiContext, final List< Page > changed, final Feed feed ) {
         if( log.isDebugEnabled() ) {
             log.debug( "Generating RSS for blog, size=" + changed.size() );
         }
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 9b0e621..e44a7ff 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
@@ -18,30 +18,13 @@
  */
 package org.apache.wiki.rss;
 
-import org.apache.log4j.Logger;
-import org.apache.wiki.WikiContext;
-import org.apache.wiki.WikiPage;
-import org.apache.wiki.WikiSession;
 import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Engine;
 import org.apache.wiki.api.core.Page;
-import org.apache.wiki.api.core.Session;
-import org.apache.wiki.api.providers.WikiProvider;
-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.io.File;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
-import java.util.Set;
 
 /**
  *  The master class for generating different kinds of Feeds (including RSS1.0, 2.0 and Atom).
@@ -57,90 +40,69 @@ import java.util.Set;
  *
  *  @since  1.7.5.
  */
-// FIXME: Limit diff and page content size.
-// FIXME3.0: This class would need a bit of refactoring.  Method names, e.g. are confusing.
-public class RSSGenerator {
-
-    private static final Logger log = Logger.getLogger( RSSGenerator.class );
-    private Engine m_engine;
-
-    /** The RSS file to generate. */
-    private String m_rssFile;
-    private String m_channelDescription = "";
-    private String m_channelLanguage = "en-us";
-    private boolean m_enabled = true;
+public interface RSSGenerator {
 
     /** Parameter value to represent RSS 1.0 feeds.  Value is <tt>{@value}</tt>. */
-    public static final String RSS10 = "rss10";
+    String RSS10 = "rss10";
 
     /** Parameter value to represent RSS 2.0 feeds.  Value is <tt>{@value}</tt>. */
-    public static final String RSS20 = "rss20";
+    String RSS20 = "rss20";
     
     /** Parameter value to represent Atom feeds.  Value is <tt>{@value}</tt>.  */
-    public static final String ATOM  = "atom";
+    String ATOM  = "atom";
 
     /** Parameter value to represent a 'blog' style feed. Value is <tt>{@value}</tt>. */
-    public static final String MODE_BLOG = "blog";
+    String MODE_BLOG = "blog";
     
     /** Parameter value to represent a 'wiki' style feed. Value is <tt>{@value}</tt>. */
-    public static final String MODE_WIKI = "wiki";
+    String MODE_WIKI = "wiki";
 
     /** Parameter value to represent a 'full' style feed. Value is <tt>{@value}</tt>. */
-    public static final String MODE_FULL = "full";
+    String MODE_FULL = "full";
 
     /**
      *  Defines the property name for the RSS channel description.  Default value for the channel description is an empty string.
+     *
      *  @since 1.7.6.
      */
-    public static final String PROP_CHANNEL_DESCRIPTION = "jspwiki.rss.channelDescription";
+    String PROP_CHANNEL_DESCRIPTION = "jspwiki.rss.channelDescription";
 
     /**
      *  Defines the property name for the RSS channel language.  Default value for the language is "en-us".
+     *
      *  @since 1.7.6.
      */
-    public static final String PROP_CHANNEL_LANGUAGE = "jspwiki.rss.channelLanguage";
+    String PROP_CHANNEL_LANGUAGE = "jspwiki.rss.channelLanguage";
 
     /** Defines the property name for the RSS channel title.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_CHANNEL_TITLE = "jspwiki.rss.channelTitle";
+    String PROP_CHANNEL_TITLE = "jspwiki.rss.channelTitle";
 
     /**
      *  Defines the property name for the RSS generator main switch.
+     *
      *  @since 1.7.6.
      */
-    public static final String PROP_GENERATE_RSS = "jspwiki.rss.generate";
+    String PROP_GENERATE_RSS = "jspwiki.rss.generate";
 
     /**
      *  Defines the property name for the RSS file that the wiki should generate.
+     *
      *  @since 1.7.6.
      */
-    public static final String PROP_RSSFILE = "jspwiki.rss.fileName";
+    String PROP_RSSFILE = "jspwiki.rss.fileName";
 
     /**
      *  Defines the property name for the RSS generation interval in seconds.
+     *
      *  @since 1.7.6.
      */
-    public static final String PROP_INTERVAL = "jspwiki.rss.interval";
+    String PROP_INTERVAL = "jspwiki.rss.interval";
 
     /** Defines the property name for the RSS author.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_RSS_AUTHOR = "jspwiki.rss.author";
+    String PROP_RSS_AUTHOR = "jspwiki.rss.author";
 
     /** Defines the property name for the RSS author email.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_RSS_AUTHOREMAIL = "jspwiki.rss.author.email";
-
-    private static final int MAX_CHARACTERS = Integer.MAX_VALUE-1;
-
-    /**
-     *  Initialize the RSS generator for a given Engine.
-     *
-     *  @param engine The Engine.
-     *  @param properties The 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 );
-        m_rssFile = TextUtil.getStringProperty( properties, RSSGenerator.PROP_RSSFILE, "rss.rdf" );
-    }
+    String PROP_RSS_AUTHOREMAIL = "jspwiki.rss.author.email";
 
     /**
      * Start the RSS generator & generator thread
@@ -148,126 +110,14 @@ public class RSSGenerator {
      * @param engine the engine
      * @param properties the properties
      */
-    public void initialize( final Engine engine, final Properties properties ) {
-        final File rssFile;
-        if( m_rssFile.startsWith( File.separator ) ) { // honor absolute pathnames
-            rssFile = new File( m_rssFile );
-        } else { // relative path names are anchored from the webapp root path
-            rssFile = new File( engine.getRootPath(), m_rssFile );
-        }
-        final int rssInterval = TextUtil.getIntegerProperty( properties, RSSGenerator.PROP_INTERVAL, 3600 );
-        final RSSThread rssThread = new RSSThread( engine, rssFile, rssInterval );
-        rssThread.start();
-    }
-
-    /**
-     *  Does the required formatting and entity replacement for XML.
-     *  
-     *  @param s String to format.
-     *  @return A formatted string.
-     */
-    // FIXME: Replicates Feed.format().
-    public static String format( String s ) {
-        s = TextUtil.replaceString( s, "&", "&amp;" );
-        s = TextUtil.replaceString( s, "<", "&lt;" );
-        s = TextUtil.replaceString( s, "]]>", "]]&gt;" );
-
-        return s.trim();
-    }
-
-    private String getAuthor( final Page page ) {
-        String author = page.getAuthor();
-        if( author == null ) {
-            author = "An unknown author";
-        }
-
-        return author;
-    }
-
-    private String getAttachmentDescription( final Attachment att ) {
-        final String author = getAuthor( att );
-        final StringBuilder sb = new StringBuilder();
-
-        if( att.getVersion() != 1 ) {
-            sb.append( author ).append( " uploaded a new version of this attachment on " ).append( att.getLastModified() );
-        } else {
-            sb.append( author ).append( " created this attachment on " ).append( att.getLastModified() );
-        }
-
-        sb.append( "<br /><hr /><br />" )
-          .append( "Parent page: <a href=\"" )
-          .append( m_engine.getURL( WikiContext.VIEW, att.getParentName(), null ) )
-          .append( "\">" ).append( att.getParentName() ).append( "</a><br />" )
-          .append( "Info page: <a href=\"" )
-          .append( m_engine.getURL( WikiContext.INFO, att.getName(), null ) )
-          .append( "\">" ).append( att.getName() ).append( "</a>" );
-
-        return sb.toString();
-    }
-
-    private String getPageDescription( final Page page ) {
-        final StringBuilder buf = new StringBuilder();
-        final String author = getAuthor( page );
-        final WikiContext ctx = new WikiContext( m_engine, page );
-        if( page.getVersion() > 1 ) {
-            final String diff = m_engine.getManager( DifferenceManager.class ).getDiff( ctx,
-                                                                page.getVersion() - 1, // FIXME: Will fail when non-contiguous versions
-                                                                         page.getVersion() );
-
-            buf.append( author ).append( " changed this page on " ).append( page.getLastModified() ).append( ":<br /><hr /><br />" );
-            buf.append( diff );
-        } else {
-            buf.append( author ).append( " created this page on " ).append( page.getLastModified() ).append( ":<br /><hr /><br />" );
-            buf.append( m_engine.getManager( RenderingManager.class ).getHTML( page.getName() ) );
-        }
-
-        return buf.toString();
-    }
-
-    private String getEntryDescription( final Page page ) {
-        final String res;
-        if( page instanceof Attachment ) {
-            res = getAttachmentDescription( (Attachment)page );
-        } else {
-            res = getPageDescription( page );
-        }
-
-        return res;
-    }
-
-    // FIXME: This should probably return something more intelligent
-    private String getEntryTitle( final Page page ) {
-        return page.getName() + ", version " + page.getVersion();
-    }
+    void initialize( Engine engine, Properties properties );
 
     /**
      *  Generates the RSS resource.  You probably want to output this result into a file or something, or serve as output from a servlet.
-     *  
-     *  @return A RSS 1.0 feed in the "full" mode.
-     */
-    public String generate() {
-        final WikiContext context = new WikiContext( m_engine, new WikiPage( m_engine, "__DUMMY" ) );
-        context.setRequestContext( WikiContext.RSS );
-        final Feed feed = new RSS10Feed( context );
-        return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + generateFullWikiRSS( context, feed );
-    }
-
-    /**
-     * Returns the content type of this RSS feed.
      *
-     * @since 2.3.15
-     * @param mode the RSS mode: {@link #RSS10}, {@link #RSS20} or {@link #ATOM}.
-     * @return the content type
+     *  @return A RSS 1.0 feed in the "full" mode.
      */
-    public static String getContentType( final String mode ) {
-        if( mode.equals( RSS10 ) || mode.equals( RSS20 ) ) {
-            return "application/rss+xml";
-        } else if( mode.equals( ATOM ) ) {
-            return "application/atom+xml";
-        }
-
-        return "application/octet-stream"; // Unknown type
-    }
+    String generate();
 
     /**
      * Generates a feed based on a context and list of changes.
@@ -279,41 +129,14 @@ public class RSSGenerator {
      * @return Fully formed XML.
      * @throws IllegalArgumentException If an illegal mode is given.
      */
-    public String generateFeed( final Context wikiContext, final List< Page > changed, final String mode, final String type ) throws IllegalArgumentException {
-        final Feed feed;
-        final String res;
-
-        if( ATOM.equals(type) ) {
-            feed = new AtomFeed( wikiContext );
-        } else if( RSS20.equals( type ) ) {
-            feed = new RSS20Feed( wikiContext );
-        } else {
-            feed = new RSS10Feed( wikiContext );
-        }
-
-        feed.setMode( mode );
-
-        if( MODE_BLOG.equals( mode ) ) {
-            res = generateBlogRSS( wikiContext, changed, feed );
-        } else if( MODE_FULL.equals(mode) ) {
-            res = generateFullWikiRSS( wikiContext, feed );
-        } else if( MODE_WIKI.equals(mode) ) {
-            res = generateWikiPageRSS( wikiContext, changed, feed );
-        } else {
-            throw new IllegalArgumentException( "Invalid value for feed mode: "+mode );
-        }
-
-        return res;
-    }
+    String generateFeed( final Context wikiContext, final List< Page > changed, final String mode, final String type ) throws IllegalArgumentException;
 
     /**
      * Returns <code>true</code> if RSS generation is enabled.
      *
      * @return whether RSS generation is currently enabled
      */
-    public boolean isEnabled() {
-        return m_enabled;
-    }
+    boolean isEnabled();
 
     /**
      * Turns RSS generation on or off. This setting is used to set the "enabled" flag only for use by callers, and does not
@@ -321,59 +144,23 @@ public class RSSGenerator {
      *
      * @param enabled whether RSS generation is considered enabled.
      */
-    public synchronized void setEnabled( final boolean enabled ) {
-        m_enabled = enabled;
-    }
+    void setEnabled( final boolean enabled );
 
-    public String getRssFile() {
-        return m_rssFile;
-    }
+    /**
+     * returns the rss file.
+     *
+     * @return the rss file.
+     */
+    String getRssFile();
 
     /**
      *  Generates an RSS feed for the entire wiki.  Each item should be an instance of the RSSItem class.
-     *  
+     *
      *  @param wikiContext A WikiContext
      *  @param feed A Feed to generate the feed to.
      *  @return feed.getString().
      */
-    protected String generateFullWikiRSS( final Context wikiContext, final Feed feed ) {
-        feed.setChannelTitle( m_engine.getApplicationName() );
-        feed.setFeedURL( m_engine.getBaseURL() );
-        feed.setChannelLanguage( m_channelLanguage );
-        feed.setChannelDescription( m_channelDescription );
-
-        final Set< Page > changed = m_engine.getManager( PageManager.class ).getRecentChanges();
-
-        final Session session = WikiSession.guestSession( m_engine );
-        int items = 0;
-        for( final Iterator< Page > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
-            final Page page = i.next();
-
-            //  Check if the anonymous user has view access to this page.
-            if( !m_engine.getManager( AuthorizationManager.class ).checkPermission(session, new PagePermission(page,PagePermission.VIEW_ACTION) ) ) {
-                // No permission, skip to the next one.
-                continue;
-            }
-
-            final String url;
-            if( page instanceof Attachment ) {
-                url = m_engine.getURL( WikiContext.ATTACH, page.getName(),null );
-            } else {
-                url = m_engine.getURL( WikiContext.VIEW, page.getName(), null );
-            }
-
-            final Entry e = new Entry();
-            e.setPage( page );
-            e.setURL( url );
-            e.setTitle( page.getName() );
-            e.setContent( getEntryDescription(page) );
-            e.setAuthor( getAuthor(page) );
-
-            feed.addEntry( e );
-        }
-
-        return feed.getString();
-    }
+    String generateFullWikiRSS( Context wikiContext, Feed feed );
 
     /**
      * Create RSS/Atom as if this page was a wikipage (in contrast to Blog mode).
@@ -383,50 +170,7 @@ public class RSSGenerator {
      * @param feed A Feed object to fill.
      * @return the RSS representation of the wiki context
      */
-    protected String generateWikiPageRSS( final Context wikiContext, final List< Page > changed, final Feed feed ) {
-        feed.setChannelTitle( m_engine.getApplicationName()+": "+wikiContext.getPage().getName() );
-        feed.setFeedURL( wikiContext.getViewURL( wikiContext.getPage().getName() ) );
-        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.getManager( VariableManager.class ).getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
-
-        if( channelDescription != null ) {
-            feed.setChannelDescription( channelDescription );
-        }
-
-        changed.sort( new PageTimeComparator() );
-
-        int items = 0;
-        for( final Iterator< Page > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
-            final Page page = i.next();
-            final Entry e = new Entry();
-            e.setPage( page );
-            String url;
-
-            if( page instanceof Attachment ) {
-                url = m_engine.getURL( WikiContext.ATTACH, page.getName(), "version=" + page.getVersion() );
-            } else {
-                url = m_engine.getURL( WikiContext.VIEW, page.getName(), "version=" + page.getVersion() );
-            }
-
-            // Unfortunately, this is needed because the code will again go through replacement conversion
-            url = TextUtil.replaceString( url, "&amp;", "&" );
-            e.setURL( url );
-            e.setTitle( getEntryTitle(page) );
-            e.setContent( getEntryDescription(page) );
-            e.setAuthor( getAuthor(page) );
-
-            feed.addEntry( e );
-        }
-
-        return feed.getString();
-    }
-
+    String generateWikiPageRSS( Context wikiContext, List< Page > changed, Feed feed );
 
     /**
      *  Creates RSS from modifications as if this page was a blog (using the WeblogPlugin).
@@ -436,89 +180,38 @@ public class RSSGenerator {
      *  @param feed A valid Feed object.  The feed will be used to create the RSS/Atom, depending on which kind of an object you want to put in it.
      *  @return A String of valid RSS or Atom.
      */
-    protected String generateBlogRSS( final Context wikiContext, final List< Page > changed, final Feed feed ) {
-        if( log.isDebugEnabled() ) {
-            log.debug( "Generating RSS for blog, size=" + changed.size() );
-        }
-
-        final String ctitle = m_engine.getManager( VariableManager.class ).getVariable( wikiContext, PROP_CHANNEL_TITLE );
-        if( ctitle != null ) {
-            feed.setChannelTitle( ctitle );
-        } else {
-            feed.setChannelTitle( m_engine.getApplicationName() + ":" + wikiContext.getPage().getName() );
-        }
-
-        feed.setFeedURL( wikiContext.getViewURL( wikiContext.getPage().getName() ) );
+    String generateBlogRSS( Context wikiContext, List< Page > changed, Feed feed );
 
-        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.getManager( VariableManager.class ).getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
-        if( channelDescription != null ) {
-            feed.setChannelDescription( channelDescription );
-        }
-
-        changed.sort( new PageTimeComparator() );
-
-        int items = 0;
-        for( final Iterator< Page > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
-            final Page page = i.next();
-            final Entry e = new Entry();
-            e.setPage( page );
-            final String url;
-
-            if( page instanceof Attachment ) {
-                url = m_engine.getURL( WikiContext.ATTACH, page.getName(),null );
-            } else {
-                url = m_engine.getURL( WikiContext.VIEW, page.getName(),null );
-            }
-
-            e.setURL( url );
-
-            //  Title
-            String pageText = m_engine.getManager( PageManager.class ).getPureText( page.getName(), WikiProvider.LATEST_VERSION );
-
-            String title = "";
-            final int firstLine = pageText.indexOf('\n');
-
-            if( firstLine > 0 ) {
-                title = pageText.substring( 0, firstLine ).trim();
-            }
-
-            if( title.length() == 0 ) {
-                title = page.getName();
-            }
-
-            // Remove wiki formatting
-            while( title.startsWith("!") ) {
-                title = title.substring(1);
-            }
+    /**
+     *  Does the required formatting and entity replacement for XML.
+     *  
+     *  @param s String to format.
+     *  @return A formatted string.
+     */
+    // FIXME: Replicates Feed.format().
+    static String format( String s ) {
+        s = TextUtil.replaceString( s, "&", "&amp;" );
+        s = TextUtil.replaceString( s, "<", "&lt;" );
+        s = TextUtil.replaceString( s, "]]>", "]]&gt;" );
 
-            e.setTitle( title );
+        return s.trim();
+    }
 
-            //  Description
-            if( firstLine > 0 ) {
-                int maxlen = pageText.length();
-                if( maxlen > MAX_CHARACTERS ) {
-                    maxlen = MAX_CHARACTERS;
-                }
-                pageText = m_engine.getManager( RenderingManager.class ).textToHTML( wikiContext, pageText.substring( firstLine + 1, maxlen ).trim() );
-                if( maxlen == MAX_CHARACTERS ) {
-                    pageText += "...";
-                }
-                e.setContent( pageText );
-            } else {
-                e.setContent( title );
-            }
-            e.setAuthor( getAuthor(page) );
-            feed.addEntry( e );
+    /**
+     * Returns the content type of this RSS feed.
+     *
+     * @since 2.3.15
+     * @param mode the RSS mode: {@link #RSS10}, {@link #RSS20} or {@link #ATOM}.
+     * @return the content type
+     */
+    static String getContentType( final String mode ) {
+        if( mode.equals( RSS10 ) || mode.equals( RSS20 ) ) {
+            return "application/rss+xml";
+        } else if( mode.equals( ATOM ) ) {
+            return "application/atom+xml";
         }
 
-        return feed.getString();
+        return "application/octet-stream"; // Unknown type
     }
 
 }
diff --git a/jspwiki-main/src/main/resources/ini/classmappings.xml b/jspwiki-main/src/main/resources/ini/classmappings.xml
index 39927df..6cff675 100644
--- a/jspwiki-main/src/main/resources/ini/classmappings.xml
+++ b/jspwiki-main/src/main/resources/ini/classmappings.xml
@@ -108,6 +108,10 @@
     <mappedClass>org.apache.wiki.render.DefaultRenderingManager</mappedClass>
   </mapping>
   <mapping>
+    <requestedClass>org.apache.wiki.rss.RSSGenerator</requestedClass>
+    <mappedClass>org.apache.wiki.rss.DefaultRSSGenerator</mappedClass>
+  </mapping>
+  <mapping>
     <requestedClass>org.apache.wiki.search.SearchManager</requestedClass>
     <mappedClass>org.apache.wiki.search.DefaultSearchManager</mappedClass>
   </mapping>