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 2017/08/22 18:12:57 UTC

[01/10] jspwiki git commit: move constants from JSPWikiMarkupParser to MarkupParser

Repository: jspwiki
Updated Branches:
  refs/heads/master 63b708f1f -> 9e29c3c75


move constants from JSPWikiMarkupParser to MarkupParser


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/e72e31dd
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/e72e31dd
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/e72e31dd

Branch: refs/heads/master
Commit: e72e31dd3e9e3c6d9a64556abf43bfdbcbe24208
Parents: 63b708f
Author: juanpablo <ju...@apache.org>
Authored: Tue Aug 22 19:56:21 2017 +0200
Committer: juanpablo <ju...@apache.org>
Committed: Tue Aug 22 19:56:21 2017 +0200

----------------------------------------------------------------------
 .../apache/wiki/parser/JSPWikiMarkupParser.java | 46 --------------------
 .../org/apache/wiki/parser/MarkupParser.java    | 46 ++++++++++++++++++++
 2 files changed, 46 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/e72e31dd/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java b/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
index c63b615..9078d47 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
@@ -78,34 +78,6 @@ import org.jdom2.Verifier;
  */
 public class JSPWikiMarkupParser extends MarkupParser {
 
-    /** The value for anchor element <tt>class</tt> attributes when used
-      * for wiki page (normal) links. The value is "wikipage". */
-    public static final String CLASS_WIKIPAGE = "wikipage";
-
-    /** The value for anchor element <tt>class</tt> attributes when used
-      * for edit page links. The value is "createpage". */
-    public static final String CLASS_EDITPAGE = "createpage";
-
-    /** The value for anchor element <tt>class</tt> attributes when used
-      * for interwiki page links. The value is "interwiki". */
-    public static final String CLASS_INTERWIKI = "interwiki";
-
-    /** The value for anchor element <tt>class</tt> attributes when used
-      * for footnote links. The value is "footnote". */
-    public static final String CLASS_FOOTNOTE = "footnote";
-
-    /** The value for anchor element <tt>class</tt> attributes when used
-      * for footnote links. The value is "footnote". */
-    public static final String CLASS_FOOTNOTE_REF = "footnoteref";
-
-    /** The value for anchor element <tt>class</tt> attributes when used
-      * for external links. The value is "external". */
-    public static final String CLASS_EXTERNAL = "external";
-
-    /** The value for anchor element <tt>class</tt> attributes when used
-      * for attachments. The value is "attachment". */
-    public static final String CLASS_ATTACHMENT = "attachment";
-
     protected static final int              READ          = 0;
     protected static final int              EDIT          = 1;
     protected static final int              EMPTY         = 2;  // Empty message
@@ -162,9 +134,6 @@ public class JSPWikiMarkupParser extends MarkupParser {
     /** If true, all outward attachment info links have a small link image appended. */
     public static final String     PROP_USEATTACHMENTIMAGE = "jspwiki.translatorReader.useAttachmentImage";
 
-    /** If set to "true", all external links are tagged with 'rel="nofollow"' */
-    public static final String     PROP_USERELNOFOLLOW   = "jspwiki.translatorReader.useRelNofollow";
-
     /** If true, then considers CamelCase links as well. */
     private boolean                m_camelCaseLinks      = false;
 
@@ -219,21 +188,6 @@ public class JSPWikiMarkupParser extends MarkupParser {
 
     private static final String CAMELCASE_PATTERN     = "JSPWikiMarkupParser.camelCasePattern";
 
-    private static final String[] CLASS_TYPES =
-    {
-       CLASS_WIKIPAGE,
-       CLASS_EDITPAGE,
-       "",
-       CLASS_FOOTNOTE,
-       CLASS_FOOTNOTE_REF,
-       "",
-       CLASS_EXTERNAL,
-       CLASS_INTERWIKI,
-       CLASS_EXTERNAL,
-       CLASS_WIKIPAGE,
-       CLASS_ATTACHMENT
-    };
-
 
     /**
      *  This Comparator is used to find an external link from c_externalLinks.  It

http://git-wip-us.apache.org/repos/asf/jspwiki/blob/e72e31dd/jspwiki-war/src/main/java/org/apache/wiki/parser/MarkupParser.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/parser/MarkupParser.java b/jspwiki-war/src/main/java/org/apache/wiki/parser/MarkupParser.java
index ec0d28f..1cbac22 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/parser/MarkupParser.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/parser/MarkupParser.java
@@ -91,6 +91,52 @@ public abstract class MarkupParser
 
     private   static final String INLINE_IMAGE_PATTERNS = "JSPWikiMarkupParser.inlineImagePatterns";
 
+    /** If set to "true", all external links are tagged with 'rel="nofollow"' */
+    public static final String     PROP_USERELNOFOLLOW   = "jspwiki.translatorReader.useRelNofollow";
+
+    /** The value for anchor element <tt>class</tt> attributes when used
+     * for wiki page (normal) links. The value is "wikipage". */
+   public static final String CLASS_WIKIPAGE = "wikipage";
+
+   /** The value for anchor element <tt>class</tt> attributes when used
+     * for edit page links. The value is "createpage". */
+   public static final String CLASS_EDITPAGE = "createpage";
+
+   /** The value for anchor element <tt>class</tt> attributes when used
+     * for interwiki page links. The value is "interwiki". */
+   public static final String CLASS_INTERWIKI = "interwiki";
+
+   /** The value for anchor element <tt>class</tt> attributes when used
+     * for footnote links. The value is "footnote". */
+   public static final String CLASS_FOOTNOTE = "footnote";
+
+   /** The value for anchor element <tt>class</tt> attributes when used
+     * for footnote links. The value is "footnote". */
+   public static final String CLASS_FOOTNOTE_REF = "footnoteref";
+
+   /** The value for anchor element <tt>class</tt> attributes when used
+     * for external links. The value is "external". */
+   public static final String CLASS_EXTERNAL = "external";
+
+   /** The value for anchor element <tt>class</tt> attributes when used
+     * for attachments. The value is "attachment". */
+   public static final String CLASS_ATTACHMENT = "attachment";
+
+   public static final String[] CLASS_TYPES =
+   {
+      CLASS_WIKIPAGE,
+      CLASS_EDITPAGE,
+      "",
+      CLASS_FOOTNOTE,
+      CLASS_FOOTNOTE_REF,
+      "",
+      CLASS_EXTERNAL,
+      CLASS_INTERWIKI,
+      CLASS_EXTERNAL,
+      CLASS_WIKIPAGE,
+      CLASS_ATTACHMENT
+   };
+
     /**
      *  Constructs a MarkupParser.  The subclass must call this constructor
      *  to set up the necessary bits and pieces.

[02/10] jspwiki git commit: fix DefaultFilterManager#modules not returning Collection< WikiModuleInfo >, as it was supposed to; extracted helper method to ModuleManager, in order to simplify other modules() implementations

Posted by ju...@apache.org.
fix DefaultFilterManager#modules not returning Collection< WikiModuleInfo >, as it was supposed to; extracted helper method to ModuleManager, in order to simplify other modules() implementations


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/bdc8f683
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/bdc8f683
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/bdc8f683

Branch: refs/heads/master
Commit: bdc8f683c50bf5d36fbb48ce42d13780a71bd59d
Parents: e72e31d
Author: juanpablo <ju...@apache.org>
Authored: Tue Aug 22 19:59:08 2017 +0200
Committer: juanpablo <ju...@apache.org>
Committed: Tue Aug 22 19:59:08 2017 +0200

----------------------------------------------------------------------
 .../wiki/filters/DefaultFilterManager.java      | 82 ++++++++++----------
 .../org/apache/wiki/modules/ModuleManager.java  | 39 +++++++---
 2 files changed, 67 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/bdc8f683/jspwiki-war/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java b/jspwiki-war/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
index 31f551c..b3da1d2 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/filters/DefaultFilterManager.java
@@ -1,4 +1,4 @@
-/* 
+/*
     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
@@ -14,7 +14,7 @@
     "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.  
+    under the License.
  */
 package org.apache.wiki.filters;
 
@@ -29,6 +29,8 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Set;
+import java.util.TreeSet;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.log4j.Logger;
@@ -42,6 +44,7 @@ import org.apache.wiki.event.WikiEventManager;
 import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.modules.ModuleManager;
 import org.apache.wiki.modules.WikiModuleInfo;
+import org.apache.wiki.plugin.DefaultPluginManager.WikiPluginInfo;
 import org.apache.wiki.util.ClassUtil;
 import org.apache.wiki.util.PriorityList;
 import org.apache.wiki.util.XmlUtil;
@@ -57,22 +60,22 @@ import org.jdom2.Element;
  *    <li>Before the page is saved.
  *    <li>After the page has been saved.
  *  </ul>
- * 
+ *
  *  Using page filters allows you to modify the page data on-the-fly, and do things like
  *  adding your own custom WikiMarkup.
- * 
+ *
  *  <p>
  *  The initial page filter configuration is kept in a file called "filters.xml".  The
  *  format is really very simple:
  *  <pre>
  *  <?xml version="1.0"?>
- * 
+ *
  *  <pagefilters>
  *
  *    <filter>
  *      <class>org.apache.wiki.filters.ProfanityFilter</class>
  *    </filter>
- *  
+ *
  *    <filter>
  *      <class>org.apache.wiki.filters.TestFilter</class>
  *
@@ -94,7 +97,7 @@ import org.jdom2.Element;
  *  the PageFilterConfiguration page in the JSPWiki distribution.
  */
 public class DefaultFilterManager extends ModuleManager implements FilterManager {
-	
+
     private PriorityList< PageFilter > m_pageFilters = new PriorityList< PageFilter >();
 
     private Map< String, PageFilterInfo > m_filterClassMap = new HashMap< String, PageFilterInfo >();
@@ -103,7 +106,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
 
     /**
      *  Constructs a new FilterManager object.
-     *  
+     *
      *  @param engine The WikiEngine which owns the FilterManager
      *  @param props Properties to initialize the FilterManager with
      *  @throws WikiException If something goes wrong.
@@ -143,14 +146,14 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
         try
         {
             PageFilterInfo info = m_filterClassMap.get( className );
-            
+
             if( info != null && !checkCompatibility(info) )
             {
                 String msg = "Filter '"+info.getName()+"' not compatible with this version of JSPWiki";
                 log.warn(msg);
                 return;
             }
-            
+
             int priority = 0; // FIXME: Currently fixed.
 
             Class< ? > cl = ClassUtil.findClass( "org.apache.wiki.filters", className );
@@ -187,7 +190,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
 
     /**
      *  Initializes the filters from an XML file.
-     *  
+     *
      *  @param props The list of properties.  Typically jspwiki.properties
      *  @throws WikiException If something goes wrong.
      */
@@ -197,7 +200,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
 
         try {
             registerFilters();
-            
+
             if( m_engine.getServletContext() != null ) {
                 log.debug( "Attempting to locate " + DEFAULT_XMLFILE + " from servlet context." );
                 if( xmlFile == null ) {
@@ -224,12 +227,12 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
             }
 
             if( xmlStream == null ) {
-                log.info( "Cannot find property file for filters (this is okay, expected to find it as: '" + 
-                           ( xmlFile == null ? DEFAULT_XMLFILE : xmlFile ) + 
+                log.info( "Cannot find property file for filters (this is okay, expected to find it as: '" +
+                           ( xmlFile == null ? DEFAULT_XMLFILE : xmlFile ) +
                           "')" );
                 return;
             }
-            
+
             parseConfigFile( xmlStream );
         } catch( IOException e ) {
             log.error("Unable to read property file", e);
@@ -240,7 +243,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
 
     /**
      *  Parses the XML filters configuration file.
-     *  
+     *
      * @param xmlStream stream to parse
      */
     private void parseConfigFile( InputStream xmlStream ) {
@@ -249,7 +252,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
             Element f = i.next();
             String filterClass = f.getChildText( "class" );
             Properties props = new Properties();
-            
+
             List< Element > params = f.getChildren( "param" );
             for( Iterator< Element > par = params.iterator(); par.hasNext(); ) {
                 Element p = par.next();
@@ -259,16 +262,16 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
             initPageFilter( filterClass, props );
         }
     }
-    
- 
+
+
     /**
      *  Does the filtering before a translation.
-     *  
+     *
      *  @param context The WikiContext
      *  @param pageData WikiMarkup data to be passed through the preTranslate chain.
      *  @throws FilterException If any of the filters throws a FilterException
      *  @return The modified WikiMarkup
-     *  
+     *
      *  @see PageFilter#preTranslate(WikiContext, String)
      */
     public String doPreTranslateFiltering( WikiContext context, String pageData )
@@ -288,7 +291,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
 
     /**
      *  Does the filtering after HTML translation.
-     *  
+     *
      *  @param context The WikiContext
      *  @param htmlData HTML data to be passed through the postTranslate
      *  @throws FilterException If any of the filters throws a FilterException
@@ -312,7 +315,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
 
     /**
      *  Does the filtering before a save to the page repository.
-     *  
+     *
      *  @param context The WikiContext
      *  @param pageData WikiMarkup data to be passed through the preSave chain.
      *  @throws FilterException If any of the filters throws a FilterException
@@ -336,11 +339,11 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
 
     /**
      *  Does the page filtering after the page has been saved.
-     * 
+     *
      *  @param context The WikiContext
      *  @param pageData WikiMarkup data to be passed through the postSave chain.
      *  @throws FilterException If any of the filters throws a FilterException
-     * 
+     *
      *  @see PageFilter#postSave(WikiContext, String)
      */
     public void doPostSaveFiltering( WikiContext context, String pageData )
@@ -360,7 +363,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
     /**
      *  Returns the list of filters currently installed.  Note that this is not
      *  a copy, but the actual list.  So be careful with it.
-     *  
+     *
      *  @return A List of PageFilter objects
      */
     public List< PageFilter > getFilterList()
@@ -369,7 +372,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
     }
 
     /**
-     * 
+     *
      * Notifies PageFilters to clean up their ressources.
      *
      */
@@ -378,16 +381,16 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
         for( PageFilter f : m_pageFilters )
         {
             f.destroy( m_engine );
-        }        
+        }
     }
-    
+
     // events processing .......................................................
 
     /**
      *  Fires a WikiPageEvent of the provided type and WikiContext.
      *  Invalid WikiPageEvent types are ignored.
      *
-     * @see org.apache.wiki.event.WikiPageEvent 
+     * @see org.apache.wiki.event.WikiPageEvent
      * @param type      the WikiPageEvent type to be fired.
      * @param context   the WikiContext of the event.
      */
@@ -404,16 +407,11 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
      *  {@inheritDoc}
      */
     @Override
-    public Collection modules()
-    {
-        ArrayList< PageFilter > modules = new ArrayList< PageFilter >();
-        
-        modules.addAll( m_pageFilters );
-        
-        return modules;
+    public Collection modules() {
+        return modules( m_filterClassMap.values().iterator() );
     }
-    
-    
+
+
     /**
      *  {@inheritDoc}
      */
@@ -447,7 +445,7 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
 
     /**
      *  Stores information about the filters.
-     * 
+     *
      *  @since 2.6.1
      */
     private static final class PageFilterInfo extends WikiModuleInfo
@@ -456,14 +454,14 @@ public class DefaultFilterManager extends ModuleManager implements FilterManager
         {
             super(name);
         }
-        
+
         protected static PageFilterInfo newInstance(String className, Element pluginEl)
         {
             if( className == null || className.length() == 0 ) return null;
             PageFilterInfo info = new PageFilterInfo( className );
 
             info.initializeFromXML( pluginEl );
-            return info;        
+            return info;
         }
     }
 }

http://git-wip-us.apache.org/repos/asf/jspwiki/blob/bdc8f683/jspwiki-war/src/main/java/org/apache/wiki/modules/ModuleManager.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/modules/ModuleManager.java b/jspwiki-war/src/main/java/org/apache/wiki/modules/ModuleManager.java
index f836a0e..35a59e4 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/modules/ModuleManager.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/modules/ModuleManager.java
@@ -1,4 +1,4 @@
-/* 
+/*
     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
@@ -14,15 +14,19 @@
     "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.  
+    under the License.
  */
 package org.apache.wiki.modules;
 
 import java.util.Collection;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
 
 import org.apache.wiki.Release;
 import org.apache.wiki.WikiEngine;
 
+
 /**
  *  Superclass for all JSPWiki managers for modules (plugins, etc).
  */
@@ -34,24 +38,24 @@ public abstract class ModuleManager
      *  (Each plugin should include this property-file in its jar-file)
      */
     public static final String PLUGIN_RESOURCE_LOCATION = "ini/jspwiki_module.xml";
-        
+
     protected WikiEngine m_engine;
-    
+
     private boolean m_loadIncompatibleModules = false;
-    
+
     /**
      *  Constructs the ModuleManager.
-     *  
+     *
      *  @param engine The WikiEngine which owns this manager.
      */
     public ModuleManager( WikiEngine engine )
     {
         m_engine = engine;
     }
-    
+
     /**
      *  Returns true, if the given module is compatible with this version of JSPWiki.
-     *  
+     *
      *  @param info The module to check
      *  @return True, if the module is compatible.
      */
@@ -61,22 +65,33 @@ public abstract class ModuleManager
         {
             String minVersion = info.getMinVersion();
             String maxVersion = info.getMaxVersion();
-            
+
             return Release.isNewerOrEqual( minVersion ) && Release.isOlderOrEqual( maxVersion );
         }
-        
+
         return true;
     }
-    
+
     /**
      * Returns a collection of modules currently managed by this ModuleManager.  Each
      * entry is an instance of the WikiModuleInfo class.  This method should return something
      * which is safe to iterate over, even if the underlying collection changes.
-     * 
+     *
      * @return A Collection of WikiModuleInfo instances.
      */
     public abstract Collection modules();
 
+    protected < T extends WikiModuleInfo > Collection< WikiModuleInfo > modules( Iterator< T > iterator ) {
+        Set< WikiModuleInfo > ls = new TreeSet< WikiModuleInfo >();
+
+        for( Iterator< T > i = iterator; i.hasNext(); ) {
+            WikiModuleInfo wmi = i.next();
+            if( !ls.contains( wmi ) ) ls.add( wmi );
+        }
+
+        return ls;
+    }
+
     /**
      * Returns the {@link WikiModuleInfo} information about the provided moduleName.
      * @param moduleName


[08/10] jspwiki git commit: RenderingManager is now capable of returning a custom renderer for WYSIWYG editing

Posted by ju...@apache.org.
RenderingManager is now capable of returning a custom renderer for WYSIWYG editing


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/d813d92b
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/d813d92b
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/d813d92b

Branch: refs/heads/master
Commit: d813d92b3ce29f4d04d1c331fa59cbeb21f6d778
Parents: f31265a
Author: juanpablo <ju...@apache.org>
Authored: Tue Aug 22 20:09:39 2017 +0200
Committer: juanpablo <ju...@apache.org>
Committed: Tue Aug 22 20:09:39 2017 +0200

----------------------------------------------------------------------
 .../apache/wiki/render/RenderingManager.java    | 110 +++++++++++++------
 1 file changed, 76 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/d813d92b/jspwiki-war/src/main/java/org/apache/wiki/render/RenderingManager.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/render/RenderingManager.java b/jspwiki-war/src/main/java/org/apache/wiki/render/RenderingManager.java
index af3cbd6..466961a 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/render/RenderingManager.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/render/RenderingManager.java
@@ -25,10 +25,6 @@ import java.util.Collection;
 import java.util.Iterator;
 import java.util.Properties;
 
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Element;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.PageManager;
 import org.apache.wiki.WikiContext;
@@ -44,6 +40,10 @@ import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.parser.WikiDocument;
 import org.apache.wiki.util.ClassUtil;
 
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Element;
+
 
 /**
  *  This class provides a facade towards the differing rendering routines.  You should
@@ -69,10 +69,11 @@ public class RenderingManager implements WikiEventListener, InternalModule
     private CacheManager m_cacheManager = CacheManager.getInstance();
 
     /** The capacity of the caches, if you want something else, tweak ehcache.xml. */
-    private static final int    DEFAULT_CACHESIZE = 1000;
-    private static final String VERSION_DELIMITER = "::";
-    private static final String PROP_PARSER       = "jspwiki.renderingManager.markupParser";
-    private static final String PROP_RENDERER     = "jspwiki.renderingManager.renderer";
+    private static final int    DEFAULT_CACHESIZE     = 1000;
+    private static final String VERSION_DELIMITER     = "::";
+    private static final String PROP_PARSER           = "jspwiki.renderingManager.markupParser";
+    private static final String PROP_RENDERER         = "jspwiki.renderingManager.renderer";
+    private static final String PROP_WYSIWYG_RENDERER = "jspwiki.renderingManager.renderer.wysiwyg";
 
     /** The name of the default renderer. */
     public static final String DEFAULT_PARSER = JSPWikiMarkupParser.class.getName();
@@ -80,6 +81,9 @@ public class RenderingManager implements WikiEventListener, InternalModule
     /** The name of the default renderer. */
     public  static final String DEFAULT_RENDERER  = XHTMLRenderer.class.getName();
 
+    /** The name of the default WYSIWYG renderer. */
+    public  static final String DEFAULT_WYSIWYG_RENDERER  = WysiwygEditingRenderer.class.getName();
+
     /** Stores the WikiDocuments that have been cached. */
     private Cache m_documentCache;
 
@@ -87,6 +91,7 @@ public class RenderingManager implements WikiEventListener, InternalModule
     public static final String DOCUMENTCACHE_NAME = "jspwiki.renderingCache";
 
     private Constructor< ? > m_rendererConstructor;
+    private Constructor< ? > m_rendererWysiwygConstructor;
     private String m_markupParserClass = DEFAULT_PARSER;
 
     /**
@@ -137,26 +142,34 @@ public class RenderingManager implements WikiEventListener, InternalModule
             }
         }
 
-        String renderImplName = properties.getProperty( PROP_RENDERER, DEFAULT_RENDERER );
+        final String renderImplName = properties.getProperty( PROP_RENDERER, DEFAULT_RENDERER );
+        final String renderWysiwygImplName = properties.getProperty( PROP_WYSIWYG_RENDERER, DEFAULT_WYSIWYG_RENDERER );
 
-        Class< ? >[] rendererParams = { WikiContext.class, WikiDocument.class };
+        final Class< ? >[] rendererParams = { WikiContext.class, WikiDocument.class };
+        m_rendererConstructor = initRenderer( renderImplName, rendererParams );
+        m_rendererWysiwygConstructor = initRenderer( renderWysiwygImplName, rendererParams );
+
+        log.info( "Rendering content with " + renderImplName + "." );
+
+        WikiEventUtils.addWikiEventListener(m_engine, WikiPageEvent.POST_SAVE_BEGIN, this);
+    }
+
+    private Constructor< ? > initRenderer( final String renderImplName, final Class< ? >[] rendererParams ) throws WikiException {
+        Constructor< ? > c = null;
         try {
-            Class< ? > c = Class.forName( renderImplName );
-            m_rendererConstructor = c.getConstructor( rendererParams );
-        } catch( ClassNotFoundException e ) {
+            final Class< ? > clazz = Class.forName( renderImplName );
+            c = clazz.getConstructor( rendererParams );
+        } catch( final ClassNotFoundException e ) {
             log.error( "Unable to find WikiRenderer implementation " + renderImplName );
-        } catch( SecurityException e ) {
+        } catch( final SecurityException e ) {
             log.error( "Unable to access the WikiRenderer(WikiContext,WikiDocument) constructor for "  + renderImplName );
-        } catch( NoSuchMethodException e ) {
+        } catch( final NoSuchMethodException e ) {
             log.error( "Unable to locate the WikiRenderer(WikiContext,WikiDocument) constructor for "  + renderImplName );
         }
-
-        if( m_rendererConstructor == null ) {
+        if( c == null ) {
             throw new WikiException( "Failed to get WikiRenderer '" + renderImplName + "'." );
         }
-        log.info( "Rendering content with " + renderImplName + "." );
-
-        WikiEventUtils.addWikiEventListener(m_engine, WikiPageEvent.POST_SAVE_BEGIN, this);
+        return c;
     }
 
     /**
@@ -236,7 +249,19 @@ public class RenderingManager implements WikiEventListener, InternalModule
      */
     public String getHTML( WikiContext context, WikiDocument doc ) throws IOException
     {
-        WikiRenderer rend = getRenderer( context, doc );
+        final Boolean wysiwygVariable = ( Boolean )context.getVariable( WYSIWYG_EDITOR_MODE );
+        final boolean wysiwygEditorMode;
+        if( wysiwygVariable != null ) {
+            wysiwygEditorMode = wysiwygVariable.booleanValue();
+        } else {
+            wysiwygEditorMode = false;
+        }
+        WikiRenderer rend;
+        if( wysiwygEditorMode ) {
+            rend = getWysiwygRenderer( context, doc );
+        } else {
+            rend = getRenderer( context, doc );
+        }
 
         return rend.getString();
     }
@@ -250,17 +275,33 @@ public class RenderingManager implements WikiEventListener, InternalModule
      * @param doc The document to render
      * @return A WikiRenderer for this document, or null, if no such renderer could be instantiated.
      */
-    public WikiRenderer getRenderer( WikiContext context, WikiDocument doc )
-    {
-        Object[] params = { context, doc };
-        WikiRenderer rval = null;
+    public WikiRenderer getRenderer( WikiContext context, WikiDocument doc ) {
+        final Object[] params = { context, doc };
+        return getRenderer( params, m_rendererConstructor );
+    }
 
-        try
-        {
-            rval = (WikiRenderer)m_rendererConstructor.newInstance( params );
-        }
-        catch( Exception e )
-        {
+    /**
+     * Returns a WikiRenderer instance meant for WYSIWYG editing, initialized with the given
+     * context and doc. The object is an WysiwygEditingRenderer, unless overridden
+     * in jspwiki.properties with PROP_WYSIWYG_RENDERER.
+     *
+     * @param context The WikiContext
+     * @param doc The document to render
+     * @return A WikiRenderer instance meant for WYSIWYG editing, for this document, or null, if
+     *         no such renderer could be instantiated.
+     */
+    public WikiRenderer getWysiwygRenderer( WikiContext context, WikiDocument doc ) {
+        final Object[] params = { context, doc };
+        return getRenderer( params, m_rendererWysiwygConstructor );
+    }
+
+    @SuppressWarnings("unchecked")
+    private < T extends WikiRenderer > T getRenderer( Object[] params, Constructor<?> rendererConstructor ) {
+        T rval = null;
+
+        try {
+            rval = (T)rendererConstructor.newInstance( params );
+        } catch( final Exception e ) {
             log.error( "Unable to create WikiRenderer", e );
         }
         return rval;
@@ -299,22 +340,23 @@ public class RenderingManager implements WikiEventListener, InternalModule
      * @see org.apache.wiki.event.WikiEventListener#actionPerformed(org.apache.wiki.event.WikiEvent)
      * @param event {@inheritDoc}
      */
+    @Override
     public void actionPerformed(WikiEvent event) {
         if (m_useCache) {
             if ((event instanceof WikiPageEvent) && (event.getType() == WikiPageEvent.POST_SAVE_BEGIN)) {
                 if (m_documentCache != null) {
                     String pageName = ((WikiPageEvent) event).getPageName();
                     m_documentCache.remove(pageName);
-                    Collection referringPages = m_engine.getReferenceManager().findReferrers(pageName);
+                    Collection<String> referringPages = m_engine.getReferenceManager().findReferrers(pageName);
 
                     //
                     //  Flush also those pages that refer to this page (if an nonexistent page
                     //  appears; we need to flush the HTML that refers to the now-existent page
                     //
                     if (referringPages != null) {
-                        Iterator i = referringPages.iterator();
+                        Iterator<String> i = referringPages.iterator();
                         while (i.hasNext()) {
-                            String page = (String) i.next();
+                            String page = i.next();
                             if (log.isDebugEnabled()) log.debug("Flushing " + page);
                             m_documentCache.remove(page);
                         }

[05/10] jspwiki git commit: new JSPWiki AdminBean exposing existing filters information

Posted by ju...@apache.org.
new JSPWiki AdminBean exposing existing filters information


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/14b2bbbf
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/14b2bbbf
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/14b2bbbf

Branch: refs/heads/master
Commit: 14b2bbbf2a56e9de92841077b7fe357b91b23f81
Parents: 6c2b106
Author: juanpablo <ju...@apache.org>
Authored: Tue Aug 22 20:02:09 2017 +0200
Committer: juanpablo <ju...@apache.org>
Committed: Tue Aug 22 20:02:09 2017 +0200

----------------------------------------------------------------------
 .../apache/wiki/ui/admin/beans/FilterBean.java  | 84 ++++++++++++++++++++
 1 file changed, 84 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/14b2bbbf/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/FilterBean.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/FilterBean.java b/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/FilterBean.java
new file mode 100755
index 0000000..edbfaee
--- /dev/null
+++ b/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/FilterBean.java
@@ -0,0 +1,84 @@
+/*
+    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.admin.beans;
+
+import java.util.Collection;
+
+import javax.management.NotCompliantMBeanException;
+
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.modules.WikiModuleInfo;
+import org.apache.wiki.util.XHTML;
+import org.apache.wiki.util.XhtmlUtil;
+import org.jdom2.Element;
+
+
+public class FilterBean extends ModuleBean< WikiModuleInfo > {
+
+    public FilterBean( WikiEngine engine ) throws NotCompliantMBeanException {
+        super( engine );
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String getTitle() {
+        return "Filters";
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int getType() {
+        return CORE;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Collection< WikiModuleInfo > modules() {
+        return m_engine.getFilterManager().modules();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Element heading() {
+        Element trHead = XhtmlUtil.element( XHTML.tr );
+        trHead.addContent( XhtmlUtil.element( XHTML.th ).addContent( "Name" ) )
+              .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Author" ) )
+              .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Notes" ) );
+        return trHead;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Element rowBody( WikiModuleInfo info ) {
+        Element tr = XhtmlUtil.element( XHTML.tr );
+        tr.addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getName() ) )
+          .addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getAuthor() ) )
+          .addContent( XhtmlUtil.element( XHTML.td ).addContent( validModuleVersion( info ) ) );
+        return tr;
+    }
+
+}


[06/10] jspwiki git commit: refactor PluginBean by extending ModuleBean instead of SimpleAdminBean

Posted by ju...@apache.org.
refactor PluginBean by extending ModuleBean instead of SimpleAdminBean


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/5139de06
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/5139de06
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/5139de06

Branch: refs/heads/master
Commit: 5139de06536922b71ee1b89c5b202178b817b9a2
Parents: 14b2bbb
Author: juanpablo <ju...@apache.org>
Authored: Tue Aug 22 20:03:29 2017 +0200
Committer: juanpablo <ju...@apache.org>
Committed: Tue Aug 22 20:03:29 2017 +0200

----------------------------------------------------------------------
 .../apache/wiki/ui/admin/beans/PluginBean.java  | 85 ++++++++------------
 1 file changed, 35 insertions(+), 50 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/5139de06/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java b/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java
index d17c10f..da0f126 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/PluginBean.java
@@ -14,7 +14,7 @@
     "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.  
+    under the License.
 */
 package org.apache.wiki.ui.admin.beans;
 
@@ -22,79 +22,64 @@ import java.util.Collection;
 
 import javax.management.NotCompliantMBeanException;
 
-import org.apache.commons.lang.StringUtils;
-import org.apache.wiki.Release;
-import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.plugin.DefaultPluginManager.WikiPluginInfo;
-import org.apache.wiki.ui.admin.SimpleAdminBean;
 import org.apache.wiki.util.XHTML;
 import org.apache.wiki.util.XhtmlUtil;
 import org.jdom2.Element;
 
-public class PluginBean extends SimpleAdminBean {
-	
-    private WikiEngine m_engine;
-    
-    private static final String VER_WARNING = "<span class='warning'>This module is not compatible with this version of JSPWiki.</span>";
-    
-    public PluginBean( WikiEngine engine ) throws NotCompliantMBeanException {
-        m_engine = engine;
-    }
 
-    public String[] getAttributeNames() {
-        return new String[0];
-    }
+public class PluginBean extends ModuleBean< WikiPluginInfo > {
 
-    public String[] getMethodNames() {
-        return new String[0];
+    public PluginBean( WikiEngine engine ) throws NotCompliantMBeanException {
+        super( engine );
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public String getTitle() {
         return "Plugins";
     }
 
+    /**
+     * {@inheritDoc}
+     */
     public int getType() {
         return CORE;
     }
 
-    @SuppressWarnings("unchecked")
-    public String doGet(WikiContext context) {
-        PluginManager pm = m_engine.getPluginManager();
-        Collection< WikiPluginInfo > plugins = pm.modules();
-        
-        Element root = XhtmlUtil.element( XHTML.div );
-        Element tb =  XhtmlUtil.element( XHTML.table ).setAttribute( "border", "1" );
-        
-        root.addContent( XhtmlUtil.element( XHTML.h4 ).addContent( "Plugins") )
-            .addContent( tb );
-        
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Collection< WikiPluginInfo > modules() {
+        return m_engine.getPluginManager().modules();
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Element heading() {
         Element trHead = XhtmlUtil.element( XHTML.tr );
         trHead.addContent( XhtmlUtil.element( XHTML.th ).addContent( "Name" ) )
-              .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Alias" ) )
               .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Author" ) )
               .addContent( XhtmlUtil.element( XHTML.th ).addContent( "Notes" ) );
-        
-        tb.addContent( trHead );
-        
-        for( WikiPluginInfo info : plugins ) {
-            Element tr = XhtmlUtil.element( XHTML.tr );
-            tr.addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getName() ) ) 
-              .addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getAlias() ) ) 
-              .addContent( XhtmlUtil.element( XHTML.td ).addContent( info.getAuthor() ) )
-              .addContent( XhtmlUtil.element( XHTML.td ).addContent( validPluginVersion( info ) ) );
-                
-            tb.addContent( tr );
-        }
-
-        return XhtmlUtil.serialize( root, XhtmlUtil.EXPAND_EMPTY_NODES );
+        return trHead;
     }
 
-    String validPluginVersion( WikiPluginInfo info ) {
-        return Release.isNewerOrEqual( info.getMinVersion() ) && Release.isOlderOrEqual( info.getMaxVersion() ) 
-               ? StringUtils.EMPTY 
-               : VER_WARNING;
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    protected Element rowBody( WikiPluginInfo plugin ) {
+        Element tr = XhtmlUtil.element( XHTML.tr );
+        tr.addContent( XhtmlUtil.element( XHTML.td ).addContent( plugin.getName() ) )
+          .addContent( XhtmlUtil.element( XHTML.td ).addContent( plugin.getAlias() ) )
+          .addContent( XhtmlUtil.element( XHTML.td ).addContent( plugin.getAuthor() ) )
+          .addContent( XhtmlUtil.element( XHTML.td ).addContent( validModuleVersion( plugin ) ) );
+        return tr;
     }
 
 }


[03/10] jspwiki git commit: simplify other modules() implementations

Posted by ju...@apache.org.
simplify other modules() implementations


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/4621e466
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/4621e466
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/4621e466

Branch: refs/heads/master
Commit: 4621e466a2a07461dec76e8f7c837ee482b06367
Parents: bdc8f68
Author: juanpablo <ju...@apache.org>
Authored: Tue Aug 22 20:00:39 2017 +0200
Committer: juanpablo <ju...@apache.org>
Committed: Tue Aug 22 20:00:39 2017 +0200

----------------------------------------------------------------------
 .../wiki/plugin/DefaultPluginManager.java       | 85 +++++++++-----------
 .../java/org/apache/wiki/ui/EditorManager.java  | 19 ++---
 2 files changed, 46 insertions(+), 58 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/4621e466/jspwiki-war/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java b/jspwiki-war/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
index e4c7714..eb48910 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/plugin/DefaultPluginManager.java
@@ -14,11 +14,30 @@
     "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.  
+    under the License.
  */
 
 package org.apache.wiki.plugin;
 
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StreamTokenizer;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.StringTokenizer;
+
+import javax.servlet.http.HttpServlet;
+
 import org.apache.commons.lang.ClassUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.log4j.Logger;
@@ -49,27 +68,6 @@ import org.apache.wiki.util.XhtmlUtil;
 import org.apache.wiki.util.XmlUtil;
 import org.jdom2.Element;
 
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StreamTokenizer;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.Properties;
-import java.util.ResourceBundle;
-import java.util.Set;
-import java.util.StringTokenizer;
-import java.util.TreeSet;
-
-import javax.servlet.http.HttpServlet;
-
 /**
  *  Manages plugin classes.  There exists a single instance of PluginManager
  *  per each instance of WikiEngine, that is, each JSPWiki instance.
@@ -162,7 +160,7 @@ import javax.servlet.http.HttpServlet;
  *  @since 1.6.1
  */
 public class DefaultPluginManager extends ModuleManager implements PluginManager {
-	
+
     private static final String PLUGIN_INSERT_PATTERN = "\\{?(INSERT)?\\s*([\\w\\._]+)[ \\t]*(WHERE)?[ \\t]*";
 
     private static Logger log = Logger.getLogger( DefaultPluginManager.class );
@@ -249,7 +247,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
     public Pattern getPluginPattern() {
 		return m_pluginPattern;
 	}
-    
+
     /**
      * {@inheritDoc}
      */
@@ -278,15 +276,15 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
     {
         Element div = XhtmlUtil.element(XHTML.div,"Plugin execution failed, stack trace follows:");
         div.setAttribute(XHTML.ATTR_class,"debug");
-        
+
 
         StringWriter out = new StringWriter();
         t.printStackTrace(new PrintWriter(out));
-        div.addContent(XhtmlUtil.element(XHTML.pre,out.toString()));        
+        div.addContent(XhtmlUtil.element(XHTML.pre,out.toString()));
         div.addContent(XhtmlUtil.element(XHTML.b,"Parameters to the plugin"));
 
         Element list = XhtmlUtil.element(XHTML.ul);
-        
+
         for( Iterator<Map.Entry<String,String>> i = params.entrySet().iterator(); i.hasNext(); ) {
             Map.Entry<String,String> e = i.next();
             String key = e.getKey();
@@ -294,7 +292,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
         }
 
         div.addContent(list);
-        
+
         return XhtmlUtil.serialize(div);
     }
 
@@ -482,7 +480,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
      *  @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!
      */
     public String execute( WikiContext context, String commandline ) throws PluginException {
@@ -579,7 +577,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
     //        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;
         private String    m_alias;
         private String    m_ajaxAlias;
@@ -604,10 +602,10 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
             info.initializeFromXML( el );
             return info;
         }
-        
+
         /**
          *  Initializes a plugin, if it has not yet been initialized.
-         *  If the plugin extends {@link HttpServlet} it will automatically 
+         *  If the plugin extends {@link HttpServlet} it will automatically
          *  register it as AJAX using {@link WikiAjaxDispatcherServlet.register}.
          *
          *  @param engine The WikiEngine
@@ -649,7 +647,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
 
         /**
          *  Create a new WikiPluginInfo based on the Class information.
-         *  
+         *
          *  @param clazz The class to check
          *  @return A WikiPluginInfo instance
          */
@@ -682,7 +680,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
         public String getAlias() {
             return m_alias;
         }
-        
+
         /**
          *  Returns the ajax alias name for this object.
          *  @return An ajax alias name for the plugin.
@@ -702,7 +700,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
          *  @throws InstantiationException If the class cannot be instantiated-
          *  @throws IllegalAccessException If the class cannot be accessed.
          */
-        
+
         public WikiPlugin newPluginInstance(List<String> searchPath, List<String> externalJars) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
             if( m_clazz == null ) {
                 m_clazz = ClassUtil.findClass(searchPath, externalJars ,m_className);
@@ -774,7 +772,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
 
         /**
          *  Returns a string suitable for debugging.  Don't assume that the format would stay the same.
-         *  
+         *
          *  @return Something human-readable
          */
         public String toString() {
@@ -787,16 +785,9 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
      */
     @Override
     public Collection< WikiModuleInfo > modules() {
-        Set< WikiModuleInfo > ls = new TreeSet< WikiModuleInfo >();
-        
-        for( Iterator< WikiPluginInfo > i = m_pluginClassMap.values().iterator(); i.hasNext(); ) {
-            WikiModuleInfo wmi = i.next();
-            if( !ls.contains( wmi ) ) ls.add( wmi );
-        }
-        
-        return ls;
+        return modules( m_pluginClassMap.values().iterator() );
     }
-    
+
     /**
      *  {@inheritDoc}
      */
@@ -807,7 +798,7 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
 
     /**
      * Creates a {@link WikiPlugin}.
-     * 
+     *
      * @param pluginName plugin's classname
      * @param rb {@link ResourceBundle} with i18ned text for exceptions.
      * @return a {@link WikiPlugin}.
@@ -839,5 +830,5 @@ public class DefaultPluginManager extends ModuleManager implements PluginManager
         }
         return plugin;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/jspwiki/blob/4621e466/jspwiki-war/src/main/java/org/apache/wiki/ui/EditorManager.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/ui/EditorManager.java b/jspwiki-war/src/main/java/org/apache/wiki/ui/EditorManager.java
index 5cdddac..7236471 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/ui/EditorManager.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/ui/EditorManager.java
@@ -1,4 +1,4 @@
-/* 
+/*
     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
@@ -14,11 +14,10 @@
     "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.  
+    under the License.
  */
 package org.apache.wiki.ui;
 
-import java.util.ArrayList;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -280,16 +279,14 @@ public class EditorManager extends ModuleManager {
         }
     }
 
+    /**
+     *  {@inheritDoc}
+     */
     @Override
-    public Collection modules()
-    {
-        ArrayList<WikiModuleInfo> ls = new ArrayList<WikiModuleInfo>();
-
-        ls.addAll( m_editors.values() );
-
-        return ls;
+    public Collection modules() {
+        return modules( m_editors.values().iterator() );
     }
-    
+
     /**
      *  {@inheritDoc}
      */

[04/10] jspwiki git commit: base class for module-based JSPWiki AdminBeans

Posted by ju...@apache.org.
base class for module-based JSPWiki AdminBeans


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/6c2b1065
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/6c2b1065
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/6c2b1065

Branch: refs/heads/master
Commit: 6c2b1065cfb0a29944eb23d0b49d2b281b37f10a
Parents: 4621e46
Author: juanpablo <ju...@apache.org>
Authored: Tue Aug 22 20:01:37 2017 +0200
Committer: juanpablo <ju...@apache.org>
Committed: Tue Aug 22 20:01:37 2017 +0200

----------------------------------------------------------------------
 .../apache/wiki/ui/admin/beans/ModuleBean.java  | 118 +++++++++++++++++++
 1 file changed, 118 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/6c2b1065/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java b/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java
new file mode 100755
index 0000000..35d0308
--- /dev/null
+++ b/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/beans/ModuleBean.java
@@ -0,0 +1,118 @@
+/*
+    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.admin.beans;
+
+import java.util.Collection;
+
+import javax.management.NotCompliantMBeanException;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.wiki.Release;
+import org.apache.wiki.WikiContext;
+import org.apache.wiki.WikiEngine;
+import org.apache.wiki.modules.WikiModuleInfo;
+import org.apache.wiki.ui.admin.SimpleAdminBean;
+import org.apache.wiki.util.XHTML;
+import org.apache.wiki.util.XhtmlUtil;
+import org.jdom2.Element;
+
+public abstract class ModuleBean< T extends WikiModuleInfo > extends SimpleAdminBean {
+
+    protected WikiEngine m_engine;
+
+    private static final String VER_WARNING = "<span class='warning'>This module is not compatible with this version of JSPWiki.</span>";
+
+    public ModuleBean( WikiEngine engine ) throws NotCompliantMBeanException {
+        m_engine = engine;
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getAttributeNames() {
+        return new String[0];
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String[] getMethodNames() {
+        return new String[0];
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public String doGet( WikiContext context ) {
+        Collection< T > filters = modules();
+        Element root = title();
+        Element tb = containerForModuleDetail( root );
+
+        Element trHead = heading();
+        tb.addContent( trHead );
+
+        for( T info : filters ) {
+            Element tr = rowBody( info );
+            tb.addContent( tr );
+        }
+
+        return XhtmlUtil.serialize( root, XhtmlUtil.EXPAND_EMPTY_NODES );
+    }
+
+    protected Element title() {
+        Element root = XhtmlUtil.element( XHTML.div );
+        root.addContent( XhtmlUtil.element( XHTML.h4 ).addContent( getTitle() ) );
+        return root;
+    }
+
+    protected Element containerForModuleDetail( Element root ) {
+        Element tb = XhtmlUtil.element( XHTML.table ).setAttribute( "border", "1" );
+        root.addContent( tb );
+        return tb;
+    }
+
+    /**
+     * Obtains the collection of modules which is going to be inspected at {@link #doGet(WikiContext)}.
+     *
+     * @return a collection of {@link WikiModuleInfo}
+     */
+    protected abstract Collection< T > modules();
+
+    /**
+     * html blob describing the values of each {@link WikiModuleInfo} inspected.
+     *
+     * @return {@link Element} describing the values of each {@link WikiModuleInfo} inspected.
+     */
+    protected abstract Element heading();
+
+    /**
+     * html blob describing{@link Element} describing attributes
+     *
+     * @param module {@link WikiModuleInfo} inspected.
+     * @return {@link Element} describing the {@link Element} inspected.
+     */
+    protected abstract Element rowBody( T module );
+
+    protected String validModuleVersion( T info ) {
+        return Release.isNewerOrEqual( info.getMinVersion() ) && Release.isOlderOrEqual( info.getMaxVersion() )
+               ? StringUtils.EMPTY
+               : VER_WARNING;
+    }
+
+}

[09/10] jspwiki git commit: no more instantiation of WysiwygEditingRenderer, the appropiate renderer is retrieved through the rendering manager

Posted by ju...@apache.org.
no more instantiation of WysiwygEditingRenderer, the appropiate renderer is retrieved through the rendering manager


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/76017e18
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/76017e18
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/76017e18

Branch: refs/heads/master
Commit: 76017e18a79409e76fe5caad651ce1a3f6de8aa0
Parents: d813d92
Author: juanpablo <ju...@apache.org>
Authored: Tue Aug 22 20:11:32 2017 +0200
Committer: juanpablo <ju...@apache.org>
Committed: Tue Aug 22 20:11:32 2017 +0200

----------------------------------------------------------------------
 .../src/main/webapp/XHRMarkup2Wysiwyg.jsp       | 11 +------
 .../templates/default/editors/CKeditor.jsp      | 30 +++++++-----------
 .../webapp/templates/default/editors/FCK.jsp    | 12 ++------
 .../templates/default/editors/TinyMCE.jsp       | 32 ++++++++------------
 .../templates/haddock/editors/CKeditor.jsp      | 10 +-----
 .../templates/haddock/editors/TinyMCE.jsp       | 14 ++-------
 .../templates/haddock/editors/wysiwyg.jsp       | 15 ++-------
 7 files changed, 33 insertions(+), 91 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/76017e18/jspwiki-war/src/main/webapp/XHRMarkup2Wysiwyg.jsp
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/webapp/XHRMarkup2Wysiwyg.jsp b/jspwiki-war/src/main/webapp/XHRMarkup2Wysiwyg.jsp
index 293bb45..c205e38 100644
--- a/jspwiki-war/src/main/webapp/XHRMarkup2Wysiwyg.jsp
+++ b/jspwiki-war/src/main/webapp/XHRMarkup2Wysiwyg.jsp
@@ -48,19 +48,10 @@
   if( usertext != null )
   {
 
-    RenderingManager renderingManager = new RenderingManager();
-
-    // since the WikiProperties are shared, we'll want to make our own copy of it for modifying.
-    Properties copyOfWikiProperties = new Properties();
-    copyOfWikiProperties.putAll( wiki.getWikiProperties() );
-    copyOfWikiProperties.setProperty( "jspwiki.renderingManager.renderer", WysiwygEditingRenderer.class.getName() );
-    renderingManager.initialize( wiki, copyOfWikiProperties );
-
     String pageAsHtml;
     try
     {
-        pageAsHtml = renderingManager.getHTML( wikiContext, usertext );
-
+        pageAsHtml = wiki.getRenderingManager().getHTML( wikiContext, usertext );
     }
         catch( Exception e )
     {

http://git-wip-us.apache.org/repos/asf/jspwiki/blob/76017e18/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
index 339c938..e9f3e2b 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/CKeditor.jsp
@@ -94,25 +94,17 @@
 <%
    if( usertext == null ) usertext = "";
 
-   RenderingManager renderingManager = engine.getRenderingManager();
-
-   // since the WikiProperties are shared, we'll want to make our own copy of it for modifying.
-   Properties copyOfWikiProperties = new Properties();
-   copyOfWikiProperties.putAll( engine.getWikiProperties() );
-   copyOfWikiProperties.setProperty( "jspwiki.renderingManager.renderer", WysiwygEditingRenderer.class.getName() );
-   renderingManager.initialize( engine, copyOfWikiProperties );
-
-    String pageAsHtml;
-    try
-    {
-        //pageAsHtml = StringEscapeUtils.escapeJavaScript( renderingManager.getHTML( context, usertext ) );
-        pageAsHtml = renderingManager.getHTML( context, usertext );
-    }
-        catch( Exception e )
-    {
-        pageAsHtml = "Error in converting wiki-markup to well-formed HTML \n" + e.toString();
-        //pageAsHtml = e.toString() + "\n" + usertext; //error
-    }
+   String pageAsHtml;
+   try
+   {
+       //pageAsHtml = StringEscapeUtils.escapeJavaScript( renderingManager.getHTML( context, usertext ) );
+       pageAsHtml = engine.getRenderingManager().getHTML( context, usertext );
+   }
+       catch( Exception e )
+   {
+       pageAsHtml = "Error in converting wiki-markup to well-formed HTML \n" + e.toString();
+       //pageAsHtml = e.toString() + "\n" + usertext; //error
+   }
 
    // Disable the WYSIWYG_EDITOR_MODE and reset the other properties immediately
    // after the XHTML for CKeditor has been rendered.

http://git-wip-us.apache.org/repos/asf/jspwiki/blob/76017e18/jspwiki-war/src/main/webapp/templates/default/editors/FCK.jsp
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/FCK.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/FCK.jsp
index e563569..ec95bca 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/FCK.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/FCK.jsp
@@ -81,15 +81,7 @@
 </wiki:CheckRequestContext>
 <% if( usertext == null ) usertext = "";
 
-   RenderingManager renderingManager = engine.getRenderingManager();
-
-   // since the WikiProperties are shared, we'll want to make our own copy of it for modifying.
-   Properties copyOfWikiProperties = new Properties();
-   copyOfWikiProperties.putAll( engine.getWikiProperties() );
-   copyOfWikiProperties.setProperty( "jspwiki.renderingManager.renderer", WysiwygEditingRenderer.class.getName() );
-   renderingManager.initialize( engine, copyOfWikiProperties );
-
-   String pageAsHtml = StringEscapeUtils.escapeJavaScript( renderingManager.getHTML( context, usertext ) );
+   String pageAsHtml = StringEscapeUtils.escapeJavaScript( engine.getRenderingManager().getHTML( context, usertext ) );
 
    // Disable the WYSIWYG_EDITOR_MODE and reset the other properties immediately
    // after the XHTML for FCK has been rendered.
@@ -97,7 +89,7 @@
    context.setVariable( WikiEngine.PROP_RUNFILTERS,  null );
    wikiPage.setAttribute( JSPWikiMarkupParser.PROP_CAMELCASELINKS, originalCCLOption );
 
-   String templateDir = (String)copyOfWikiProperties.get( WikiEngine.PROP_TEMPLATEDIR );
+   String templateDir = (String)engine.getWikiProperties().get( WikiEngine.PROP_TEMPLATEDIR );
 
    String protocol = "http://";
    if( request.isSecure() )

http://git-wip-us.apache.org/repos/asf/jspwiki/blob/76017e18/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp b/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
index 72c95ce..207c1a9 100644
--- a/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
+++ b/jspwiki-war/src/main/webapp/templates/default/editors/TinyMCE.jsp
@@ -94,25 +94,17 @@
 <%
    if( usertext == null ) usertext = "";
 
-   RenderingManager renderingManager = engine.getRenderingManager();
-
-   // since the WikiProperties are shared, we'll want to make our own copy of it for modifying.
-   Properties copyOfWikiProperties = new Properties();
-   copyOfWikiProperties.putAll( engine.getWikiProperties() );
-   copyOfWikiProperties.setProperty( "jspwiki.renderingManager.renderer", WysiwygEditingRenderer.class.getName() );
-   renderingManager.initialize( engine, copyOfWikiProperties );
-
-    String pageAsHtml;
-    try
-    {
-        //pageAsHtml = StringEscapeUtils.escapeJavaScript( renderingManager.getHTML( context, usertext ) );
-        pageAsHtml = renderingManager.getHTML( context, usertext );
-    }
-        catch( Exception e )
-    {
-        pageAsHtml = "Error in converting wiki-markup to well-formed HTML \n" + e.toString();
-        //pageAsHtml = e.toString() + "\n" + usertext; //error
-    }
+   String pageAsHtml;
+   try
+   {
+       //pageAsHtml = StringEscapeUtils.escapeJavaScript( engine.getRenderingManager().getHTML( context, usertext ) );
+       pageAsHtml = engine.getRenderingManager().getHTML( context, usertext );
+   }
+       catch( Exception e )
+   {
+       pageAsHtml = "Error in converting wiki-markup to well-formed HTML \n" + e.toString();
+       //pageAsHtml = e.toString() + "\n" + usertext; //error
+   }
 
    // Disable the WYSIWYG_EDITOR_MODE and reset the other properties immediately
    // after the XHTML for TinyMCE has been rendered.
@@ -122,7 +114,7 @@
    wikiPage.setAttribute( JSPWikiMarkupParser.PROP_CAMELCASELINKS, originalCCLOption );
 
    /*not used
-   String templateDir = (String)copyOfWikiProperties.get( WikiEngine.PROP_TEMPLATEDIR );
+   String templateDir = (String)engine.getWikiProperties().get( WikiEngine.PROP_TEMPLATEDIR );
 
    String protocol = "http://";
    if( request.isSecure() )

http://git-wip-us.apache.org/repos/asf/jspwiki/blob/76017e18/jspwiki-war/src/main/webapp/templates/haddock/editors/CKeditor.jsp
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/webapp/templates/haddock/editors/CKeditor.jsp b/jspwiki-war/src/main/webapp/templates/haddock/editors/CKeditor.jsp
index 7a79de8..026e5ff 100644
--- a/jspwiki-war/src/main/webapp/templates/haddock/editors/CKeditor.jsp
+++ b/jspwiki-war/src/main/webapp/templates/haddock/editors/CKeditor.jsp
@@ -96,19 +96,11 @@
 <%
     if( usertext == null ) usertext = "";
 
-    RenderingManager renderingManager = new RenderingManager();
-
-    // since the WikiProperties are shared, we'll want to make our own copy of it for modifying.
-    Properties copyOfWikiProperties = new Properties();
-    copyOfWikiProperties.putAll( engine.getWikiProperties() );
-    copyOfWikiProperties.setProperty( "jspwiki.renderingManager.renderer", WysiwygEditingRenderer.class.getName() );
-    renderingManager.initialize( engine, copyOfWikiProperties );
-
     String pageAsHtml;
     try
     {
         //pageAsHtml = StringEscapeUtils.escapeJavaScript( renderingManager.getHTML( context, usertext ) );
-        pageAsHtml = renderingManager.getHTML( context, usertext );
+        pageAsHtml = engine.getRenderingManager().getHTML( context, usertext );
     }
         catch( Exception e )
     {

http://git-wip-us.apache.org/repos/asf/jspwiki/blob/76017e18/jspwiki-war/src/main/webapp/templates/haddock/editors/TinyMCE.jsp
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/webapp/templates/haddock/editors/TinyMCE.jsp b/jspwiki-war/src/main/webapp/templates/haddock/editors/TinyMCE.jsp
index e3af0a1..2bad241 100644
--- a/jspwiki-war/src/main/webapp/templates/haddock/editors/TinyMCE.jsp
+++ b/jspwiki-war/src/main/webapp/templates/haddock/editors/TinyMCE.jsp
@@ -97,19 +97,11 @@
 <%
     if( usertext == null ) usertext = "";
 
-    RenderingManager renderingManager = new RenderingManager();
-
-    // since the WikiProperties are shared, we'll want to make our own copy of it for modifying.
-    Properties copyOfWikiProperties = new Properties();
-    copyOfWikiProperties.putAll( engine.getWikiProperties() );
-    copyOfWikiProperties.setProperty( "jspwiki.renderingManager.renderer", WysiwygEditingRenderer.class.getName() );
-    renderingManager.initialize( engine, copyOfWikiProperties );
-
     String pageAsHtml;
     try
     {
-        //pageAsHtml = StringEscapeUtils.escapeJavaScript( renderingManager.getHTML( context, usertext ) );
-        pageAsHtml = renderingManager.getHTML( context, usertext );
+        //pageAsHtml = StringEscapeUtils.escapeJavaScript( engine.getRenderingManager().getHTML( context, usertext ) );
+        pageAsHtml = engine.getRenderingManager().getHTML( context, usertext );
 
     }
         catch( Exception e )
@@ -134,7 +126,7 @@
 
 
    /*FSS not used
-   String templateDir = (String)copyOfWikiProperties.get( WikiEngine.PROP_TEMPLATEDIR );
+   String templateDir = (String)engine.getWikiProperties().get( WikiEngine.PROP_TEMPLATEDIR );
 
    String protocol = "http://";
    if( request.isSecure() )

http://git-wip-us.apache.org/repos/asf/jspwiki/blob/76017e18/jspwiki-war/src/main/webapp/templates/haddock/editors/wysiwyg.jsp
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/webapp/templates/haddock/editors/wysiwyg.jsp b/jspwiki-war/src/main/webapp/templates/haddock/editors/wysiwyg.jsp
index 2aea0e9..4ddad49 100644
--- a/jspwiki-war/src/main/webapp/templates/haddock/editors/wysiwyg.jsp
+++ b/jspwiki-war/src/main/webapp/templates/haddock/editors/wysiwyg.jsp
@@ -89,20 +89,11 @@
 <%
     if( usertext == null ) usertext = "";
 
-    RenderingManager renderingManager = new RenderingManager();
-    //RenderingManager renderingManager = engine.getRenderingManager();
-
-    // since the WikiProperties are shared, we'll want to make our own copy of it for modifying.
-    Properties copyOfWikiProperties = new Properties();
-    copyOfWikiProperties.putAll( engine.getWikiProperties() );
-    copyOfWikiProperties.setProperty( "jspwiki.renderingManager.renderer", WysiwygEditingRenderer.class.getName() );
-    renderingManager.initialize( engine, copyOfWikiProperties );
-
     String pageAsHtml;
     try
     {
-        //pageAsHtml = StringEscapeUtils.escapeJavaScript( renderingManager.getHTML( context, usertext ) );
-        pageAsHtml = renderingManager.getHTML( context, usertext );
+        //pageAsHtml = StringEscapeUtils.escapeJavaScript( engine.getRenderingManager().getHTML( context, usertext ) );
+        pageAsHtml = engine.getRenderingManager().getHTML( context, usertext );
     }
         catch( Exception e )
     {
@@ -123,7 +114,7 @@
    wikiPage.setAttribute( JSPWikiMarkupParser.PROP_CAMELCASELINKS, originalCCLOption );
 
    /*not used
-   String templateDir = (String)copyOfWikiProperties.get( WikiEngine.PROP_TEMPLATEDIR );
+   String templateDir = (String)engine.getWikiProperties().get( WikiEngine.PROP_TEMPLATEDIR );
 
    String protocol = "http://";
    if( request.isSecure() )

[07/10] jspwiki git commit: register FilterBean, method parameter from private void registerBeans(..) is now typed

Posted by ju...@apache.org.
register FilterBean, method parameter from private void registerBeans(..) is now typed


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/f31265aa
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/f31265aa
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/f31265aa

Branch: refs/heads/master
Commit: f31265aad1a62c4cba2587a379e537d9aa79a2cc
Parents: 5139de0
Author: juanpablo <ju...@apache.org>
Authored: Tue Aug 22 20:05:17 2017 +0200
Committer: juanpablo <ju...@apache.org>
Committed: Tue Aug 22 20:05:17 2017 +0200

----------------------------------------------------------------------
 .../wiki/ui/admin/DefaultAdminBeanManager.java  | 35 ++++++++++----------
 1 file changed, 18 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/f31265aa/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java b/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
index e657c8f..ff94ccc 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/ui/admin/DefaultAdminBeanManager.java
@@ -1,4 +1,4 @@
-/* 
+/*
     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
@@ -14,7 +14,7 @@
     "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.  
+    under the License.
  */
 package org.apache.wiki.ui.admin;
 
@@ -37,25 +37,25 @@ import org.apache.log4j.Logger;
 import org.apache.wiki.Release;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.engine.AdminBeanManager;
-import org.apache.wiki.api.engine.PluginManager;
 import org.apache.wiki.event.WikiEngineEvent;
 import org.apache.wiki.event.WikiEvent;
 import org.apache.wiki.event.WikiEventListener;
 import org.apache.wiki.modules.WikiModuleInfo;
 import org.apache.wiki.ui.admin.beans.CoreBean;
+import org.apache.wiki.ui.admin.beans.FilterBean;
 import org.apache.wiki.ui.admin.beans.PluginBean;
 import org.apache.wiki.ui.admin.beans.SearchManagerBean;
 import org.apache.wiki.ui.admin.beans.UserBean;
 
 
 /**
- *  Provides a manager class for all AdminBeans within JSPWiki.  This class also manages registration for any 
+ *  Provides a manager class for all AdminBeans within JSPWiki.  This class also manages registration for any
  *  AdminBean which is also a JMX bean.
  *
  *  @since  2.5.52
  */
 public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanManager {
-	
+
     private WikiEngine m_engine;
     private ArrayList< AdminBean >  m_allBeans;
 
@@ -102,7 +102,7 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
 
 
     /**
-     *  Register an AdminBean.  If the AdminBean is also a JMX MBean, it also gets registered to the MBeanServer 
+     *  Register an AdminBean.  If the AdminBean is also a JMX MBean, it also gets registered to the MBeanServer
      *  we've found.
      *
      *  @param ab AdminBean to register.
@@ -147,9 +147,9 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
      *
      *  @param c Collection of WikiModuleInfo instances
      */
-    private void registerBeans( Collection c ) {
-        for( Iterator i = c.iterator(); i.hasNext(); ) {
-            String abname = ((WikiModuleInfo)i.next()).getAdminBeanClass();
+    private void registerBeans( Collection< WikiModuleInfo > c ) {
+        for( Iterator< WikiModuleInfo > i = c.iterator(); i.hasNext(); ) {
+            String abname = i.next().getAdminBeanClass();
 
             try {
                 if( abname != null && abname.length() > 0 ) {
@@ -173,16 +173,17 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
         m_allBeans = new ArrayList<AdminBean>();
 
         try {
-            registerAdminBean( new CoreBean(m_engine) );
-            registerAdminBean( new UserBean(m_engine) );
-            registerAdminBean( new SearchManagerBean(m_engine) );
-            registerAdminBean( new PluginBean(m_engine) );
+            registerAdminBean( new CoreBean( m_engine ) );
+            registerAdminBean( new UserBean( m_engine ) );
+            registerAdminBean( new SearchManagerBean( m_engine ) );
+            registerAdminBean( new PluginBean( m_engine ) );
+            registerAdminBean( new FilterBean( m_engine ) );
         } catch( NotCompliantMBeanException e ) {
             log.error( e.getMessage(), e );
         }
         registerBeans( m_engine.getEditorManager().modules() );
-        PluginManager pm = m_engine.getPluginManager();
-        registerBeans( pm.modules() );
+        registerBeans( m_engine.getPluginManager().modules() );
+        registerBeans( m_engine.getFilterManager().modules() );
     }
 
     /* (non-Javadoc)
@@ -214,7 +215,7 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
     }
 
     /**
-     *  Provides a JDK 1.5-compliant version of the MBeanServerFactory. This will simply bind to the 
+     *  Provides a JDK 1.5-compliant version of the MBeanServerFactory. This will simply bind to the
      *  platform MBeanServer.
      */
     private static final class MBeanServerFactory15 {
@@ -269,5 +270,5 @@ public class DefaultAdminBeanManager implements WikiEventListener, AdminBeanMana
             }
         }
     }
-    
+
 }


[10/10] jspwiki git commit: 2.10.3-git-41

Posted by ju...@apache.org.
2.10.3-git-41


Project: http://git-wip-us.apache.org/repos/asf/jspwiki/repo
Commit: http://git-wip-us.apache.org/repos/asf/jspwiki/commit/9e29c3c7
Tree: http://git-wip-us.apache.org/repos/asf/jspwiki/tree/9e29c3c7
Diff: http://git-wip-us.apache.org/repos/asf/jspwiki/diff/9e29c3c7

Branch: refs/heads/master
Commit: 9e29c3c7500109975c65c43de228dc9a62ad3d74
Parents: 76017e1
Author: juanpablo <ju...@apache.org>
Authored: Tue Aug 22 20:12:37 2017 +0200
Committer: juanpablo <ju...@apache.org>
Committed: Tue Aug 22 20:12:37 2017 +0200

----------------------------------------------------------------------
 ChangeLog                                       | 25 +++++++++++++++++---
 .../src/main/java/org/apache/wiki/Release.java  |  2 +-
 2 files changed, 23 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jspwiki/blob/9e29c3c7/ChangeLog
----------------------------------------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 6a5e137..4d17a42 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,11 +1,30 @@
+2017-08-22  Juan Pablo Santos (juanpablo AT apache DOT org)
+
+       * 2.10.3-git-41
+
+       * WysiwygEditingRenderer isn't hardcoded in JSPs anymore, and can be substituted
+         through jspwiki.renderingManager.renderer.wysiwyg property on jspwiki.properties.
+         This allows to develop custom renderers which do not expect the same information
+         as the existing ones.
+
+       * Fixed DefaultFilterManager#modules not returning Collection< WikiModuleInfo >,
+         as it was supposed to. This method wasn't used anywhere, until now, where it
+         is used through FilterBean, a new JSPWiki AdminBean exposing existing filters
+         information.
+
+       * FilterBean runs parallel to PluginBean, which allowed some more minor internal
+         refactorings and code polishing.
+
+       * Moved some constants from JSPWikiMarkupParser to MarkupParser.
+
 2017-07-16  Juan Pablo Santos (juanpablo AT apache DOT org)
 
        * 2.10.3-git-40
 
-       * Some small changes around JSPWikiMarkupParser, needed to develop 
-         custom markup parsers, which do not rely on the former class or 
+       * Some small changes around JSPWikiMarkupParser, needed to develop
+         custom markup parsers, which do not rely on the former class or
          WikiDocument.
-       
+
        * Some other minor internal refactorings and code polishing
 
 2017-05-14  Harry Metske (metskem@apache.org)

http://git-wip-us.apache.org/repos/asf/jspwiki/blob/9e29c3c7/jspwiki-war/src/main/java/org/apache/wiki/Release.java
----------------------------------------------------------------------
diff --git a/jspwiki-war/src/main/java/org/apache/wiki/Release.java b/jspwiki-war/src/main/java/org/apache/wiki/Release.java
index d70457c..43ce952 100644
--- a/jspwiki-war/src/main/java/org/apache/wiki/Release.java
+++ b/jspwiki-war/src/main/java/org/apache/wiki/Release.java
@@ -72,7 +72,7 @@ public final class Release {
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "40";
+    public static final String     BUILD         = "41";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of