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/04/09 12:50:28 UTC

[jspwiki] branch master updated (a829052 -> 5c43566)

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 a829052  (Hopefully) generate Translation status page - No version bump
     new e9c0ab4  JSPWIKI-303: promote RenderingManager#textToHtml( Context, String ) to public API
     new 5c43566  2.11.0-M7-git-18

The 2 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                                       |  7 +++++++
 .../src/main/java/org/apache/wiki/api/Release.java |  2 +-
 .../java/org/apache/wiki/api/engine/RenderApi.java | 24 +++++++++++-----------
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  5 ++++-
 .../org/apache/wiki/render/RenderingManager.java   | 12 ++---------
 .../test/java/org/apache/wiki/WikiEngineTest.java  |  6 +++++-
 6 files changed, 31 insertions(+), 25 deletions(-)
 copy jspwiki-main/src/main/java/org/apache/wiki/StringTransmutator.java => jspwiki-api/src/main/java/org/apache/wiki/api/engine/RenderApi.java (61%)


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

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 5c43566fddffa177949a2e748990d5009d6eb5f4
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Apr 9 14:49:55 2020 +0200

    2.11.0-M7-git-18
---
 ChangeLog.md                                               | 7 +++++++
 jspwiki-api/src/main/java/org/apache/wiki/api/Release.java | 2 +-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/ChangeLog.md b/ChangeLog.md
index d8c3cea..2b502d6 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -17,6 +17,13 @@ specific language governing permissions and limitations
 under the License.
 -->
 
+**2020-04-09  Juan Pablo Santos (juanpablo AT apache DOT org)**
+
+* _2.11.0-M7-git-18_
+
+* [JSPWIKI-303](https://issues.apache.org/jira/browse/JSPWIKI-303): [JSPWiki API](https://jspwiki-wiki.apache.org/Wiki.jsp?page=JSPWikiPublicAPI) library creation
+    * Promote `RenderingManager#textToHtml( Context, String )` to the public API
+
 **2020-03-29  Juan Pablo Santos (juanpablo AT apache DOT org)**
 
 * _2.11.0-M7-git-17_
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 a8718bf..2ff709b 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-17";
+    public static final String     BUILD         = "git-18";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of


[jspwiki] 01/02: JSPWIKI-303: promote RenderingManager#textToHtml( Context, String ) to public API

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 e9c0ab4b2eb0ffc740e1466eec3d1300a58da8b5
Author: juanpablo <ju...@apache.org>
AuthorDate: Thu Apr 9 14:49:19 2020 +0200

    JSPWIKI-303: promote RenderingManager#textToHtml( Context, String ) to public API
---
 .../java/org/apache/wiki/api/engine/RenderApi.java | 40 ++++++++++++++++++++++
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  5 ++-
 .../org/apache/wiki/render/RenderingManager.java   | 12 ++-----
 .../test/java/org/apache/wiki/WikiEngineTest.java  |  6 +++-
 4 files changed, 51 insertions(+), 12 deletions(-)

diff --git a/jspwiki-api/src/main/java/org/apache/wiki/api/engine/RenderApi.java b/jspwiki-api/src/main/java/org/apache/wiki/api/engine/RenderApi.java
new file mode 100644
index 0000000..f45b0d5
--- /dev/null
+++ b/jspwiki-api/src/main/java/org/apache/wiki/api/engine/RenderApi.java
@@ -0,0 +1,40 @@
+/*
+    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.api.engine;
+
+import org.apache.wiki.api.core.Context;
+
+
+/**
+ * <p>Rendering routines that all JSPWiki public API implementations should provide.</p>
+ *
+ * <p>A {@code RenderApi} should be obtained from {@code Engine#getManager( RenderApi.class )}.</p>
+ */
+public interface RenderApi {
+
+    /**
+     *  Converts raw page data to HTML.
+     *
+     *  @param pagedata Raw page data to convert to HTML
+     *  @param context  The WikiContext in which the page is to be rendered
+     *  @return Rendered page text
+     */
+    String textToHTML( Context context, String pagedata );
+
+}
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 478bf6a..4780b90 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -410,7 +410,10 @@ public class WikiEngine implements Engine {
     @Override
     @SuppressWarnings( "unchecked" )
     public < T > T getManager( final Class< T > manager ) {
-        return ( T )managers.get( manager );
+        return ( T )managers.entrySet().stream()
+                                       .filter( e -> manager.isAssignableFrom( e.getKey() ) )
+                                       .map( Map.Entry::getValue )
+                                       .findFirst().orElse( null );
     }
 
     /** {@inheritDoc} */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java b/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
index 36ecc32..48323dc 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/render/RenderingManager.java
@@ -23,6 +23,7 @@ import org.apache.wiki.StringTransmutator;
 import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Page;
 import org.apache.wiki.api.engine.Initializable;
+import org.apache.wiki.api.engine.RenderApi;
 import org.apache.wiki.api.providers.PageProvider;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.modules.InternalModule;
@@ -42,7 +43,7 @@ import java.io.IOException;
  *
  *  @since  2.4
  */
-public interface RenderingManager extends WikiEventListener, InternalModule, Initializable {
+public interface RenderingManager extends RenderApi, WikiEventListener, InternalModule, Initializable {
 
     /** markup parser property. */
     String PROP_PARSER = "jspwiki.renderingManager.markupParser";
@@ -179,15 +180,6 @@ public interface RenderingManager extends WikiEventListener, InternalModule, Ini
     }
 
     /**
-     *  Converts raw page data to HTML.
-     *
-     *  @param pagedata Raw page data to convert to HTML
-     *  @param context  The WikiContext in which the page is to be rendered
-     *  @return Rendered page text
-     */
-    String textToHTML( Context context, String pagedata );
-
-    /**
      *  Helper method for doing the HTML translation.
      *
      *  @param context The WikiContext in which to do the conversion
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 dcfcec5..66fe532 100644
--- a/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
+++ b/jspwiki-main/src/test/java/org/apache/wiki/WikiEngineTest.java
@@ -23,6 +23,7 @@ import net.sf.ehcache.CacheManager;
 import org.apache.wiki.api.core.Attachment;
 import org.apache.wiki.api.core.Context;
 import org.apache.wiki.api.core.Page;
+import org.apache.wiki.api.engine.RenderApi;
 import org.apache.wiki.api.spi.Wiki;
 import org.apache.wiki.attachment.AttachmentManager;
 import org.apache.wiki.content.PageRenamer;
@@ -330,10 +331,13 @@ public class WikiEngineTest {
 
     @Test
     public void testGetManagers() {
+        Assertions.assertNull( m_engine.getManager( String.class ) );
+        Assertions.assertNotNull( m_engine.getManager( RenderApi.class ) );
         Assertions.assertNotNull( m_engine.getManager( PageManager.class ) );
-        Assertions.assertNull( m_engine.getManager( ModuleManager.class ) );
+        Assertions.assertNotNull( m_engine.getManager( ModuleManager.class ) );
 
         Assertions.assertEquals( 0, m_engine.getManagers( String.class ).size() );
+        Assertions.assertEquals( 1, m_engine.getManagers( RenderApi.class ).size() );
         Assertions.assertEquals( 1, m_engine.getManagers( PageManager.class ).size() );
         Assertions.assertEquals( 4, m_engine.getManagers( ModuleManager.class ).size() );
     }