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 2019/08/19 20:16:59 UTC

[jspwiki] branch master updated (849e9c2 -> e1975f3)

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 849e9c2  JSPWIKI-1115: migration from commons-lang 2.6 to 3.9 + commons-text 1.7 (2/2)
     new a4906d3  removal of @deprecated code (1) - AuthenticationManager: * some constants not used anymore -> deleted, no replacement available * login( WikiSession, String, String ) -> deleted use instead login( WikiSession, HttpServletRequest, String, String )
     new 7c03330  removal of @deprecated code (2) - AuthorizationManager: removed unused method
     new c7709c0  removal of @deprecated code (3) - GroupDatabase: removal of commit(), no replacement as the method wasn't used anymore
     new cac4d61  fix couple of probable concurrent issues if the XMLGroupDatabase is kept running around; format code
     new d198538  removal of @deprecated code (4) - CookieAssertionLoginModule: remove unused constant
     new f0e08d5  code format
     new c4bc572  removal of @deprecated code (5) - UserProfile: removed setWikiName(String), wasn't used anywhere
     new 018cbdd  removal of @deprecated code (6) - WikiEngineEvent: removed getWikiEngine(), use getEngine() instead
     new f78a215  code format
     new 2b2a879  removal of @deprecated code (7) - JSPWikiMarkupParser: * JSPWikiMarkupParser.isExternalLink(String) -> use instead LinkParsingOperations#isExternalLink(String) * JSPWikiMarkupParser.isPluginLink(String) -> use instead LinkParsingOperations#isPluginLink(String)
     new a80cd3c  removal of @deprecated code (8) - RSSGenerator: remove unused variables, a little bit of code format
     new 5f11314  removal of @deprecated code (9) - SearchManager: remove deprecated jspwiki.useLucene property
     new 4e3e778  removal of @deprecated code (10) - UserCheckTag: removal of exists attribute, use status instead
     new 9f1b363  removal of @deprecated code (11) - VariableManager: removal of isVariableLink(String), use LinkParsingOperations#isVariableLink(String) instead
     new de0d511  format code
     new 9e9ec9f  removal of @deprecated code (12) - WikiEngine: * removed WikiEngine.getEditURL -> use instead WikiEngine#getURL(String, String, String, boolean) or WikiContext#getURL(String, String) * removed WikiEngine.getAttachmentURL -> use instead WikiEngine#getURL(String, String, String, boolean) or WikiContext#getURL(String, String) * removed WikiEngine.safeGetParameter -> no replacement, no longer necessary
     new 15fbc8e  WikiEngine#getContentEncoding returns a Charset now, instead of a String + propagate the change
     new 22a7d52  small refactor of parseLong
     new f48280a  propagate changes from WikiEngine#getContentEncoding returning a Charset now
     new a7467bb  code format
     new 3600c98  removal of @deprecated code (13) - Editor: removed unused getUrl() method
     new 1ec4300  INFRA-18845: switch sonar instance to sonarcloud.io
     new efd7887  2.11.0-M5-git-10
     new e1975f3  fix date

The 24 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                                          |  11 +-
 Jenkinsfile                                        |   7 +-
 .../src/main/java/org/apache/wiki/Release.java     |   2 +-
 .../main/java/org/apache/wiki/VariableManager.java |  91 +++-------
 .../src/main/java/org/apache/wiki/WikiContext.java |  48 ++---
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 180 ++++---------------
 .../wiki/ajax/WikiAjaxDispatcherServlet.java       |   9 +-
 .../apache/wiki/auth/AuthenticationManager.java    |  50 ------
 .../org/apache/wiki/auth/AuthorizationManager.java | 116 +++++-------
 .../apache/wiki/auth/authorize/GroupDatabase.java  |  20 +--
 .../wiki/auth/authorize/JDBCGroupDatabase.java     |  15 --
 .../wiki/auth/authorize/XMLGroupDatabase.java      | 194 +++++++--------------
 .../wiki/auth/login/AbstractLoginModule.java       |  49 +++---
 .../auth/login/CookieAssertionLoginModule.java     |  20 +--
 .../wiki/auth/user/AbstractUserDatabase.java       |  74 +++-----
 .../apache/wiki/auth/user/DefaultUserProfile.java  |  13 --
 .../org/apache/wiki/auth/user/UserProfile.java     |   9 -
 .../org/apache/wiki/diff/ExternalDiffProvider.java |  42 +++--
 .../org/apache/wiki/event/WikiEngineEvent.java     |  51 ++----
 .../java/org/apache/wiki/filters/CreoleFilter.java |  36 ++--
 .../java/org/apache/wiki/filters/SpamFilter.java   |  50 +++---
 .../apache/wiki/parser/JSPWikiMarkupParser.java    |  33 ----
 .../java/org/apache/wiki/rss/RSSGenerator.java     |  78 +++------
 .../java/org/apache/wiki/search/SearchManager.java |  34 +---
 .../org/apache/wiki/tags/ContentEncodingTag.java   |  17 +-
 .../org/apache/wiki/tags/EditorIteratorTag.java    |  34 ++--
 .../java/org/apache/wiki/tags/UserCheckTag.java    | 120 ++++---------
 .../java/org/apache/wiki/ui/CommandResolver.java   |  40 ++---
 .../src/main/java/org/apache/wiki/ui/Editor.java   |  50 ++----
 .../java/org/apache/wiki/ui/EditorManager.java     |  21 ++-
 .../java/org/apache/wiki/ui/WikiJSPFilter.java     |   5 +-
 .../java/org/apache/wiki/ui/WikiServletFilter.java |  24 +--
 .../org/apache/wiki/url/DefaultURLConstructor.java | 139 ++++-----------
 .../org/apache/wiki/url/ShortURLConstructor.java   |  24 +--
 .../java/org/apache/wiki/url/URLConstructor.java   |  11 +-
 .../main/java/org/apache/wiki/util/FileUtil.java   | 119 ++++---------
 .../java/org/apache/wiki/util/FileUtilTest.java    |  36 ++--
 37 files changed, 562 insertions(+), 1310 deletions(-)


[jspwiki] 13/24: removal of @deprecated code (10) - UserCheckTag: removal of exists attribute, use status instead

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 4e3e77808ea8ea7255ad2dc562ae0c770d412afd
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Aug 17 01:28:49 2019 +0200

    removal of @deprecated code (10) - UserCheckTag: removal of exists attribute, use status instead
---
 .../java/org/apache/wiki/tags/UserCheckTag.java    | 120 ++++++---------------
 1 file changed, 35 insertions(+), 85 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
index 156e8ca..687d977 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/UserCheckTag.java
@@ -18,8 +18,6 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-
 import org.apache.wiki.WikiSession;
 import org.apache.wiki.auth.AuthenticationManager;
 
@@ -62,9 +60,8 @@ import org.apache.wiki.auth.AuthenticationManager;
  *
  *  @since 2.0
  */
-public class UserCheckTag
-    extends WikiTagBase
-{
+public class UserCheckTag extends WikiTagBase {
+
     private static final long serialVersionUID = 3256438110127863858L;
     private static final String ASSERTED = "asserted";
     private static final String AUTHENTICATED = "authenticated";
@@ -82,8 +79,7 @@ public class UserCheckTag
      *  {@inheritDoc}
      */
     @Override
-    public void initTag()
-    {
+    public void initTag() {
         super.initTag();
         m_status = null;
     }
@@ -103,116 +99,70 @@ public class UserCheckTag
      *  
      *  @param status The status to be checked.
      */
-    public void setStatus( String status )
+    public void setStatus( final String status )
     {
         m_status = status.toLowerCase();
     }
 
-
-    /**
-     *  Sets the "exists" attribute, which is converted on-the-fly into
-     *  an equivalent "status" -attribute.  This is only for backwards compatibility.
-     *
-     *  @param arg If true, works exactly as status = authenticated.  If false, works
-     *             as if status = anonymous.
-     *  @deprecated
-     */
-    public void setExists( String arg )
-    {
-        if("true".equals(arg))
-        {
-            m_status = AUTHENTICATED;
-        }
-        else
-        {
-            m_status = ANONYMOUS;
-        }
-    }
-
-
     /**
      * {@inheritDoc}
      * @see org.apache.wiki.tags.WikiTagBase#doWikiStartTag()
      */
     @Override
-    public final int doWikiStartTag()
-        throws IOException
-    {
-        WikiSession session = m_wikiContext.getWikiSession();
-        String status = session.getStatus();
-        AuthenticationManager mgr = m_wikiContext.getEngine().getAuthenticationManager();
-        boolean containerAuth = mgr.isContainerAuthenticated();
-        boolean cookieAssertions = mgr.allowsCookieAssertions();
-
-        if( m_status != null )
-        {
-            if ( ANONYMOUS.equals( m_status )) 
-            {
-                if (status.equals(WikiSession.ANONYMOUS))
-                {
+    public final int doWikiStartTag() {
+        final WikiSession session = m_wikiContext.getWikiSession();
+        final String status = session.getStatus();
+        final AuthenticationManager mgr = m_wikiContext.getEngine().getAuthenticationManager();
+        final boolean containerAuth = mgr.isContainerAuthenticated();
+        final boolean cookieAssertions = mgr.allowsCookieAssertions();
+
+        if( m_status != null ) {
+            switch( m_status ) {
+            case ANONYMOUS:
+                if( status.equals( WikiSession.ANONYMOUS ) ) {
                     return EVAL_BODY_INCLUDE;
                 }
-            }
-            else if( AUTHENTICATED.equals( m_status ))
-            { 
-                if (status.equals(WikiSession.AUTHENTICATED)) 
-                {
+                break;
+            case AUTHENTICATED:
+                if( status.equals( WikiSession.AUTHENTICATED ) ) {
                     return EVAL_BODY_INCLUDE;
                 }
-            }
-            else if( ASSERTED.equals( m_status )) 
-            { 
-                if (status.equals(WikiSession.ASSERTED)) 
-                {
+                break;
+            case ASSERTED:
+                if( status.equals( WikiSession.ASSERTED ) ) {
                     return EVAL_BODY_INCLUDE;
                 }
-            }
-            else if( ASSERTIONS_ALLOWED.equals( m_status ))
-            { 
-                if ( cookieAssertions )
-                {
+                break;
+            case ASSERTIONS_ALLOWED:
+                if( cookieAssertions ) {
                     return EVAL_BODY_INCLUDE;
                 }
                 return SKIP_BODY;
-            }
-            else if( ASSERTIONS_NOT_ALLOWED.equals( m_status ))
-            { 
-                if ( !cookieAssertions )
-                {
+            case ASSERTIONS_NOT_ALLOWED:
+                if( !cookieAssertions ) {
                     return EVAL_BODY_INCLUDE;
                 }
                 return SKIP_BODY;
-            }
-            else if( CONTAINER_AUTH.equals( m_status )) 
-            { 
-                if ( containerAuth )
-                {
+            case CONTAINER_AUTH:
+                if( containerAuth ) {
                     return EVAL_BODY_INCLUDE;
                 }
                 return SKIP_BODY;
-            }
-            else if( CUSTOM_AUTH.equals( m_status )) 
-            { 
-                if ( !containerAuth )
-                {
+            case CUSTOM_AUTH:
+                if( !containerAuth ) {
                     return EVAL_BODY_INCLUDE;
                 }
                 return SKIP_BODY;
-            }
-            else if( KNOWN.equals( m_status )) 
-            { 
-                if ( !session.isAnonymous() )
-                {
+            case KNOWN:
+                if( !session.isAnonymous() ) {
                     return EVAL_BODY_INCLUDE;
                 }
                 return SKIP_BODY;
-            }
-            else if( NOT_AUTHENTICATED.equals( m_status ))
-            { 
-                if (!status.equals(WikiSession.AUTHENTICATED)) 
-                {
+            case NOT_AUTHENTICATED:
+                if( !status.equals( WikiSession.AUTHENTICATED ) ) {
                     return EVAL_BODY_INCLUDE;
                 }
+                break;
             }
         }
 


[jspwiki] 11/24: removal of @deprecated code (8) - RSSGenerator: remove unused variables, a little bit of code format

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

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

commit a80cd3ca79c7d7394fe812ee8aad6bf45e99995f
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Aug 17 01:16:14 2019 +0200

    removal of @deprecated code (8) - RSSGenerator: remove unused variables, a little bit of code format
---
 .../java/org/apache/wiki/rss/RSSGenerator.java     | 78 ++++++----------------
 1 file changed, 21 insertions(+), 57 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
index 9010ae8..383bafa 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/RSSGenerator.java
@@ -18,12 +18,6 @@
  */
 package org.apache.wiki.rss;
 
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -37,6 +31,12 @@ import org.apache.wiki.auth.permissions.PagePermission;
 import org.apache.wiki.pages.PageTimeComparator;
 import org.apache.wiki.util.TextUtil;
 
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+
 /**
  *  The master class for generating different kinds of Feeds (including RSS1.0, 2.0 and Atom).
  *  <p>
@@ -54,8 +54,8 @@ import org.apache.wiki.util.TextUtil;
  */
 // FIXME: Limit diff and page content size.
 // FIXME3.0: This class would need a bit of refactoring.  Method names, e.g. are confusing.
-public class RSSGenerator
-{
+public class RSSGenerator {
+
     static Logger              log = Logger.getLogger( RSSGenerator.class );
     private WikiEngine         m_engine;
 
@@ -63,34 +63,22 @@ public class RSSGenerator
     private String             m_channelLanguage    = "en-us";
     private boolean            m_enabled = true;
 
-    /**
-     *  Parameter value to represent RSS 1.0 feeds.  Value is <tt>{@value}</tt>. 
-     */
+    /** Parameter value to represent RSS 1.0 feeds.  Value is <tt>{@value}</tt>. */
     public static final String RSS10 = "rss10";
 
-    /**
-     *  Parameter value to represent RSS 2.0 feeds.  Value is <tt>{@value}</tt>. 
-     */
+    /** Parameter value to represent RSS 2.0 feeds.  Value is <tt>{@value}</tt>. */
     public static final String RSS20 = "rss20";
     
-    /**
-     *  Parameter value to represent Atom feeds.  Value is <tt>{@value}</tt>. 
-     */
+    /** Parameter value to represent Atom feeds.  Value is <tt>{@value}</tt>.  */
     public static final String ATOM  = "atom";
 
-    /**
-     *  Parameter value to represent a 'blog' style feed. Value is <tt>{@value}</tt>.
-     */
+    /** Parameter value to represent a 'blog' style feed. Value is <tt>{@value}</tt>. */
     public static final String MODE_BLOG = "blog";
     
-    /**
-     *  Parameter value to represent a 'wiki' style feed. Value is <tt>{@value}</tt>.
-     */
+    /** Parameter value to represent a 'wiki' style feed. Value is <tt>{@value}</tt>. */
     public static final String MODE_WIKI = "wiki";
 
-    /**
-     *  Parameter value to represent a 'full' style feed. Value is <tt>{@value}</tt>.
-     */
+    /** Parameter value to represent a 'full' style feed. Value is <tt>{@value}</tt>. */
     public static final String MODE_FULL = "full";
 
     /**
@@ -101,15 +89,12 @@ public class RSSGenerator
     public static final String PROP_CHANNEL_DESCRIPTION = "jspwiki.rss.channelDescription";
 
     /**
-     *  Defines the property name for the RSS channel language.  Default value for the
-     *  language is "en-us".
+     *  Defines the property name for the RSS channel language.  Default value for the language is "en-us".
      *  @since 1.7.6.
      */
     public static final String PROP_CHANNEL_LANGUAGE    = "jspwiki.rss.channelLanguage";
 
-    /**
-     *  Defins the property name for the RSS channel title.  Value is <tt>{@value}</tt>.
-     */
+    /** Defines the property name for the RSS channel title.  Value is <tt>{@value}</tt>. */
     public static final String PROP_CHANNEL_TITLE       = "jspwiki.rss.channelTitle";
 
     /**
@@ -130,28 +115,12 @@ public class RSSGenerator
      */
     public static final String PROP_INTERVAL            = "jspwiki.rss.interval";
 
-    /**
-     *  Defines the property name for the RSS author.  Value is <tt>{@value}</tt>.
-     */
+    /** Defines the property name for the RSS author.  Value is <tt>{@value}</tt>. */
     public static final String PROP_RSS_AUTHOR          = "jspwiki.rss.author";
 
-    /**
-     *  Defines the property name for the RSS author email.  Value is <tt>{@value}</tt>.
-     */
+    /** Defines the property name for the RSS author email.  Value is <tt>{@value}</tt>. */
     public static final String PROP_RSS_AUTHOREMAIL     = "jspwiki.rss.author.email";
 
-    /**
-     *  Property name for the RSS copyright info.  Value is <tt>{@value}</tt>.
-     */
-    public static final String PROP_RSS_COPYRIGHT       = "jspwiki.rss.copyright";
-
-    /** Just for compatibilty.  @deprecated */
-    public static final String PROP_RSSAUTHOR           = PROP_RSS_AUTHOR;
-
-    /** Just for compatibilty.  @deprecated */
-    public static final String PROP_RSSAUTHOREMAIL      = PROP_RSS_AUTHOREMAIL;
-
-
     private static final int MAX_CHARACTERS             = Integer.MAX_VALUE-1;
 
     /**
@@ -161,15 +130,10 @@ public class RSSGenerator
      *  @param properties The properties.
      *  @throws NoRequiredPropertyException If something is missing from the given property set.
      */
-    public RSSGenerator( WikiEngine engine, Properties properties )
-        throws NoRequiredPropertyException
-    {
+    public RSSGenerator( WikiEngine engine, Properties properties ) {
         m_engine = engine;
-
-        m_channelDescription = properties.getProperty( PROP_CHANNEL_DESCRIPTION,
-                                                       m_channelDescription );
-        m_channelLanguage    = properties.getProperty( PROP_CHANNEL_LANGUAGE,
-                                                       m_channelLanguage );
+        m_channelDescription = properties.getProperty( PROP_CHANNEL_DESCRIPTION, m_channelDescription );
+        m_channelLanguage    = properties.getProperty( PROP_CHANNEL_LANGUAGE, m_channelLanguage );
     }
 
     /**


[jspwiki] 12/24: removal of @deprecated code (9) - SearchManager: remove deprecated jspwiki.useLucene property

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 5f113143facbbc39419a774ef3f02b3638245129
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Aug 17 01:22:42 2019 +0200

    removal of @deprecated code (9) - SearchManager: remove deprecated jspwiki.useLucene property
---
 .../java/org/apache/wiki/search/SearchManager.java | 34 +++-------------------
 1 file changed, 4 insertions(+), 30 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
index 46ad9eb..c8ac883 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/search/SearchManager.java
@@ -38,7 +38,6 @@ import org.apache.wiki.event.WikiPageEvent;
 import org.apache.wiki.modules.InternalModule;
 import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.util.ClassUtil;
-import org.apache.wiki.util.TextUtil;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
@@ -64,12 +63,7 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
 
     private static final String DEFAULT_SEARCHPROVIDER  = "org.apache.wiki.search.LuceneSearchProvider";
 
-    /** Old option, now deprecated. */
-    private static final String PROP_USE_LUCENE        = "jspwiki.useLucene";
-
-    /**
-     *  Property name for setting the search provider. Value is <tt>{@value}</tt>.
-     */
+    /** Property name for setting the search provider. Value is <tt>{@value}</tt>. */
     public static final String PROP_SEARCHPROVIDER     = "jspwiki.searchProvider";
 
     private SearchProvider    m_searchProvider;
@@ -279,31 +273,11 @@ public class SearchManager extends BasicPageFilter implements InternalModule, Wi
         }
     }
 
-    private void loadSearchProvider(Properties properties) {
+    private void loadSearchProvider( final Properties properties ) {
         //
-        // See if we're using Lucene, and if so, ensure that its
-        // index directory is up to date.
+        // See if we're using Lucene, and if so, ensure that its index directory is up to date.
         //
-        String useLucene = properties.getProperty(PROP_USE_LUCENE);
-
-        // FIXME: Obsolete, remove, or change logic to first load searchProvder?
-        // If the old jspwiki.useLucene property is set we use that instead of the searchProvider class.
-        if( useLucene != null )
-        {
-            log.info( PROP_USE_LUCENE+" is deprecated; please use "+PROP_SEARCHPROVIDER+"=<your search provider> instead." );
-            if( TextUtil.isPositive( useLucene ) )
-            {
-                m_searchProvider = new LuceneSearchProvider();
-            }
-            else
-            {
-                m_searchProvider = new BasicSearchProvider();
-            }
-            log.debug("useLucene was set, loading search provider " + m_searchProvider);
-            return;
-        }
-
-        String providerClassName = properties.getProperty( PROP_SEARCHPROVIDER, DEFAULT_SEARCHPROVIDER );
+        final String providerClassName = properties.getProperty( PROP_SEARCHPROVIDER, DEFAULT_SEARCHPROVIDER );
 
         try {
             Class<?> providerClass = ClassUtil.findClass( "org.apache.wiki.search", providerClassName );


[jspwiki] 09/24: code format

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

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

commit f78a215d6df88e4bc0b23e087b8b2bb6aec24bca
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Aug 16 20:46:51 2019 +0200

    code format
---
 .../java/org/apache/wiki/filters/CreoleFilter.java | 36 ++++++++--------------
 1 file changed, 12 insertions(+), 24 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/CreoleFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/CreoleFilter.java
index 0af9b7a..9e8fab4 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/CreoleFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/CreoleFilter.java
@@ -18,22 +18,22 @@
  */
 package org.apache.wiki.filters;
 
-import java.util.Properties;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
-import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.wiki.api.exceptions.FilterException;
+import org.apache.wiki.api.filters.BasicPageFilter;
 import org.apache.wiki.parser.CreoleToJSPWikiTranslator;
 
+import java.util.Properties;
+
 /**
  * <p>Provides the Implementation for mixed mode creole: If you activate
  * this filter, it will translate all markup that was saved as creole
  * markup to JSPWiki markup. Therefore the files will be saved 
  * with mixed markup.
  * <p>
- * <b>WARNING</b>: There's no turning back after insalling this
+ * <b>WARNING</b>: There's no turning back after installing this
  * filter. Since your wiki pages are saved in Creole markup you can
  * not deactivate it afterwards.
  * <p>
@@ -48,32 +48,25 @@ import org.apache.wiki.parser.CreoleToJSPWikiTranslator;
  * @see <a href="http://www.wikicreole.org/wiki/MixedMode">[[WikiCreole:MixedMode]]</a> 
  */
 
-public class CreoleFilter extends BasicPageFilter 
-{
+public class CreoleFilter extends BasicPageFilter {
     
     private static final Logger log = Logger.getLogger(CreoleFilter.class);
     
     /**
      *  {@inheritDoc}
      */
-    public void initialize(WikiEngine engine, Properties props) throws FilterException 
-    {
+    public void initialize(WikiEngine engine, Properties props) throws FilterException {
     }
 
     /**
      *  {@inheritDoc}
      */
-    public String preSave( WikiContext wikiContext, String content )
-    throws FilterException
-    {
-        try 
-        {
+    public String preSave( WikiContext wikiContext, String content ) {
+        try {
             String username=wikiContext.getCurrentUser().getName();
             Properties prop = wikiContext.getEngine().getWikiProperties();
             return new CreoleToJSPWikiTranslator().translateSignature(prop, content,username);
-        }
-        catch(Exception e )
-        {
+        } catch(Exception e ) {
             log.error( e.getMessage(), e );
             return e.getMessage();
         }
@@ -82,16 +75,11 @@ public class CreoleFilter extends BasicPageFilter
     /**
      *  {@inheritDoc}
      */
-    public String preTranslate(WikiContext wikiContext, String content)
-        throws FilterException 
-    {
-        try
-        {
+    public String preTranslate(WikiContext wikiContext, String content) {
+        try {
             Properties prop = wikiContext.getEngine().getWikiProperties();
             return new CreoleToJSPWikiTranslator().translate(prop ,content);
-        } 
-        catch (Exception e) 
-        {
+        } catch (Exception e) {
             log.error( e.getMessage(), e );
             return content
                    + "\n \n %%error \n"


[jspwiki] 22/24: INFRA-18845: switch sonar instance to sonarcloud.io

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 1ec43004eba670341f4cffc3f42788776e803efe
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Aug 19 22:11:49 2019 +0200

    INFRA-18845: switch sonar instance to sonarcloud.io
---
 Jenkinsfile | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 663a38e..c0ee4bb 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -36,9 +36,10 @@ try {
             dir( build ) {
                 git url: buildRepo, poll: true
                 withMaven(jdk: 'JDK 1.8 (latest)', maven: 'Maven 3 (latest)' ) {
-                    withSonarQubeEnv( 'ASF Sonar Analysis' ) {
-                        echo "Will use SonarQube instance at $SONAR_HOST_URL"
-                        sh "mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Pattach-additional-artifacts $SONAR_MAVEN_GOAL -up"
+                    withCredentials( [ string( credentialsId: 'sonarcloud-jspwiki', variable: 'SONAR_TOKEN' ) ] ) {
+                        def sonarOptions = '-Dsonar.projectKey=jspwiki-builder -Dsonar.organization=apache -Dsonar.host.url=https://sonarcloud.io' // sonar.login read from SONAR_TOKEN env var
+                        echo 'Will use SonarQube instance at https://sonarcloud.io'
+                        sh "mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install -Pattach-additional-artifacts sonar:sonar -up $sonarOptions"
                     }
                     pom = readMavenPom file: 'pom.xml'
                     writeFile file: 'target/classes/apidocs.txt', text: 'file created in order to allow aggregated javadoc generation, target/classes is needed for all modules'


[jspwiki] 16/24: removal of @deprecated code (12) - WikiEngine: * removed WikiEngine.getEditURL -> use instead WikiEngine#getURL(String, String, String, boolean) or WikiContext#getURL(String, String) * removed WikiEngine.getAttachmentURL -> use instead WikiEngine#getURL(String, String, String, boolean) or WikiContext#getURL(String, String) * removed WikiEngine.safeGetParameter -> no replacement, no longer necessary

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 9e9ec9fdcd3b5aa16c9a3643527c4a03db96cb95
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Aug 18 19:10:54 2019 +0200

    removal of @deprecated code (12) - WikiEngine:
    * removed WikiEngine.getEditURL -> use instead WikiEngine#getURL(String, String, String, boolean) or WikiContext#getURL(String, String)
    * removed WikiEngine.getAttachmentURL -> use instead WikiEngine#getURL(String, String, String, boolean) or WikiContext#getURL(String, String)
    * removed WikiEngine.safeGetParameter -> no replacement, no longer necessary
---
 .../src/main/java/org/apache/wiki/WikiContext.java |  20 ++-
 .../src/main/java/org/apache/wiki/WikiEngine.java  | 149 ++++-----------------
 2 files changed, 32 insertions(+), 137 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
index c443e21..503ac22 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -64,9 +64,8 @@ import java.util.PropertyPermission;
  *  @see org.apache.wiki.plugin.Counter
  *
  */
-public class WikiContext
-    implements Cloneable, Command
-{
+public class WikiContext implements Cloneable, Command {
+
     private    Command m_command = null;
 
     private    WikiPage   m_page;
@@ -600,7 +599,7 @@ public class WikiContext
      *  @param page The page to which to link
      *  @return An URL to the page, honours the absolute/relative setting in jspwiki.properties
      */
-    public String getURL( String context, String page ) {
+    public String getURL( final String context, final String page ) {
         return getURL( context, page, null );
     }
 
@@ -615,8 +614,8 @@ public class WikiContext
      *
      *  @return An URL to the given context and page.
      */
-    public String getURL( String context, String page, String params ) {
-        boolean absolute = "absolute".equals(m_engine.getVariable( this, WikiEngine.PROP_REFSTYLE ));
+    public String getURL( final String context, final String page, final String params ) {
+        final boolean absolute = "absolute".equals(m_engine.getVariable( this, WikiEngine.PROP_REFSTYLE ));
 
         // FIXME: is rather slow
         return m_engine.getURL( context, page, params, absolute );
@@ -638,10 +637,8 @@ public class WikiContext
      *  @return A shallow clone of the WikiContext
      */
     @Override
-	public Object clone()
-    {
-        try
-        {
+	public Object clone() {
+        try {
             // super.clone() must always be called to make sure that inherited objects
             // get the right type
             WikiContext copy = (WikiContext)super.clone();
@@ -656,8 +653,7 @@ public class WikiContext
             copy.m_page        = m_page;
             copy.m_realPage    = m_realPage;
             return copy;
-        }
-        catch( CloneNotSupportedException e ){} // Never happens
+        } catch( CloneNotSupportedException e ){} // Never happens
 
         return null;
     }
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 286bb7d..fad91ec 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -74,7 +74,6 @@ import org.apache.wiki.workflow.WorkflowManager;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletContext;
-import javax.servlet.ServletRequest;
 import javax.servlet.http.HttpServletRequest;
 import java.io.File;
 import java.io.IOException;
@@ -788,22 +787,16 @@ public class WikiEngine
      *  @since 1.6.1
      *  @return The Base URL.
      */
-
-    public String getBaseURL()
-    {
-    	String contextPath = m_servletContext.getContextPath();
-
-        return contextPath;
+    public String getBaseURL() {
+    	return m_servletContext.getContextPath();
     }
 
-
     /**
      *  Returns the moment when this engine was started.
      *
      *  @since 2.0.15.
      *  @return The start time of this wiki.
      */
-
     public Date getStartTime()
     {
         return (Date)m_startTime.clone();
@@ -822,49 +815,11 @@ public class WikiEngine
      * @param pageName The name of the page.  May be null, in which case defaults to the front page.
      * @return An absolute URL to the page.
      */
-    public String getViewURL( String pageName )
-    {
-        if( pageName == null )
-        {
+    public String getViewURL( String pageName ) {
+        if( pageName == null ) {
             pageName = getFrontPage();
         }
-        return getURLConstructor().makeURL(WikiContext.VIEW, pageName, "absolute".equals(PROP_REFSTYLE), null);
-    }
-
-    /**
-     *  Returns the basic URL to an editor.  Please use WikiContext.getURL() or
-     *  WikiEngine.getURL() instead.
-     *
-     *  @see #getURL(String, String, String, boolean)
-     *  @see WikiContext#getURL(String, String)
-     *  @deprecated
-     *
-     *  @param pageName The name of the page.
-     *  @return An URI.
-     *
-     *  @since 2.0.3
-     */
-    @Deprecated
-    public String getEditURL( String pageName )
-    {
-        return m_urlConstructor.makeURL( WikiContext.EDIT, pageName, false, null );
-    }
-
-    /**
-     *  Returns the basic attachment URL.Please use WikiContext.getURL() or
-     *  WikiEngine.getURL() instead.
-     *
-     *  @see #getURL(String, String, String, boolean)
-     *  @see WikiContext#getURL(String, String)
-     *  @since 2.0.42.
-     *  @param attName Attachment name
-     *  @deprecated
-     *  @return An URI.
-     */
-    @Deprecated
-    public String getAttachmentURL( String attName )
-    {
-        return m_urlConstructor.makeURL( WikiContext.ATTACH, attName, false, null );
+        return getURLConstructor().makeURL( WikiContext.VIEW, pageName, "absolute".equals( PROP_REFSTYLE ), null );
     }
 
     /**
@@ -876,9 +831,10 @@ public class WikiEngine
      *  @param absolute If true, will generate an absolute URL regardless of properties setting.
      *  @return An URL (absolute or relative).
      */
-    public String getURL( String context, String pageName, String params, boolean absolute )
-    {
-        if( pageName == null ) pageName = getFrontPage();
+    public String getURL( final String context, String pageName, final String params, final boolean absolute ) {
+        if( pageName == null ) {
+            pageName = getFrontPage();
+        }
         return m_urlConstructor.makeURL( context, pageName, absolute, params );
     }
 
@@ -908,49 +864,6 @@ public class WikiEngine
     }
 
     /**
-     *  This is a safe version of the Servlet.Request.getParameter() routine.
-     *  Unfortunately, the default version always assumes that the incoming
-     *  character set is ISO-8859-1, even though it was something else.
-     *  This means that we need to make a new string using the correct
-     *  encoding.
-     *  <P>
-     *  For more information, see:
-     *     <A HREF="http://www.jguru.com/faq/view.jsp?EID=137049">JGuru FAQ</A>.
-     *  <P>
-     *  Incidentally, this is almost the same as encodeName(), below.
-     *  I am not yet entirely sure if it's safe to merge the code.
-     *
-     *  @param request The servlet request
-     *  @param name    The parameter name to get.
-     *  @return The parameter value or null
-     *  @since 1.5.3
-     *  @deprecated JSPWiki now requires servlet API 2.3, which has a better
-     *              way of dealing with this stuff.  This will be removed in
-     *              the near future.
-     */
-
-    @Deprecated
-    public String safeGetParameter( ServletRequest request, String name )
-    {
-        try
-        {
-            String res = request.getParameter( name );
-            if( res != null )
-            {
-                res = new String(res.getBytes( StandardCharsets.ISO_8859_1), getContentEncoding() );
-            }
-
-            return res;
-        }
-        catch( UnsupportedEncodingException e )
-        {
-            log.fatal( "Unsupported encoding", e );
-            return "";
-        }
-
-    }
-
-    /**
      *  Returns the query string (the portion after the question mark).
      *
      *  @param request The HTTP request to parse.
@@ -959,33 +872,25 @@ public class WikiEngine
      *
      *  @since 2.1.3
      */
-    public String safeGetQueryString( HttpServletRequest request )
-    {
-        if (request == null)
-        {
+    public String safeGetQueryString( final HttpServletRequest request ) {
+        if (request == null) {
             return "";
         }
 
-        try
-        {
+        try {
             String res = request.getQueryString();
-            if( res != null )
-            {
-                res = new String(res.getBytes("ISO-8859-1"),
-                                 getContentEncoding() );
+            if( res != null ) {
+                res = new String( res.getBytes( StandardCharsets.ISO_8859_1 ), getContentEncoding() );
 
                 //
                 // Ensure that the 'page=xyz' attribute is removed
-                // FIXME: Is it really the mandate of this routine to
-                //        do that?
+                // FIXME: Is it really the mandate of this routine to do that?
                 //
-                int pos1 = res.indexOf("page=");
-                if (pos1 >= 0)
-                {
-                    String tmpRes = res.substring(0, pos1);
-                    int pos2 = res.indexOf("&",pos1) + 1;
-                    if ( (pos2 > 0) && (pos2 < res.length()) )
-                    {
+                final int pos1 = res.indexOf("page=");
+                if( pos1 >= 0 ) {
+                    String tmpRes = res.substring( 0, pos1 );
+                    final int pos2 = res.indexOf( "&",pos1 ) + 1;
+                    if ( ( pos2 > 0 ) && ( pos2 < res.length() ) ) {
                         tmpRes = tmpRes + res.substring(pos2);
                     }
                     res = tmpRes;
@@ -993,9 +898,7 @@ public class WikiEngine
             }
 
             return res;
-        }
-        catch( UnsupportedEncodingException e )
-        {
+        } catch( UnsupportedEncodingException e ) {
             log.fatal( "Unsupported encoding", e );
             return "";
         }
@@ -1293,14 +1196,10 @@ public class WikiEngine
      *  @return A decoded string.
      *  @see #encodeName(String)
      */
-    public String decodeName( String pagerequest )
-    {
-        try
-        {
+    public String decodeName( final String pagerequest ) {
+        try {
             return URLDecoder.decode( pagerequest, m_useUTF8 ? "UTF-8" : "ISO-8859-1" );
-        }
-        catch( UnsupportedEncodingException e )
-        {
+        } catch( UnsupportedEncodingException e ) {
             throw new InternalWikiException("ISO-8859-1 not a supported encoding!?!  Your platform is borked.", e);
         }
     }


[jspwiki] 15/24: format code

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

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

commit de0d511979b1cc976d776dac6be32598f21249a1
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Aug 18 18:56:30 2019 +0200

    format code
---
 .../src/main/java/org/apache/wiki/WikiContext.java | 32 ++++++++--------------
 1 file changed, 11 insertions(+), 21 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
index 321e818..c443e21 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiContext.java
@@ -18,15 +18,6 @@
  */
 package org.apache.wiki;
 
-import java.security.Permission;
-import java.security.Principal;
-import java.util.HashMap;
-import java.util.PropertyPermission;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-import javax.servlet.jsp.PageContext;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.auth.NoSuchPrincipalException;
 import org.apache.wiki.auth.UserManager;
@@ -42,6 +33,14 @@ import org.apache.wiki.ui.PageCommand;
 import org.apache.wiki.ui.WikiCommand;
 import org.apache.wiki.util.TextUtil;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import javax.servlet.jsp.PageContext;
+import java.security.Permission;
+import java.security.Principal;
+import java.util.HashMap;
+import java.util.PropertyPermission;
+
 /**
  *  <p>Provides state information throughout the processing of a page.  A
  *  WikiContext is born when the JSP pages that are the main entry
@@ -601,9 +600,7 @@ public class WikiContext
      *  @param page The page to which to link
      *  @return An URL to the page, honours the absolute/relative setting in jspwiki.properties
      */
-    public String getURL( String context,
-                          String page )
-    {
+    public String getURL( String context, String page ) {
         return getURL( context, page, null );
     }
 
@@ -618,18 +615,11 @@ public class WikiContext
      *
      *  @return An URL to the given context and page.
      */
-    public String getURL( String context,
-                          String page,
-                          String params )
-    {
+    public String getURL( String context, String page, String params ) {
         boolean absolute = "absolute".equals(m_engine.getVariable( this, WikiEngine.PROP_REFSTYLE ));
 
         // FIXME: is rather slow
-        return m_engine.getURL( context,
-                                page,
-                                params,
-                                absolute );
-
+        return m_engine.getURL( context, page, params, absolute );
     }
 
     /**


[jspwiki] 20/24: code format

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

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

commit a7467bbff0194de8d90a45c1341e016909544363
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Aug 18 20:56:00 2019 +0200

    code format
---
 .../org/apache/wiki/tags/EditorIteratorTag.java    | 34 +++++++++-------------
 .../src/main/java/org/apache/wiki/ui/Editor.java   | 27 ++++++++---------
 .../java/org/apache/wiki/ui/EditorManager.java     | 21 +++++++------
 3 files changed, 35 insertions(+), 47 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/EditorIteratorTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/EditorIteratorTag.java
index 27e1995..690fe91 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/EditorIteratorTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/EditorIteratorTag.java
@@ -18,43 +18,35 @@
  */
 package org.apache.wiki.tags;
 
-import java.util.ArrayList;
-import java.util.Collection;
-
 import org.apache.log4j.Logger;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.ui.Editor;
 import org.apache.wiki.ui.EditorManager;
 
+import java.util.ArrayList;
+import java.util.Collection;
+
 /**
  *  Iterates through editors.
  *
  *  @since 2.4.12
  */
 
-public class EditorIteratorTag
-    extends IteratorTag
-{
-    private static final long serialVersionUID = 0L;
+public class EditorIteratorTag extends IteratorTag  {
 
-    static    Logger    log = Logger.getLogger( EditorIteratorTag.class );
+    private static final long serialVersionUID = 0L;
+    private static final Logger log = Logger.getLogger( EditorIteratorTag.class );
 
-    public final int doStartTag()
-    {
+    public final int doStartTag() {
         m_wikiContext = WikiContext.findContext(pageContext);
+        final WikiEngine engine = m_wikiContext.getEngine();
+        final EditorManager mgr = engine.getEditorManager();
+        final String[] editorList = mgr.getEditorList();
+        final Collection< Editor > editors = new ArrayList<>();
 
-        WikiEngine engine = m_wikiContext.getEngine();
-        EditorManager mgr    = engine.getEditorManager();
-
-        String[] editorList = mgr.getEditorList();
-
-        Collection<Editor> editors = new ArrayList<Editor>();
-
-        for ( int i = 0; i < editorList.length; i++ )
-        {
-            editors.add(new Editor(m_wikiContext, editorList[i]));
+        for ( int i = 0; i < editorList.length; i++ ) {
+            editors.add( new Editor( m_wikiContext, editorList[ i ] ) );
         }
         setList( editors );
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java
index efc2b4a..e730be6 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java
@@ -25,14 +25,13 @@ import org.apache.wiki.WikiContext;
  *
  *  @since 2.4.12
  */
-public class Editor
-{
-    private String m_editorName;
-    private WikiContext m_wikiContext;
-    private EditorManager m_editorManager;
+public class Editor {
 
-    public Editor( WikiContext wikiContext, String editorName )
-    {
+    private final String m_editorName;
+    private final WikiContext m_wikiContext;
+    private final EditorManager m_editorManager;
+
+    public Editor( final WikiContext wikiContext, final String editorName ) {
         m_wikiContext = wikiContext;
         m_editorName = editorName;
         m_editorManager = wikiContext.getEngine().getEditorManager();
@@ -47,16 +46,15 @@ public class Editor
     /** @deprecated */
     public String getURL()
     {
-        String uri = m_wikiContext.getHttpRequest().getRequestURI();
+        final String uri = m_wikiContext.getHttpRequest().getRequestURI();
         String para = m_wikiContext.getHttpRequest().getQueryString();
 
         // if para already contains editor parameter, replace instead of append it
         // FIXME: Should cut out parameter instead of simple setting strin to null, maybe
         // in futur releases it may change and theres the danger that trailing parameters get lost
-        int idx = para.indexOf(EditorManager.PARA_EDITOR + "=");
-        if (idx >= 0)
-        {
-            para = para.substring(0, idx-1);
+        final int idx = para.indexOf( EditorManager.PARA_EDITOR + "=" );
+        if( idx >= 0 ) {
+            para = para.substring( 0, idx - 1 );
         }
 
         return uri + "?" + para + "&amp;" + EditorManager.PARA_EDITOR + "=" + m_editorName;
@@ -71,13 +69,12 @@ public class Editor
         return isSelected( "selected='selected'", "" );
     }
 
-    public String isSelected( String ifSelected )
+    public String isSelected( final String ifSelected )
     {
         return isSelected( ifSelected, "" );
     }
 
-    public String isSelected( String ifSelected, String ifNotSelected )
-    {
+    public String isSelected( final String ifSelected, final String ifNotSelected ) {
         if ( m_editorName.equals(m_editorManager.getEditorName(m_wikiContext) ) )
         {
             return ifSelected;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
index ed5895f..c66e810 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/EditorManager.java
@@ -18,16 +18,6 @@
  */
 package org.apache.wiki.ui;
 
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import javax.servlet.jsp.PageContext;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -38,6 +28,15 @@ import org.apache.wiki.preferences.Preferences;
 import org.apache.wiki.util.XmlUtil;
 import org.jdom2.Element;
 
+import javax.servlet.jsp.PageContext;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
 
 /**
  *  Defines an editor manager.  An editor can be added by adding a
@@ -106,7 +105,7 @@ public class EditorManager extends ModuleManager {
      */
     private void registerEditors() {
         log.info( "Registering editor modules" );
-        m_editors = new HashMap<String, WikiEditorInfo>();
+        m_editors = new HashMap<>();
 
         //
         // Register all editors which have created a resource containing its properties.


[jspwiki] 01/24: removal of @deprecated code (1) - AuthenticationManager: * some constants not used anymore -> deleted, no replacement available * login( WikiSession, String, String ) -> deleted use instead login( WikiSession, HttpServletRequest, String, String )

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 a4906d3f7d420edccda842e0a70738126af0224d
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Aug 16 20:11:00 2019 +0200

    removal of @deprecated code (1) - AuthenticationManager:
    * some constants not used anymore -> deleted, no replacement available
    * login( WikiSession, String, String ) -> deleted use instead login( WikiSession, HttpServletRequest, String, String )
---
 .../apache/wiki/auth/AuthenticationManager.java    | 50 ----------------------
 1 file changed, 50 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
index 0fb3a18..b9eb341 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthenticationManager.java
@@ -93,29 +93,6 @@ public class AuthenticationManager {
     /** If this jspwiki.properties property is <code>true</code>, allow cookies to be used for authentication. */
     public static final String                 PROP_ALLOW_COOKIE_AUTH = "jspwiki.cookieAuthentication";
     
-    /**
-     *  This property determines whether we use JSPWiki authentication or not.
-     *  Possible values are AUTH_JAAS or AUTH_CONTAINER.
-     *  <p>
-     *  Setting this is now deprecated - we do not guarantee that it works.
-     *  
-     * @deprecated - to be removed on 2.11.0
-     */
-    @Deprecated
-    public  static final String                PROP_SECURITY       = "jspwiki.security";
-
-    /** Value specifying that the user wants to use the container-managed security, just like in JSPWiki 2.2.
-     * @deprecated - to be removed on 2.11.0
-      */
-    @Deprecated
-    public static final String                SECURITY_OFF      = "off";
-
-    /** Value specifying that the user wants to use the built-in JAAS-based system.
-     * @deprecated - to be removed on 2.11.0
-     */
-    @Deprecated
-    public static final String                SECURITY_JAAS     = "jaas";
-
     /** Whether logins should be throttled to limit brute-forcing attempts. Defaults to true. */
     public static final String                 PROP_LOGIN_THROTTLING = "jspwiki.login.throttling";
 
@@ -140,14 +117,6 @@ public class AuthenticationManager {
      * initialized by {@link #initialize(WikiEngine, Properties)}. */
     protected Map<String,String> m_loginModuleOptions = new HashMap<String,String>();
 
-    /** Just to provide compatibility with the old versions.  The same
-     *  as SECURITY_OFF.
-     *
-     *  @deprecated use {@link #SECURITY_OFF} instead - to be removed on 2.11.0
-     */
-    @Deprecated
-    protected static final String             SECURITY_CONTAINER = "container";
-
     /** The default {@link javax.security.auth.spi.LoginModule} class name to use for custom authentication. */
     private static final String                 DEFAULT_LOGIN_MODULE = "org.apache.wiki.auth.login.UserDatabaseLoginModule";
     
@@ -341,25 +310,6 @@ public class AuthenticationManager {
     
     /**
      * Attempts to perform a WikiSession login for the given username/password
-     * combination using JSPWiki's custom authentication mode. This method is identical to
-     * {@link #login(WikiSession, String, String)}, except that user's HTTP request is not made available
-     * to LoginModules via the {@link org.apache.wiki.auth.login.HttpRequestCallback}.
-     * @param session the current wiki session; may not be <code>null</code>.
-     * @param username The user name. This is a login name, not a WikiName. In
-     *            most cases they are the same, but in some cases, they might
-     *            not be.
-     * @param password the password
-     * @return true, if the username/password is valid
-     * @throws org.apache.wiki.auth.WikiSecurityException if the Authorizer or UserManager cannot be obtained
-     * @deprecated use {@link #login(WikiSession, HttpServletRequest, String, String)} instead
-     */
-    public boolean login( WikiSession session, String username, String password ) throws WikiSecurityException
-    {
-        return login( session, null, username, password );
-    }
-    
-    /**
-     * Attempts to perform a WikiSession login for the given username/password
      * combination using JSPWiki's custom authentication mode. In order to log in,
      * the JAAS LoginModule supplied by the WikiEngine property {@link #PROP_LOGIN_MODULE}
      * will be instantiated, and its


[jspwiki] 05/24: removal of @deprecated code (4) - CookieAssertionLoginModule: remove unused constant

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 d1985387b5a961f5dfd5f90f80fea47bbc420194
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Aug 16 20:30:11 2019 +0200

    removal of @deprecated code (4) - CookieAssertionLoginModule: remove unused constant
---
 .../wiki/auth/login/CookieAssertionLoginModule.java  | 20 +++++++-------------
 1 file changed, 7 insertions(+), 13 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAssertionLoginModule.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAssertionLoginModule.java
index 429eb1a..4e490fa 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAssertionLoginModule.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/CookieAssertionLoginModule.java
@@ -18,7 +18,10 @@
  */
 package org.apache.wiki.auth.login;
 
-import java.io.IOException;
+import org.apache.log4j.Logger;
+import org.apache.wiki.auth.WikiPrincipal;
+import org.apache.wiki.util.HttpUtil;
+import org.apache.wiki.util.TextUtil;
 
 import javax.security.auth.callback.Callback;
 import javax.security.auth.callback.UnsupportedCallbackException;
@@ -28,11 +31,7 @@ import javax.servlet.http.Cookie;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import javax.servlet.http.HttpSession;
-
-import org.apache.log4j.Logger;
-import org.apache.wiki.auth.WikiPrincipal;
-import org.apache.wiki.util.HttpUtil;
-import org.apache.wiki.util.TextUtil;
+import java.io.IOException;
 
 /**
  * <p>
@@ -55,17 +54,12 @@ import org.apache.wiki.util.TextUtil;
  * @see CookieAuthenticationLoginModule
  * @since 2.3
  */
-public class CookieAssertionLoginModule extends AbstractLoginModule
-{
+public class CookieAssertionLoginModule extends AbstractLoginModule {
 
     /** The name of the cookie that gets stored to the user browser. */
     public static final String PREFS_COOKIE_NAME = "JSPWikiAssertedName";
 
-    /** Believed to be unused.
-     *  @deprecated */
-    public static final String PROMPT            = "User name";
-
-    protected static final Logger    log         = Logger.getLogger( CookieAssertionLoginModule.class );
+    protected static final Logger log = Logger.getLogger( CookieAssertionLoginModule.class );
 
     /**
      * Logs in the user by calling back to the registered CallbackHandler with


[jspwiki] 10/24: removal of @deprecated code (7) - JSPWikiMarkupParser: * JSPWikiMarkupParser.isExternalLink(String) -> use instead LinkParsingOperations#isExternalLink(String) * JSPWikiMarkupParser.isPluginLink(String) -> use instead LinkParsingOperations#isPluginLink(String)

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 2b2a8792c1acebf932b57bfcb894009c741b11ae
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Aug 17 01:15:05 2019 +0200

    removal of @deprecated code (7) - JSPWikiMarkupParser:
    * JSPWikiMarkupParser.isExternalLink(String) -> use instead LinkParsingOperations#isExternalLink(String)
    * JSPWikiMarkupParser.isPluginLink(String) -> use instead LinkParsingOperations#isPluginLink(String)
---
 .../apache/wiki/parser/JSPWikiMarkupParser.java    | 33 ----------------------
 1 file changed, 33 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
index f0b9ab5..9e548b5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/parser/JSPWikiMarkupParser.java
@@ -440,39 +440,6 @@ public class JSPWikiMarkupParser extends MarkupParser {
         return el;
     }
 
-
-    /**
-     *  Figures out if a link is an off-site link.  This recognizes
-     *  the most common protocols by checking how it starts.
-     *
-     *  @param link The link to check.
-     *  @return true, if this is a link outside of this wiki.
-     *  @since 2.4
-     *  @deprecated - use {@link LinkParsingOperations#isExternalLink(String)} instead.
-     */
-    @Deprecated
-    public static boolean isExternalLink( String link )
-    {
-        return new LinkParsingOperations(null).isExternalLink( link );
-    }
-
-    /**
-     *  Returns true if the link is really command to insert
-     *  a plugin.
-     *  <P>
-     *  Currently we just check if the link starts with "{INSERT",
-     *  or just plain "{" but not "{$".
-     *
-     *  @param link Link text, i.e. the contents of text between [].
-     *  @return True, if this link seems to be a command to insert a plugin here.
-     *  @deprecated Use {@link LinkParsingOperations#isPluginLink(String)} instead,
-     */
-    @Deprecated
-    public static boolean isPluginLink( String link )
-    {
-        return new LinkParsingOperations( null ).isPluginLink( link );
-    }
-
     /**
      *  These are all of the HTML 4.01 block-level elements.
      */


[jspwiki] 02/24: removal of @deprecated code (2) - AuthorizationManager: removed unused method

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

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

commit 7c033301cdcb65be3ea706046a1267bf7fcbd181
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Aug 16 20:13:03 2019 +0200

    removal of @deprecated code (2) - AuthorizationManager: removed unused method
---
 .../org/apache/wiki/auth/AuthorizationManager.java | 51 ++++++++--------------
 1 file changed, 19 insertions(+), 32 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
index d37b629..a892249 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
@@ -19,26 +19,6 @@
 package org.apache.wiki.auth;
 
 
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.security.AccessControlException;
-import java.security.AccessController;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.Principal;
-import java.security.PrivilegedAction;
-import java.security.ProtectionDomain;
-import java.security.cert.Certificate;
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.Properties;
-import java.util.ResourceBundle;
-import java.util.WeakHashMap;
-
-import javax.servlet.http.HttpServletResponse;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -63,6 +43,25 @@ import org.apache.wiki.tags.WikiTagBase;
 import org.apache.wiki.util.ClassUtil;
 import org.freshcookies.security.policy.LocalPolicy;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+import java.net.URL;
+import java.security.AccessControlException;
+import java.security.AccessController;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.Principal;
+import java.security.PrivilegedAction;
+import java.security.ProtectionDomain;
+import java.security.cert.Certificate;
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.Map;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.WeakHashMap;
+
 /**
  * <p>Manages all access control and authorization; determines what authenticated
  * users are allowed to do.</p>
@@ -497,18 +496,6 @@ public class AuthorizationManager {
     }
 
     /**
-     * Returns <code>true</code> if JSPWiki's JAAS authorization system
-     * is used for authorization in addition to container controls.
-     * @return the result
-     * @deprecated functionality deprecated - returns true always. To be removed on 2.11.0
-     */
-    @Deprecated
-    protected boolean isJAASAuthorized()
-    {
-        return true;
-    }
-
-    /**
      * Attempts to locate and initialize a Authorizer to use with this manager.
      * Throws a WikiException if no entry is found, or if one fails to
      * initialize.


[jspwiki] 19/24: propagate changes from WikiEngine#getContentEncoding returning a Charset now

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 f48280a66d5b75b4bcb761e5a2eabd7ed850b4cb
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Aug 18 20:55:40 2019 +0200

    propagate changes from WikiEngine#getContentEncoding returning a Charset now
---
 .../main/java/org/apache/wiki/util/FileUtil.java   | 119 ++++++---------------
 .../java/org/apache/wiki/util/FileUtilTest.java    |  36 ++-----
 2 files changed, 46 insertions(+), 109 deletions(-)

diff --git a/jspwiki-util/src/main/java/org/apache/wiki/util/FileUtil.java b/jspwiki-util/src/main/java/org/apache/wiki/util/FileUtil.java
index 3ea3708..30c1354 100644
--- a/jspwiki-util/src/main/java/org/apache/wiki/util/FileUtil.java
+++ b/jspwiki-util/src/main/java/org/apache/wiki/util/FileUtil.java
@@ -18,6 +18,8 @@
  */
 package org.apache.wiki.util;
 
+import org.apache.log4j.Logger;
+
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -37,14 +39,13 @@ import java.nio.charset.CharacterCodingException;
 import java.nio.charset.Charset;
 import java.nio.charset.CharsetDecoder;
 import java.nio.charset.CodingErrorAction;
-
-import org.apache.log4j.Logger;
+import java.nio.charset.StandardCharsets;
 
 /**
  *  Generic utilities related to file and stream handling.
  */
-public final class FileUtil
-{
+public final class FileUtil {
+
     /** Size of the buffer used when copying large chunks of data. */
     private static final int      BUFFER_SIZE = 4096;
     private static final Logger   log         = Logger.getLogger(FileUtil.class);
@@ -66,52 +67,31 @@ public final class FileUtil
      *  @throws IOException If the content creation failed.
      *  @see java.io.File#createTempFile(String,String,File)
      */
-    public static File newTmpFile( String content, String encoding )
-        throws IOException
-    {
-        Writer out = null;
-        Reader in  = null;
-        File   f   = null;
-
-        try
-        {
-            f = File.createTempFile( "jspwiki", null );
-
-            in = new StringReader( content );
-
-            out = new OutputStreamWriter( new FileOutputStream( f ),
-                                          encoding );
-
+    public static File newTmpFile( final String content, final Charset encoding ) throws IOException {
+        final File f = File.createTempFile( "jspwiki", null );
+        try( final Reader in = new StringReader( content );
+             final Writer out = new OutputStreamWriter( new FileOutputStream( f ), encoding ) ) {
             copyContents( in, out );
         }
-        finally
-        {
-            if( in  != null ) in.close();
-            if( out != null ) out.close();
-        }
 
         return f;
     }
 
     /**
-     *  Creates a new temporary file using the default encoding
-     *  of ISO-8859-1 (Latin1).
+     *  Creates a new temporary file using the default encoding of ISO-8859-1 (Latin1).
      *
      *  @param content The content to put into the file.
      *  @throws IOException If writing was unsuccessful.
      *  @return A handle to the newly created file.
-     *  @see #newTmpFile( String, String )
+     *  @see #newTmpFile( String, Charset )
      *  @see java.io.File#createTempFile(String,String,File)
      */
-    public static File newTmpFile( String content )
-        throws IOException
-    {
-        return newTmpFile( content, "ISO-8859-1" );
+    public static File newTmpFile( final String content ) throws IOException {
+        return newTmpFile( content, StandardCharsets.ISO_8859_1 );
     }
 
     /**
-     *  Runs a simple command in given directory.
-     *  The environment is inherited from the parent process (e.g. the
+     *  Runs a simple command in given directory. The environment is inherited from the parent process (e.g. the
      *  one in which this Java VM runs).
      *
      *  @return Standard output from the command.
@@ -120,51 +100,32 @@ public final class FileUtil
      *  @throws IOException If the command failed
      *  @throws InterruptedException If the command was halted
      */
-    public static String runSimpleCommand( String command, String directory )
-        throws IOException,
-               InterruptedException
-    {
-    	StringBuilder result = new StringBuilder();
-
-        log.info("Running simple command "+command+" in "+directory);
-
-        Process process = Runtime.getRuntime().exec( command, null, new File(directory) );
-
-        BufferedReader stdout = null;
-        BufferedReader stderr = null;
-
-        try
-        {
-            stdout = new BufferedReader( new InputStreamReader(process.getInputStream()) );
-            stderr = new BufferedReader( new InputStreamReader(process.getErrorStream()) );
+    public static String runSimpleCommand( final String command, final String directory ) throws IOException, InterruptedException {
+        log.info( "Running simple command " + command + " in " + directory );
+        final StringBuilder result = new StringBuilder();
+        final Process process = Runtime.getRuntime().exec( command, null, new File( directory ) );
 
+        try( final BufferedReader stdout = new BufferedReader( new InputStreamReader( process.getInputStream() ) );
+             final BufferedReader stderr = new BufferedReader( new InputStreamReader( process.getErrorStream() ) ) ) {
             String line;
 
-            while( (line = stdout.readLine()) != null )
-            {
+            while( (line = stdout.readLine()) != null ) {
                 result.append( line+"\n");
             }
 
-            StringBuilder error = new StringBuilder();
-            while( (line = stderr.readLine()) != null )
-            {
+            final StringBuilder error = new StringBuilder();
+            while( (line = stderr.readLine()) != null ) {
                 error.append( line+"\n");
             }
 
-            if( error.length() > 0 )
-            {
+            if( error.length() > 0 ) {
                 log.error("Command failed, error stream is: "+error);
             }
 
             process.waitFor();
-
-        }
-        finally
-        {
+        } finally {
             // we must close all by exec(..) opened streams: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4784692
             process.getInputStream().close();
-            if( stdout != null ) stdout.close();
-            if( stderr != null ) stderr.close();
         }
 
         return result.toString();
@@ -172,46 +133,36 @@ public final class FileUtil
 
 
     /**
-     *  Just copies all characters from <I>in</I> to <I>out</I>.  The copying
-     *  is performed using a buffer of bytes.
+     *  Just copies all characters from <I>in</I> to <I>out</I>.  The copying is performed using a buffer of bytes.
      *
      *  @since 1.5.8
      *  @param in The reader to copy from
      *  @param out The reader to copy to
      *  @throws IOException If reading or writing failed.
      */
-    public static void copyContents( Reader in, Writer out )
-        throws IOException
-    {
+    public static void copyContents( final Reader in, final Writer out ) throws IOException {
         char[] buf = new char[BUFFER_SIZE];
-        int bytesRead = 0;
-
-        while ((bytesRead = in.read(buf)) > 0)
-        {
-            out.write(buf, 0, bytesRead);
+        int bytesRead;
+        while( ( bytesRead = in.read( buf ) ) > 0 ) {
+            out.write( buf, 0, bytesRead );
         }
 
         out.flush();
     }
 
     /**
-     *  Just copies all bytes from <I>in</I> to <I>out</I>.  The copying is
-     *  performed using a buffer of bytes.
+     *  Just copies all bytes from <I>in</I> to <I>out</I>.  The copying is performed using a buffer of bytes.
      *
      *  @since 1.9.31
      *  @param in The inputstream to copy from
      *  @param out The outputstream to copy to
      *  @throws IOException In case reading or writing fails.
      */
-    public static void copyContents( InputStream in, OutputStream out )
-        throws IOException
-    {
+    public static void copyContents( final InputStream in, final OutputStream out ) throws IOException {
         byte[] buf = new byte[BUFFER_SIZE];
-        int bytesRead = 0;
-
-        while ((bytesRead = in.read(buf)) > 0)
-        {
-            out.write(buf, 0, bytesRead);
+        int bytesRead;
+        while( ( bytesRead = in.read( buf ) ) > 0 ) {
+            out.write( buf, 0, bytesRead );
         }
 
         out.flush();
diff --git a/jspwiki-util/src/test/java/org/apache/wiki/util/FileUtilTest.java b/jspwiki-util/src/test/java/org/apache/wiki/util/FileUtilTest.java
index b00c87e..aac72ed 100644
--- a/jspwiki-util/src/test/java/org/apache/wiki/util/FileUtilTest.java
+++ b/jspwiki-util/src/test/java/org/apache/wiki/util/FileUtilTest.java
@@ -19,15 +19,15 @@
 
 package org.apache.wiki.util;
 
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
 import java.io.ByteArrayInputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.StringReader;
 import java.nio.charset.StandardCharsets;
 
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.Test;
-
 public class FileUtilTest
 {
 
@@ -39,9 +39,7 @@ public class FileUtilTest
      *  broken.  If it's not, seek for the bug in your code.
      */
     @Test
-    public void testJDKString()
-        throws Exception
-    {
+    public void testJDKString() {
         String src = "abc\u00e4\u00e5\u00a6";
 
         String res = new String( src.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.ISO_8859_1 );
@@ -80,35 +78,23 @@ public class FileUtilTest
      * ISO Latin 1 from a pipe.
      */
     @Test
-    public void testReadContentsFromPipe()
-        throws Exception
-    {
+    public void testReadContentsFromPipe() throws Exception {
         String src = "abc\n123456\n\nfoobar.\n";
 
         // Make a very long string.
-        for( int i = 0; i < 10; i++ )
-        {
+        for( int i = 0; i < 10; i++ ) {
             src += src;
         }
 
         src += "\u00e4\u00e5\u00a6";
 
-        File f = FileUtil.newTmpFile( src, StandardCharsets.ISO_8859_1.name() );
+        File f = FileUtil.newTmpFile( src, StandardCharsets.ISO_8859_1 );
 
         String[] envp = {};
-
-        try
-        {
-            Process process = Runtime.getRuntime().exec( "cat "+f.getAbsolutePath(), envp, f.getParentFile() );
-
-            String result = FileUtil.readContents( process.getInputStream(), StandardCharsets.UTF_8.name() );
-
-            f.delete();
-
-            Assertions.assertEquals( src,
-                          result );
-        }
-        catch( IOException e ) {}
+        Process process = Runtime.getRuntime().exec( "cat "+f.getAbsolutePath(), envp, f.getParentFile() );
+        String result = FileUtil.readContents( process.getInputStream(), StandardCharsets.UTF_8.name() );
+        f.delete();
+        Assertions.assertEquals( src, result );
     }
 
     @Test


[jspwiki] 06/24: code format

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

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

commit f0e08d5d7c7ab3c6306bcf7e87efff33bf0649d9
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Aug 16 20:39:55 2019 +0200

    code format
---
 .../wiki/auth/login/AbstractLoginModule.java       | 49 ++++++++++------------
 1 file changed, 22 insertions(+), 27 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/AbstractLoginModule.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/AbstractLoginModule.java
index 1bd444d..fca22b8 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/login/AbstractLoginModule.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/login/AbstractLoginModule.java
@@ -18,19 +18,17 @@
  */
 package org.apache.wiki.auth.login;
 
-import java.security.Principal;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Map;
+import org.apache.log4j.Logger;
+import org.apache.wiki.auth.WikiPrincipal;
 
 import javax.security.auth.Subject;
 import javax.security.auth.callback.CallbackHandler;
 import javax.security.auth.login.LoginException;
 import javax.security.auth.spi.LoginModule;
-
-import org.apache.log4j.Logger;
-
-import org.apache.wiki.auth.WikiPrincipal;
+import java.security.Principal;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Map;
 
 /**
  * Abstract JAAS {@link javax.security.auth.spi.LoginModule}that implements
@@ -40,14 +38,12 @@ import org.apache.wiki.auth.WikiPrincipal;
  * {@link #logout()} should be sufficient for most purposes.
  * @since 2.3
  */
-public abstract class AbstractLoginModule implements LoginModule
-{
+public abstract class AbstractLoginModule implements LoginModule {
 
-    private static final Logger   log = Logger.getLogger( AbstractLoginModule.class );
+    private static final Logger log = Logger.getLogger( AbstractLoginModule.class );
 
     protected CallbackHandler m_handler;
-
-    protected Map<String,?>             m_options;
+    protected Map< String, ? > m_options;
 
     /**
      * Collection of Principals set during login module initialization.
@@ -58,7 +54,7 @@ public abstract class AbstractLoginModule implements LoginModule
      * if login succeeds.
      * @deprecated
      */
-    protected Collection<Principal>      m_previousWikiPrincipals;
+    protected Collection< Principal > m_previousWikiPrincipals;
 
     /**
      * Implementing classes should add Principals to this collection; these
@@ -66,7 +62,7 @@ public abstract class AbstractLoginModule implements LoginModule
      * These Principals will be added to the Subject
      * during the {@link #commit()} phase of login.
      */
-    protected Collection<Principal> m_principals;
+    protected Collection< Principal > m_principals;
 
     /**
      * Implementing classes should add Principals to this collection
@@ -76,7 +72,7 @@ public abstract class AbstractLoginModule implements LoginModule
      * {@link org.apache.wiki.auth.authorize.Role}.
      * @deprecated
      */
-    protected Collection<Principal>      m_principalsToRemove;
+    protected Collection< Principal > m_principalsToRemove;
 
     /**
      * Implementing classes should add Principals to this collection to specify
@@ -91,13 +87,13 @@ public abstract class AbstractLoginModule implements LoginModule
      * should over-write {@link org.apache.wiki.auth.authorize.Role#ANONYMOUS}.
      * @deprecated
      */
-    protected Collection<Principal>      m_principalsToOverwrite;
+    protected Collection< Principal > m_principalsToOverwrite;
 
-    protected Map<String,?>             m_state;
+    protected Map< String, ? > m_state;
 
-    protected Subject         m_subject;
+    protected Subject m_subject;
 
-    protected static final String NULL           = "(null)";
+    protected static final String NULL = "(null)";
 
     /**
      * Aborts the login; called if the LoginContext's overall authentication
@@ -108,10 +104,9 @@ public abstract class AbstractLoginModule implements LoginModule
      * {@link #m_principalsToRemove}.
      * It always returns <code>true</code>.
      * @see javax.security.auth.spi.LoginModule#abort()
-     * @throws LoginException if the abort itself fails
      * @return True, always.
      */
-    public final boolean abort() throws LoginException
+    public final boolean abort()
     {
         removePrincipals( m_principals );
         removePrincipals( m_principalsToRemove );
@@ -182,10 +177,10 @@ public abstract class AbstractLoginModule implements LoginModule
      */
     public final void initialize( Subject subject, CallbackHandler callbackHandler, Map<String,?> sharedState, Map<String,?> options )
     {
-        m_previousWikiPrincipals = new HashSet<Principal>();
-        m_principals = new HashSet<Principal>();
-        m_principalsToRemove = new HashSet<Principal>();
-        m_principalsToOverwrite = new HashSet<Principal>();
+        m_previousWikiPrincipals = new HashSet<>();
+        m_principals = new HashSet<>();
+        m_principalsToRemove = new HashSet<>();
+        m_principalsToOverwrite = new HashSet<>();
         m_subject = subject;
         m_handler = callbackHandler;
         m_state = sharedState;
@@ -221,7 +216,7 @@ public abstract class AbstractLoginModule implements LoginModule
      * @throws LoginException if the logout itself fails
      * @see javax.security.auth.spi.LoginModule#logout()
      */
-    public final boolean logout() throws LoginException
+    public final boolean logout()
     {
         removePrincipals( m_principals );
         removePrincipals( m_principalsToRemove );


[jspwiki] 24/24: fix date

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 e1975f3ed9c501bea6cb958b5d28a80bccc2b4b3
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Aug 19 22:16:30 2019 +0200

    fix date
---
 ChangeLog | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 4504e9a..7f7eb9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,7 +7,7 @@
 
        * [INFRA-18845]: switch Sonar instance to sonarcloud.io
 
-2019-08-06  Juan Pablo Santos (juanpablo AT apache DOT org)
+2019-08-16  Juan Pablo Santos (juanpablo AT apache DOT org)
 
        * 2.11.0-M5-git-09
 


[jspwiki] 23/24: 2.11.0-M5-git-10

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

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

commit efd78875b9b531c95fdfa05cddcbd83848ed45b1
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Aug 19 22:15:25 2019 +0200

    2.11.0-M5-git-10
---
 ChangeLog                                                 | 9 +++++++++
 jspwiki-main/src/main/java/org/apache/wiki/Release.java   | 2 +-
 jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java | 2 +-
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6fa1754..4504e9a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2019-08-19  Juan Pablo Santos (juanpablo AT apache DOT org)
+
+       * 2.11.0-M5-git-10
+
+       * Removed @Deprecated code. A complete analysis of what have changed will be available at
+         http://jspwiki.apache.org/japicmp/index.html once 2.11.0.M5 gets released
+
+       * [INFRA-18845]: switch Sonar instance to sonarcloud.io
+
 2019-08-06  Juan Pablo Santos (juanpablo AT apache DOT org)
 
        * 2.11.0-M5-git-09
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/Release.java b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
index 39dbcd1..3e93d11 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/Release.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/Release.java
@@ -72,7 +72,7 @@ public final class Release {
      *  <p>
      *  If the build identifier is empty, it is not added.
      */
-    public static final String     BUILD         = "09";
+    public static final String     BUILD         = "10";
 
     /**
      *  This is the generic version string you should use when printing out the version.  It is of
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java
index e4fff20..9c35e45 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java
@@ -66,5 +66,5 @@ public class Editor {
     public String toString() {
         return m_editorName;
     }
-    
+
 }


[jspwiki] 18/24: small refactor of parseLong

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 22a7d523d6b2a7a301353ded2ba96d0d04ce3ffd
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Aug 18 20:54:06 2019 +0200

    small refactor of parseLong
---
 .../wiki/auth/user/AbstractUserDatabase.java       | 74 ++++++++--------------
 1 file changed, 27 insertions(+), 47 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/AbstractUserDatabase.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/AbstractUserDatabase.java
index 5c985d6..727d0cd 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/AbstractUserDatabase.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/AbstractUserDatabase.java
@@ -18,14 +18,7 @@
  */
 package org.apache.wiki.auth.user;
 
-import java.nio.charset.StandardCharsets;
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Properties;
-import java.util.UUID;
-
+import org.apache.commons.lang3.math.NumberUtils;
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
@@ -35,6 +28,14 @@ import org.apache.wiki.auth.WikiSecurityException;
 import org.apache.wiki.util.ByteUtils;
 import org.apache.wiki.util.CryptoUtil;
 
+import java.nio.charset.StandardCharsets;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.Principal;
+import java.util.ArrayList;
+import java.util.Properties;
+import java.util.UUID;
+
 /**
  * Abstract UserDatabase class that provides convenience methods for finding
  * profiles, building Principal collections and hashing passwords.
@@ -260,8 +261,7 @@ public abstract class AbstractUserDatabase implements UserDatabase
      * @param db The database for which the UID should be generated.
      * @return A random, unique UID.
      */
-    protected static String generateUid( UserDatabase db )
-    {
+    protected static String generateUid( UserDatabase db ) {
         // Keep generating UUIDs until we find one that doesn't collide
         String uid = null;
         boolean collision;
@@ -290,19 +290,13 @@ public abstract class AbstractUserDatabase implements UserDatabase
      * @param text the text to hash
      * @return the result hash
      */
-    protected String getHash( String text )
-    {
-        String hash = null;
-        try
-        {
-            hash = CryptoUtil.getSaltedPassword( text.getBytes(StandardCharsets.UTF_8) );
-        }
-        catch( NoSuchAlgorithmException e )
-        {
+    protected String getHash( final String text ) {
+        try {
+            return CryptoUtil.getSaltedPassword( text.getBytes(StandardCharsets.UTF_8 ) );
+        } catch( final NoSuchAlgorithmException e ) {
             log.error( "Error creating salted SHA password hash:" + e.getMessage() );
-            hash = text;
+            return text;
         }
-        return hash;
     }
 
     /**
@@ -312,22 +306,16 @@ public abstract class AbstractUserDatabase implements UserDatabase
      * @return the result hash
      * @deprecated this method is retained for backwards compatibility purposes; use {@link #getHash(String)} instead
      */
-    protected String getOldHash( String text )
-    {
-        String hash = null;
-        try
-        {
-            MessageDigest md = MessageDigest.getInstance( "SHA" );
-            md.update( text.getBytes(StandardCharsets.UTF_8) );
+    protected String getOldHash( final String text ) {
+        try {
+            final MessageDigest md = MessageDigest.getInstance( "SHA" );
+            md.update( text.getBytes( StandardCharsets.UTF_8 ) );
             byte[] digestedBytes = md.digest();
-            hash = ByteUtils.bytes2hex( digestedBytes );
-        }
-        catch( NoSuchAlgorithmException e )
-        {
+            return ByteUtils.bytes2hex( digestedBytes );
+        } catch( final NoSuchAlgorithmException e ) {
             log.error( "Error creating SHA password hash:" + e.getMessage() );
-            hash = text;
+            return text;
         }
-        return hash;
     }
 
     /**
@@ -335,19 +323,11 @@ public abstract class AbstractUserDatabase implements UserDatabase
      * @param value the string to parse
      * @return the value parsed
      */
-    protected long parseLong( String value )
-    {
-        if ( value == null || value.length() == 0 )
-        {
-            return 0;
-        }
-        try
-        {
-            return Long.parseLong( value );
-        }
-        catch ( NumberFormatException e )
-        {
-            return 0;
+    protected long parseLong( final String value ) {
+        if( NumberUtils.isParsable( value ) ) {
+            return Long.valueOf( value );
+        } else {
+            return 0L;
         }
     }
 


[jspwiki] 07/24: removal of @deprecated code (5) - UserProfile: removed setWikiName(String), wasn't used anywhere

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 c4bc572eaaa1dd2c60434a2d370adeb7c8a9df82
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Aug 16 20:41:07 2019 +0200

    removal of @deprecated code (5) - UserProfile: removed setWikiName(String), wasn't used anywhere
---
 .../java/org/apache/wiki/auth/user/DefaultUserProfile.java  | 13 -------------
 .../main/java/org/apache/wiki/auth/user/UserProfile.java    |  9 ---------
 2 files changed, 22 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java
index 8e37790..ae2df73 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/DefaultUserProfile.java
@@ -275,19 +275,6 @@ public final class DefaultUserProfile implements UserProfile
     }
 
     /**
-     * No-op method. In previous versions of JSPWiki, the method
-     * set the user's wiki name directly. Now, the wiki name is automatically
-     * calculated based on the full name.
-     * @param name the wiki name
-     * @deprecated This method will be removed in a future release.
-     */
-    @Deprecated
-    @Override
-    public void setWikiName( String name )
-    {
-    }
-
-    /**
      * Returns a string representation of this user profile.
      * @return the string
      */
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserProfile.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserProfile.java
index 6ea6f1a..cb39278 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserProfile.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/user/UserProfile.java
@@ -187,15 +187,6 @@ public interface UserProfile extends Serializable
      * @param uid the unique identifier to set
      */
     void setUid( String uid );
-    
-    /**
-     * No-op method. In previous versions of JSPWiki, the method
-     * set the user's wiki name directly. Now, the wiki name is automatically
-     * calculated based on the full name.
-     * @param name the wiki name
-     * @deprecated This method will be removed in a future release.
-     */
-    void setWikiName( String name );
 
     /**
      * Returns a string representation of this user profile.


[jspwiki] 04/24: fix couple of probable concurrent issues if the XMLGroupDatabase is kept running around; format code

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

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

commit cac4d616f212dae68b96b68acd6101950d79075b
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Aug 16 20:27:44 2019 +0200

    fix couple of probable concurrent issues if the XMLGroupDatabase is kept running around; format code
---
 .../wiki/auth/authorize/XMLGroupDatabase.java      | 180 ++++++++-------------
 1 file changed, 63 insertions(+), 117 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/XMLGroupDatabase.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/XMLGroupDatabase.java
index 440e252..153a2d6 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/XMLGroupDatabase.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/XMLGroupDatabase.java
@@ -39,15 +39,17 @@ import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
 import java.security.Principal;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
 import java.util.Date;
-import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
+import java.util.concurrent.ConcurrentHashMap;
+
 
 /**
  * <p>
@@ -99,17 +101,17 @@ public class XMLGroupDatabase implements GroupDatabase
 
     private static final String   PRINCIPAL        = "principal";
 
+    private static final String  DATE_FORMAT       = "yyyy.MM.dd 'at' HH:mm:ss:SSS z";
+
     private Document              m_dom            = null;
 
     private DateFormat            m_defaultFormat  = DateFormat.getDateTimeInstance();
 
-    private DateFormat            m_format         = new SimpleDateFormat("yyyy.MM.dd 'at' HH:mm:ss:SSS z");
-
     private File                  m_file           = null;
 
     private WikiEngine            m_engine         = null;
 
-    private Map<String, Group>    m_groups         = new HashMap<>();
+    private Map<String, Group>    m_groups         = new ConcurrentHashMap<>();
 
     /**
       * Looks up and deletes a {@link Group} from the group database. If the
@@ -211,10 +213,8 @@ public class XMLGroupDatabase implements GroupDatabase
      * @throws WikiSecurityException if the Group could not be saved successfully
      */
     @Override
-    public void save( Group group, Principal modifier ) throws WikiSecurityException
-    {
-        if ( group == null || modifier == null )
-        {
+    public void save( Group group, Principal modifier ) throws WikiSecurityException {
+        if ( group == null || modifier == null ) {
             throw new IllegalArgumentException( "Group or modifier cannot be null." );
         }
 
@@ -239,67 +239,50 @@ public class XMLGroupDatabase implements GroupDatabase
         saveDOM();
     }
 
-    private void buildDOM() throws WikiSecurityException
-    {
-        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+    private void buildDOM() {
+        final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
         factory.setValidating( false );
         factory.setExpandEntityReferences( false );
         factory.setIgnoringComments( true );
         factory.setNamespaceAware( false );
-        try
-        {
+        try {
             m_dom = factory.newDocumentBuilder().parse( m_file );
             log.debug( "Database successfully initialized" );
             m_lastModified = m_file.lastModified();
             m_lastCheck    = System.currentTimeMillis();
-        }
-        catch( ParserConfigurationException e )
-        {
+        } catch( final ParserConfigurationException e ) {
             log.error( "Configuration error: " + e.getMessage() );
-        }
-        catch( SAXException e )
-        {
+        } catch( final SAXException e ) {
             log.error( "SAX error: " + e.getMessage() );
-        }
-        catch( FileNotFoundException e )
-        {
+        } catch( final FileNotFoundException e ) {
             log.info( "Group database not found; creating from scratch..." );
-        }
-        catch( IOException e )
-        {
+        } catch( final IOException e ) {
             log.error( "IO error: " + e.getMessage() );
         }
-        if ( m_dom == null )
-        {
-            try
-            {
+        if ( m_dom == null ) {
+            try {
                 //
                 // Create the DOM from scratch
                 //
                 m_dom = factory.newDocumentBuilder().newDocument();
                 m_dom.appendChild( m_dom.createElement( "groups" ) );
-            }
-            catch( ParserConfigurationException e )
-            {
+            } catch( final ParserConfigurationException e ) {
                 log.fatal( "Could not create in-memory DOM" );
             }
         }
 
         // Ok, now go and read this sucker in
-        if ( m_dom != null )
-        {
-            NodeList groupNodes = m_dom.getElementsByTagName( GROUP_TAG );
-            for( int i = 0; i < groupNodes.getLength(); i++ )
-            {
-                Element groupNode = (Element) groupNodes.item( i );
-                String groupName = groupNode.getAttribute( GROUP_NAME );
-                if ( groupName == null )
-                {
+        if ( m_dom != null ) {
+            final NodeList groupNodes = m_dom.getElementsByTagName( GROUP_TAG );
+            for( int i = 0; i < groupNodes.getLength(); i++ ) {
+                final Element groupNode = (Element) groupNodes.item( i );
+                final String groupName = groupNode.getAttribute( GROUP_NAME );
+                if ( groupName == null ) {
                     log.warn( "Detected null group name in XMLGroupDataBase. Check your group database." );
                 }
                 else
                 {
-                    Group group = buildGroup( groupNode, groupName );
+                    final Group group = buildGroup( groupNode, groupName );
                     m_groups.put( groupName, group );
                 }
             }
@@ -309,24 +292,12 @@ public class XMLGroupDatabase implements GroupDatabase
     private long m_lastCheck    = 0;
     private long m_lastModified = 0;
 
-    private void checkForRefresh()
-    {
-        long time = System.currentTimeMillis();
-
-        if( time - m_lastCheck > 60*1000L )
-        {
-            long lastModified = m_file.lastModified();
-
-            if( lastModified > m_lastModified )
-            {
-                try
-                {
-                    buildDOM();
-                }
-                catch( WikiSecurityException e )
-                {
-                    log.error("Could not refresh DOM",e);
-                }
+    private void checkForRefresh() {
+        final long time = System.currentTimeMillis();
+        if( time - m_lastCheck > 60*1000L ) {
+            final long lastModified = m_file.lastModified();
+            if( lastModified > m_lastModified ) {
+                buildDOM();
             }
         }
     }
@@ -334,50 +305,39 @@ public class XMLGroupDatabase implements GroupDatabase
      * Constructs a Group based on a DOM group node.
      * @param groupNode the node in the DOM containing the node
      * @param name the name of the group
-     * @throws NoSuchPrincipalException
-     * @throws WikiSecurityException
      */
-    private Group buildGroup( Element groupNode, String name )
-    {
+    private Group buildGroup( final Element groupNode, final String name ) {
         // It's an error if either param is null (very odd)
-        if ( groupNode == null || name == null )
-        {
+        if ( groupNode == null || name == null ) {
             throw new IllegalArgumentException( "DOM element or name cannot be null." );
         }
 
         // Construct a new group
-        Group group = new Group( name, m_engine.getApplicationName() );
+        final Group group = new Group( name, m_engine.getApplicationName() );
 
         // Get the users for this group, and add them
-        NodeList members = groupNode.getElementsByTagName( MEMBER_TAG );
-        for( int i = 0; i < members.getLength(); i++ )
-        {
-            Element memberNode = (Element) members.item( i );
-            String principalName = memberNode.getAttribute( PRINCIPAL );
-            Principal member = new WikiPrincipal( principalName );
+        final NodeList members = groupNode.getElementsByTagName( MEMBER_TAG );
+        for( int i = 0; i < members.getLength(); i++ ) {
+            final Element memberNode = (Element) members.item( i );
+            final String principalName = memberNode.getAttribute( PRINCIPAL );
+            final Principal member = new WikiPrincipal( principalName );
             group.add( member );
         }
 
         // Add the created/last-modified info
-        String creator = groupNode.getAttribute( CREATOR );
-        String created = groupNode.getAttribute( CREATED );
-        String modifier = groupNode.getAttribute( MODIFIER );
-        String modified = groupNode.getAttribute( LAST_MODIFIED );
-        try
-        {
-            group.setCreated( m_format.parse( created ) );
-            group.setLastModified( m_format.parse( modified ) );
-        }
-        catch ( ParseException e )
-        {
+        final String creator = groupNode.getAttribute( CREATOR );
+        final String created = groupNode.getAttribute( CREATED );
+        final String modifier = groupNode.getAttribute( MODIFIER );
+        final String modified = groupNode.getAttribute( LAST_MODIFIED );
+        try {
+            group.setCreated( new SimpleDateFormat( DATE_FORMAT ).parse( created ) );
+            group.setLastModified( new SimpleDateFormat( DATE_FORMAT ).parse( modified ) );
+        } catch ( final ParseException e ) {
             // If parsing failed, use the platform default
-            try
-            {
+            try {
                 group.setCreated( m_defaultFormat.parse( created ) );
                 group.setLastModified( m_defaultFormat.parse( modified ) );
-            }
-            catch ( ParseException e2)
-            {
+            } catch ( final ParseException e2 ) {
                 log.warn( "Could not parse 'created' or 'lastModified' " + "attribute for " + " group'"
                           + group.getName() + "'." + " It may have been tampered with." );
             }
@@ -387,41 +347,34 @@ public class XMLGroupDatabase implements GroupDatabase
         return group;
     }
 
-    private void saveDOM() throws WikiSecurityException
-    {
-        if ( m_dom == null )
-        {
+    private void saveDOM() throws WikiSecurityException {
+        if ( m_dom == null ) {
             log.fatal( "Group database doesn't exist in memory." );
         }
 
-        File newFile = new File( m_file.getAbsolutePath() + ".new" );
-        try
-        {
-            BufferedWriter io = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( newFile ), "UTF-8" ) );
-
+        final File newFile = new File( m_file.getAbsolutePath() + ".new" );
+        try( final BufferedWriter io = new BufferedWriter( new OutputStreamWriter( new FileOutputStream( newFile ), StandardCharsets.UTF_8 ) ) ) {
             // Write the file header and document root
             io.write( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
             io.write( "<groups>\n" );
 
             // Write each profile as a <group> node
-            for( Group group : m_groups.values() )
-            {
+            for( final Group group : m_groups.values() ) {
                 io.write( "  <" + GROUP_TAG + " " );
                 io.write( GROUP_NAME );
                 io.write( "=\"" + StringEscapeUtils.escapeXml11( group.getName() )+ "\" " );
                 io.write( CREATOR );
                 io.write( "=\"" + StringEscapeUtils.escapeXml11( group.getCreator() ) + "\" " );
                 io.write( CREATED );
-                io.write( "=\"" + m_format.format( group.getCreated() ) + "\" " );
+                io.write( "=\"" + new SimpleDateFormat( DATE_FORMAT ).format( group.getCreated() ) + "\" " );
                 io.write( MODIFIER );
                 io.write( "=\"" + group.getModifier() + "\" " );
                 io.write( LAST_MODIFIED );
-                io.write( "=\"" + m_format.format( group.getLastModified() ) + "\"" );
+                io.write( "=\"" + new SimpleDateFormat( DATE_FORMAT ).format( group.getLastModified() ) + "\"" );
                 io.write( ">\n" );
 
                 // Write each member as a <member> node
-                for( Principal member : group.members() )
-                {
+                for( final Principal member : group.members() ) {
                     io.write( "    <" + MEMBER_TAG + " " );
                     io.write( PRINCIPAL );
                     io.write( "=\"" + StringEscapeUtils.escapeXml11(member.getName()) + "\" " );
@@ -432,28 +385,21 @@ public class XMLGroupDatabase implements GroupDatabase
                 io.write( "  </" + GROUP_TAG + ">\n" );
             }
             io.write( "</groups>" );
-            io.close();
-        }
-        catch( IOException e )
-        {
+        } catch( final IOException e ) {
             throw new WikiSecurityException( e.getLocalizedMessage(), e );
         }
 
         // Copy new file over old version
-        File backup = new File( m_file.getAbsolutePath() + ".old" );
-        if ( backup.exists() && !backup.delete())
-        {
+        final File backup = new File( m_file.getAbsolutePath() + ".old" );
+        if ( backup.exists() && !backup.delete()) {
             log.error( "Could not delete old group database backup: " + backup );
         }
-        if ( !m_file.renameTo( backup ) )
-        {
+        if ( !m_file.renameTo( backup ) ) {
             log.error( "Could not create group database backup: " + backup );
         }
-        if ( !newFile.renameTo( m_file ) )
-        {
+        if ( !newFile.renameTo( m_file ) ) {
             log.error( "Could not save database: " + backup + " restoring backup." );
-            if ( !backup.renameTo( m_file ) )
-            {
+            if ( !backup.renameTo( m_file ) ) {
                 log.error( "Restore failed. Check the file permissions." );
             }
             log.error( "Could not save database: " + m_file + ". Check the file permissions" );


[jspwiki] 08/24: removal of @deprecated code (6) - WikiEngineEvent: removed getWikiEngine(), use getEngine() instead

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 018cbdd2184d0f646a4d4162dc6146365c4fec01
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Aug 16 20:44:48 2019 +0200

    removal of @deprecated code (6) - WikiEngineEvent: removed getWikiEngine(), use getEngine() instead
---
 .../org/apache/wiki/event/WikiEngineEvent.java     | 51 +++++-----------------
 1 file changed, 11 insertions(+), 40 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
index 082bf10..fed4cd0 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/event/WikiEngineEvent.java
@@ -27,8 +27,8 @@ import org.apache.wiki.WikiEngine;
   * @see     org.apache.wiki.event.WikiEvent
   * @since   2.4.20
   */
-public class WikiEngineEvent extends WikiEvent
-{
+public class WikiEngineEvent extends WikiEvent {
+
     private static final long serialVersionUID = 1829433967558773970L;
 
     /** Indicates a WikiEngine initialization event, fired as the 
@@ -50,9 +50,6 @@ public class WikiEngineEvent extends WikiEvent
 
     private WikiEngine m_engine;
 
-    // ............
-
-
      /**
       *  Constructs an instance of this event.
       * @param eventSource  the Object that is the source of the event,
@@ -60,31 +57,24 @@ public class WikiEngineEvent extends WikiEvent
       * method thows a ClassCastException
       * @param type the event type
       */
-    public WikiEngineEvent( Object eventSource, int type )
-    {
+    public WikiEngineEvent( Object eventSource, int type ) {
         super( eventSource, type );
         m_engine = (WikiEngine)eventSource;
     }
 
-
     /**
      *  Sets the type of this event.
      *
      * @param type      the type of this WikiEngineEvent.
      */
-    protected void setType( int type )
-    {
-        if ( type >= INITIALIZING && type <= STOPPED )
-        {
+    protected void setType( int type ) {
+        if ( type >= INITIALIZING && type <= STOPPED ) {
             super.setType(type);
-        }
-        else
-        {
+        } else {
             super.setType(ERROR);
         }
     }
 
-
     /**
      *  Returns the WikiEngine that spawned this event.
      *
@@ -95,19 +85,6 @@ public class WikiEngineEvent extends WikiEvent
         return m_engine;
     }
 
-
-    /**
-     *  Returns the WikiEngine that spawned this event.
-     *
-     * @return  the WikiEngine that spawned this event.
-     * @deprecated  use {@link #getEngine()} instead.
-     */
-    public WikiEngine getWikiEngine()
-    {
-        return m_engine;
-    }
-
-
    /**
      * Returns <code>true</code> if the int value is a WikiPageEvent type.
      * @param type the event type
@@ -118,16 +95,13 @@ public class WikiEngineEvent extends WikiEvent
         return type >= INITIALIZING && type <= STOPPED;
     }
 
-
     /**
      *  Returns a textual representation of the event type.
      *
      * @return a String representation of the type
      */
-    public final String eventName()
-    {
-        switch ( getType() )
-        {
+    public final String eventName() {
+        switch ( getType() ) {
             case INITIALIZING:         return "INITIALIZING";
             case INITIALIZED:          return "INITIALIZED";
             case SHUTDOWN:             return "SHUTDOWN";
@@ -136,16 +110,13 @@ public class WikiEngineEvent extends WikiEvent
         }
     }
 
-
     /**
      *  Returns a human-readable description of the event type.
      *
      * @return a String description of the type
      */
-    public final String getTypeDescription()
-    {
-        switch ( getType() )
-        {
+    public final String getTypeDescription() {
+        switch ( getType() ) {
             case INITIALIZING:         return "wiki engine initializing";
             case INITIALIZED:          return "wiki engine initialized";
             case SHUTDOWN:             return "wiki engine shutting down";
@@ -154,4 +125,4 @@ public class WikiEngineEvent extends WikiEvent
         }
     }
 
-} // end class org.apache.wiki.event.WikiEngineEvent
+}


[jspwiki] 17/24: WikiEngine#getContentEncoding returns a Charset now, instead of a String + propagate the change

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 15fbc8e557ee68278b18b251b18935c8da4bd47c
Author: juanpablo <ju...@apache.org>
AuthorDate: Sun Aug 18 20:36:22 2019 +0200

    WikiEngine#getContentEncoding returns a Charset now, instead of a String + propagate the change
---
 .../main/java/org/apache/wiki/VariableManager.java |  21 ++--
 .../src/main/java/org/apache/wiki/WikiEngine.java  |  51 ++++----
 .../wiki/ajax/WikiAjaxDispatcherServlet.java       |   9 +-
 .../org/apache/wiki/auth/AuthorizationManager.java |  65 ++++------
 .../org/apache/wiki/diff/ExternalDiffProvider.java |  42 +++----
 .../java/org/apache/wiki/filters/SpamFilter.java   |  50 ++++----
 .../org/apache/wiki/tags/ContentEncodingTag.java   |  17 +--
 .../java/org/apache/wiki/ui/CommandResolver.java   |  40 +++---
 .../java/org/apache/wiki/ui/WikiJSPFilter.java     |   5 +-
 .../java/org/apache/wiki/ui/WikiServletFilter.java |  24 ++--
 .../org/apache/wiki/url/DefaultURLConstructor.java | 139 +++++----------------
 .../org/apache/wiki/url/ShortURLConstructor.java   |  24 ++--
 .../java/org/apache/wiki/url/URLConstructor.java   |  11 +-
 13 files changed, 186 insertions(+), 312 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/VariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/VariableManager.java
index f7d1378..86e166d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/VariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/VariableManager.java
@@ -365,14 +365,12 @@ public class VariableManager
             return Release.getVersionString();
         }
 
-        public String getEncoding()
-        {
-            return m_context.getEngine().getContentEncoding();
+        public String getEncoding() {
+            return m_context.getEngine().getContentEncoding().displayName();
         }
 
-        public String getTotalpages()
-        {
-            return Integer.toString(m_context.getEngine().getPageCount());
+        public String getTotalpages() {
+            return Integer.toString( m_context.getEngine().getPageCount() );
         }
 
         public String getPageprovider()
@@ -385,16 +383,13 @@ public class VariableManager
             return m_context.getEngine().getCurrentProviderInfo();
         }
 
-        public String getAttachmentprovider()
-        {
-            WikiProvider p = m_context.getEngine().getAttachmentManager().getCurrentProvider();
+        public String getAttachmentprovider() {
+            final WikiProvider p = m_context.getEngine().getAttachmentManager().getCurrentProvider();
             return (p != null) ? p.getClass().getName() : "-";
         }
 
-        public String getAttachmentproviderdescription()
-        {
-            WikiProvider p = m_context.getEngine().getAttachmentManager().getCurrentProvider();
-
+        public String getAttachmentproviderdescription() {
+            final WikiProvider p = m_context.getEngine().getAttachmentManager().getCurrentProvider();
             return (p != null) ? p.getProviderInfo() : "-";
         }
 
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 fad91ec..c438ecb 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/WikiEngine.java
@@ -82,6 +82,7 @@ import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
+import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 import java.security.Principal;
 import java.util.ArrayList;
@@ -877,31 +878,26 @@ public class WikiEngine
             return "";
         }
 
-        try {
-            String res = request.getQueryString();
-            if( res != null ) {
-                res = new String( res.getBytes( StandardCharsets.ISO_8859_1 ), getContentEncoding() );
-
-                //
-                // Ensure that the 'page=xyz' attribute is removed
-                // FIXME: Is it really the mandate of this routine to do that?
-                //
-                final int pos1 = res.indexOf("page=");
-                if( pos1 >= 0 ) {
-                    String tmpRes = res.substring( 0, pos1 );
-                    final int pos2 = res.indexOf( "&",pos1 ) + 1;
-                    if ( ( pos2 > 0 ) && ( pos2 < res.length() ) ) {
-                        tmpRes = tmpRes + res.substring(pos2);
-                    }
-                    res = tmpRes;
+        String res = request.getQueryString();
+        if( res != null ) {
+            res = new String( res.getBytes( StandardCharsets.ISO_8859_1 ), getContentEncoding() );
+
+            //
+            // Ensure that the 'page=xyz' attribute is removed
+            // FIXME: Is it really the mandate of this routine to do that?
+            //
+            final int pos1 = res.indexOf("page=");
+            if( pos1 >= 0 ) {
+                String tmpRes = res.substring( 0, pos1 );
+                final int pos2 = res.indexOf( "&",pos1 ) + 1;
+                if ( ( pos2 > 0 ) && ( pos2 < res.length() ) ) {
+                    tmpRes = tmpRes + res.substring(pos2);
                 }
+                res = tmpRes;
             }
-
-            return res;
-        } catch( UnsupportedEncodingException e ) {
-            log.fatal( "Unsupported encoding", e );
-            return "";
         }
+
+        return res;
     }
 
     /**
@@ -1211,12 +1207,11 @@ public class WikiEngine
      *  @since 1.5.3
      *  @return The content encoding (either UTF-8 or ISO-8859-1).
      */
-    public String getContentEncoding()
-    {
-        if( m_useUTF8 )
-            return "UTF-8";
-
-        return "ISO-8859-1";
+    public Charset getContentEncoding() {
+        if( m_useUTF8 ) {
+            return StandardCharsets.UTF_8;
+        }
+        return StandardCharsets.ISO_8859_1;
     }
 
     /**
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
index 31bf209..5c06d50 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ajax/WikiAjaxDispatcherServlet.java
@@ -121,8 +121,7 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
      * @throws IOException
      * @throws ServletException if no registered servlet can be found
      */
-    private void performAction(HttpServletRequest req, HttpServletResponse res)
-            throws IOException, ServletException {
+    private void performAction( final HttpServletRequest req, final HttpServletResponse res ) throws IOException, ServletException {
         final String path = req.getRequestURI();
         final String servletName = getServletName(path);
         if (servletName!=null) {
@@ -130,8 +129,8 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
             if (container != null) {
                 final WikiAjaxServlet servlet = container.servlet;
                 if ( validatePermission(req,container) ) {
-                    req.setCharacterEncoding(m_engine.getContentEncoding());
-                    res.setCharacterEncoding(m_engine.getContentEncoding());
+                    req.setCharacterEncoding(m_engine.getContentEncoding().displayName());
+                    res.setCharacterEncoding(m_engine.getContentEncoding().displayName());
                     final String actionName = AjaxUtil.getNextPathPart(req.getRequestURI(), servlet.getServletMapping());
                     log.debug("actionName="+actionName);
                     final Object params = req.getParameter("params");
@@ -184,7 +183,7 @@ public class WikiAjaxDispatcherServlet extends HttpServlet {
     /**
      * Find the {@link AjaxServletContainer} as registered in {@link #registerServlet}.
      *
-     * @param servletName the name of the servlet from {@link #getServletName}
+     * @param servletAlias the name of the servlet from {@link #getServletName}
      * @return The first servlet found, or null.
      */
     private AjaxServletContainer findServletContainer(String servletAlias) {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
index a892249..6d27142 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/AuthorizationManager.java
@@ -453,8 +453,7 @@ public class AuthorizationManager {
      * @param properties the set of properties used to initialize the wiki engine
      * @throws WikiException if the AuthorizationManager cannot be initialized
      */
-    public void initialize( WikiEngine engine, Properties properties ) throws WikiException
-    {
+    public void initialize( final WikiEngine engine, final Properties properties ) throws WikiException {
         m_engine = engine;
 
         //
@@ -464,32 +463,26 @@ public class AuthorizationManager {
         m_authorizer.initialize( engine, properties );
 
         // Initialize local security policy
-        try
-        {
-            String policyFileName = properties.getProperty( POLICY, DEFAULT_POLICY );
-            URL policyURL = AuthenticationManager.findConfigFile( engine, policyFileName );
+        try {
+            final String policyFileName = properties.getProperty( POLICY, DEFAULT_POLICY );
+            final URL policyURL = AuthenticationManager.findConfigFile( engine, policyFileName );
 
-            if (policyURL != null)
-            {
-                File policyFile = new File( policyURL.toURI().getPath() );
+            if (policyURL != null) {
+                final File policyFile = new File( policyURL.toURI().getPath() );
                 log.info("We found security policy URL: " + policyURL + " and transformed it to file " + policyFile.getAbsolutePath());
-                m_localPolicy = new LocalPolicy( policyFile, engine.getContentEncoding() );
+                m_localPolicy = new LocalPolicy( policyFile, engine.getContentEncoding().displayName() );
                 m_localPolicy.refresh();
                 log.info( "Initialized default security policy: " + policyFile.getAbsolutePath() );
-            }
-            else
-            {
-                String sb = "JSPWiki was unable to initialize the default security policy (WEB-INF/jspwiki.policy) file. " +
-                            "Please ensure that the jspwiki.policy file exists in the default location. " +
-                		    "This file should exist regardless of the existance of a global policy file. " +
-                            "The global policy file is identified by the java.security.policy variable. ";
-                WikiSecurityException wse = new WikiSecurityException( sb );
+            } else {
+                final String sb = "JSPWiki was unable to initialize the default security policy (WEB-INF/jspwiki.policy) file. " +
+                                  "Please ensure that the jspwiki.policy file exists in the default location. " +
+                		          "This file should exist regardless of the existance of a global policy file. " +
+                                  "The global policy file is identified by the java.security.policy variable. ";
+                final WikiSecurityException wse = new WikiSecurityException( sb );
                 log.fatal( sb, wse );
                 throw wse;
             }
-        }
-        catch ( Exception e)
-        {
+        } catch ( final Exception e) {
             log.error("Could not initialize local security policy: " + e.getMessage() );
             throw new WikiException( "Could not initialize local security policy: " + e.getMessage(), e );
         }
@@ -504,34 +497,24 @@ public class AuthorizationManager {
      * @return a Authorizer used to get page authorization information
      * @throws WikiException
      */
-    private Authorizer getAuthorizerImplementation( Properties props ) throws WikiException
-    {
-        String authClassName = props.getProperty( PROP_AUTHORIZER, DEFAULT_AUTHORIZER );
-        return (Authorizer) locateImplementation( authClassName );
+    private Authorizer getAuthorizerImplementation( Properties props ) throws WikiException {
+        final String authClassName = props.getProperty( PROP_AUTHORIZER, DEFAULT_AUTHORIZER );
+        return ( Authorizer )locateImplementation( authClassName );
     }
 
-    private Object locateImplementation( String clazz ) throws WikiException
-    {
-        if ( clazz != null )
-        {
-            try
-            {
-                Class<?> authClass = ClassUtil.findClass( "org.apache.wiki.auth.authorize", clazz );
+    private Object locateImplementation( final String clazz ) throws WikiException {
+        if ( clazz != null ) {
+            try {
+                Class< ? > authClass = ClassUtil.findClass( "org.apache.wiki.auth.authorize", clazz );
                 Object impl = authClass.newInstance();
                 return impl;
-            }
-            catch( ClassNotFoundException e )
-            {
+            } catch( ClassNotFoundException e ) {
                 log.fatal( "Authorizer " + clazz + " cannot be found", e );
                 throw new WikiException( "Authorizer " + clazz + " cannot be found", e );
-            }
-            catch( InstantiationException e )
-            {
+            } catch( InstantiationException e ) {
                 log.fatal( "Authorizer " + clazz + " cannot be created", e );
                 throw new WikiException( "Authorizer " + clazz + " cannot be created", e );
-            }
-            catch( IllegalAccessException e )
-            {
+            } catch( IllegalAccessException e ) {
                 log.fatal( "You are not allowed to access this authorizer class", e );
                 throw new WikiException( "You are not allowed to access this authorizer class", e );
             }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/diff/ExternalDiffProvider.java b/jspwiki-main/src/main/java/org/apache/wiki/diff/ExternalDiffProvider.java
index 2b78637..48b920f 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/diff/ExternalDiffProvider.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/diff/ExternalDiffProvider.java
@@ -19,12 +19,6 @@
 
 package org.apache.wiki.diff;
 
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.Properties;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -32,6 +26,14 @@ import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.util.FileUtil;
 import org.apache.wiki.util.TextUtil;
 
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.util.Properties;
+
 /**
  * This DiffProvider allows external command line tools to be used to generate
  * the diff.
@@ -47,7 +49,7 @@ public class ExternalDiffProvider implements DiffProvider
     public static final String PROP_DIFFCOMMAND    = "jspwiki.diffCommand";
 
     private String m_diffCommand = null;
-    private String m_encoding;
+    private Charset m_encoding;
 
     private static final char DIFF_ADDED_SYMBOL    = '+';
     private static final char DIFF_REMOVED_SYMBOL  = '-';
@@ -118,7 +120,7 @@ public class ExternalDiffProvider implements DiffProvider
             String output = FileUtil.runSimpleCommand(cmd, f1.getParent());
 
             // FIXME: Should this rely on the system default encoding?
-            String rawWikiDiff = new String(output.getBytes("ISO-8859-1"), m_encoding);
+            String rawWikiDiff = new String( output.getBytes( StandardCharsets.ISO_8859_1 ), m_encoding );
 
             String htmlWikiDiff = TextUtil.replaceEntities( rawWikiDiff );
 
@@ -127,21 +129,17 @@ public class ExternalDiffProvider implements DiffProvider
             else
                 diff = htmlWikiDiff;
 
-        }
-        catch (IOException e)
-        {
+        } catch (IOException e) {
             log.error("Failed to do file diff", e);
-        }
-        catch (InterruptedException e)
-        {
+        } catch (InterruptedException e) {
             log.error("Interrupted", e);
-        }
-        finally
-        {
-            if( f1 != null )
+        } finally {
+            if( f1 != null ) {
                 f1.delete();
-            if( f2 != null )
+            }
+            if( f2 != null ) {
                 f2.delete();
+            }
         }
 
         return diff;
@@ -154,10 +152,10 @@ public class ExternalDiffProvider implements DiffProvider
      * green, those starting with - reddish (hm, got to think of color blindness
      * here...).
      */
-    static String colorizeDiff(String diffText) throws IOException
-    {
-        if( diffText == null )
+    static String colorizeDiff(String diffText) throws IOException {
+        if( diffText == null ) {
             return "Invalid diff - probably something wrong with server setup.";
+        }
 
         String line = null;
         String start = null;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
index 12a0752..3ee127c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/filters/SpamFilter.java
@@ -18,25 +18,7 @@
  */
 package org.apache.wiki.filters;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.Random;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.jsp.PageContext;
-
+import net.sf.akismet.Akismet;
 import org.apache.commons.lang3.time.StopWatch;
 import org.apache.log4j.Logger;
 import org.apache.oro.text.regex.MalformedPatternException;
@@ -69,7 +51,24 @@ import org.suigeneris.jrcs.diff.delta.DeleteDelta;
 import org.suigeneris.jrcs.diff.delta.Delta;
 import org.suigeneris.jrcs.diff.myers.MyersDiff;
 
-import net.sf.akismet.Akismet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.jsp.PageContext;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.Random;
+import java.util.StringTokenizer;
+import java.util.Vector;
 
 
 /**
@@ -1084,12 +1083,11 @@ public class SpamFilter extends BasicPageFilter {
      * @param pageContext The PageContext
      * @return A HTML string which contains input fields for the SpamFilter.
      */
-    public static final String insertInputFields( PageContext pageContext ) {
-        WikiContext ctx = WikiContext.findContext( pageContext );
-        WikiEngine engine = ctx.getEngine();
-
-        StringBuilder sb = new StringBuilder();
-        if( engine.getContentEncoding().equals( "UTF-8" ) ) {
+    public static final String insertInputFields( final PageContext pageContext ) {
+        final WikiContext ctx = WikiContext.findContext( pageContext );
+        final WikiEngine engine = ctx.getEngine();
+        final StringBuilder sb = new StringBuilder();
+        if( engine.getContentEncoding().equals( StandardCharsets.UTF_8 ) ) {
             sb.append( "<input name='encodingcheck' type='hidden' value='\u3041' />\n" );
         }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tags/ContentEncodingTag.java b/jspwiki-main/src/main/java/org/apache/wiki/tags/ContentEncodingTag.java
index 482c323..a33a0d3 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tags/ContentEncodingTag.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tags/ContentEncodingTag.java
@@ -18,30 +18,25 @@
  */
 package org.apache.wiki.tags;
 
-import java.io.IOException;
-
 import org.apache.wiki.WikiEngine;
 
+import java.io.IOException;
+
 /**
  *  Returns the app name.
  *
  *  @since 2.0
  */
-public class ContentEncodingTag
-    extends WikiTagBase
-{
+public class ContentEncodingTag extends WikiTagBase {
+
     private static final long serialVersionUID = 0L;
 
     /**
      *  {@inheritDoc}
      */
-    public final int doWikiStartTag()
-        throws IOException
-    {
-        WikiEngine engine = m_wikiContext.getEngine();
-
+    public final int doWikiStartTag() throws IOException {
+        final WikiEngine engine = m_wikiContext.getEngine();
         pageContext.getOut().print( engine.getContentEncoding() );
-
         return SKIP_BODY;
     }
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java
index e6f6a70..c3ca5de 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/CommandResolver.java
@@ -18,14 +18,6 @@
  */
 package org.apache.wiki.ui;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-
-import javax.servlet.http.HttpServletRequest;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiEngine;
@@ -36,6 +28,13 @@ import org.apache.wiki.auth.GroupPrincipal;
 import org.apache.wiki.parser.MarkupParser;
 import org.apache.wiki.util.TextUtil;
 
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+
 /**
  * <p>Resolves special pages, JSPs and Commands on behalf of a
  * WikiEngine. CommandResolver will automatically resolve page names
@@ -429,35 +428,26 @@ public final class CommandResolver
      * @param request the HTTP request
      * @return the resolved page name
      */
-    protected String extractPageFromParameter( String requestContext, HttpServletRequest request )
-    {
+    protected String extractPageFromParameter( final String requestContext, final HttpServletRequest request ) {
         String page;
 
         // Extract the page name from the URL directly
-        try
-        {
+        try {
             page = m_engine.getURLConstructor().parsePage( requestContext, request, m_engine.getContentEncoding() );
-            if ( page != null )
-            {
-                try
-                {
+            if ( page != null ) {
+                try {
                     // Look for singular/plural variants; if one
                     // not found, take the one the user supplied
-                    String finalPage = getFinalPageName( page );
-                    if ( finalPage != null )
-                    {
+                    final String finalPage = getFinalPageName( page );
+                    if ( finalPage != null ) {
                         page = finalPage;
                     }
-                }
-                catch( ProviderException e )
-                {
+                } catch( final ProviderException e ) {
                     // FIXME: Should not ignore!
                 }
                 return page;
             }
-        }
-        catch( IOException e )
-        {
+        } catch( final IOException e ) {
             m_log.error( "Unable to create context", e );
             throw new InternalWikiException( "Big internal booboo, please check logs." , e);
         }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
index 21dbf87..41d55c9 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiJSPFilter.java
@@ -43,6 +43,7 @@ import java.io.IOException;
 import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
 import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 
 
 /**
@@ -102,8 +103,8 @@ public class WikiJSPFilter extends WikiServletFilter
             responseWrapper = new JSPWikiServletResponseWrapper( (HttpServletResponse)response, m_wiki_encoding, useEncoding);
 
             // fire PAGE_REQUESTED event
-            String pagename = DefaultURLConstructor.parsePageFromURL(
-                    (HttpServletRequest)request, response.getCharacterEncoding() );
+            String pagename = DefaultURLConstructor.parsePageFromURL( ( HttpServletRequest )request,
+                                                                      Charset.forName( response.getCharacterEncoding() ) );
             fireEvent( WikiPageEvent.PAGE_REQUESTED, pagename );
 
             super.doFilter( request, responseWrapper, chain );
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
index 2fafb2e..45a95e1 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/WikiServletFilter.java
@@ -18,16 +18,8 @@
  */
 package org.apache.wiki.ui;
 
-import java.io.IOException;
-import java.io.PrintWriter;
-
-import javax.servlet.*;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-
 import org.apache.log4j.Logger;
 import org.apache.log4j.NDC;
-
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiSession;
@@ -35,6 +27,18 @@ import org.apache.wiki.auth.SessionMonitor;
 import org.apache.wiki.auth.WikiSecurityException;
 import org.apache.wiki.tags.WikiTagBase;
 
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+import java.io.IOException;
+import java.io.PrintWriter;
+
 /**
  * Filter that verifies that the {@link org.apache.wiki.WikiEngine} is running, and
  * sets the authentication status for the user's WikiSession. Each HTTP request
@@ -129,10 +133,10 @@ public class WikiServletFilter implements Filter
         }   
         
         // If we haven't done so, wrap the request
-        HttpServletRequest httpRequest = (HttpServletRequest) request;
+        HttpServletRequest httpRequest = ( HttpServletRequest )request;
         
         // Set the character encoding
-        httpRequest.setCharacterEncoding( m_engine.getContentEncoding() );
+        httpRequest.setCharacterEncoding( m_engine.getContentEncoding().displayName() );
         
         if ( !isWrapped( request ) )
         {
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java
index 383043c..9a72a4d 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/DefaultURLConstructor.java
@@ -26,7 +26,7 @@ import org.apache.wiki.ui.CommandResolver;
 import org.apache.wiki.util.TextUtil;
 
 import javax.servlet.http.HttpServletRequest;
-import java.io.UnsupportedEncodingException;
+import java.nio.charset.Charset;
 import java.util.Properties;
 
 /**
@@ -36,9 +36,8 @@ import java.util.Properties;
  *
  *  @since 2.2
  */
-public class DefaultURLConstructor
-    implements URLConstructor
-{
+public class DefaultURLConstructor implements URLConstructor {
+
     protected WikiEngine m_engine;
 
     /**
@@ -51,11 +50,8 @@ public class DefaultURLConstructor
      *
      * {@inheritDoc}
      */
-    public void initialize( WikiEngine engine,
-                            Properties properties )
-    {
+    public void initialize( final WikiEngine engine, final Properties properties ) {
         m_engine = engine;
-
         m_pathPrefix = engine.getBaseURL() + "/";
     }
 
@@ -76,11 +72,12 @@ public class DefaultURLConstructor
      *                 the setting in jspwiki.properties.
      * @return A replacement.
      */
-    protected final String doReplacement( String baseptrn, String name, boolean absolute )
-    {
+    protected final String doReplacement( String baseptrn, final String name, final boolean absolute ) {
         String baseurl = m_pathPrefix;
 
-        if( absolute ) baseurl = m_engine.getBaseURL() + "/";
+        if( absolute ) {
+            baseurl = m_engine.getBaseURL() + "/";
+        }
 
         baseptrn = TextUtil.replaceString( baseptrn, "%u", baseurl );
         baseptrn = TextUtil.replaceString( baseptrn, "%U", m_engine.getBaseURL() );
@@ -97,10 +94,8 @@ public class DefaultURLConstructor
      *
      *  We also convert any %2F's back to slashes to make nicer-looking URLs.
      */
-    private String encodeURI( String uri )
-    {
+    private String encodeURI( String uri ) {
         uri = m_engine.encodeName(uri);
-
         uri = StringUtils.replace( uri, "+", "%20" );
         uri = StringUtils.replace( uri, "%2F", "/" );
 
@@ -114,17 +109,14 @@ public class DefaultURLConstructor
      * @return A pattern for replacement.
      * @throws IllegalArgumentException if the context cannot be found
      */
-    public static String getURLPattern( String context, String name )
-        throws IllegalArgumentException
-    {
-        if( context.equals(WikiContext.VIEW) && name == null)
-        {
+    public static String getURLPattern( final String context, final String name ) throws IllegalArgumentException {
+        if( context.equals(WikiContext.VIEW) && name == null) {
             // FIXME
             return "%uWiki.jsp";
         }
 
         // Find the action matching our pattern (could throw exception)
-        Command command = CommandResolver.findCommand( context );
+        final Command command = CommandResolver.findCommand( context );
 
         return command.getURLPattern();
     }
@@ -132,10 +124,7 @@ public class DefaultURLConstructor
     /**
      *  Constructs the actual URL based on the context.
      */
-    private String makeURL( String context,
-                            String name,
-                            boolean absolute )
-    {
+    private String makeURL( final String context, final String name, final boolean absolute ) {
         return doReplacement( getURLPattern(context,name), name, absolute );
     }
 
@@ -145,31 +134,19 @@ public class DefaultURLConstructor
      *
      *  {@inheritDoc}
      */
-    public String makeURL( String context,
-                           String name,
-                           boolean absolute,
-                           String parameters )
-    {
-        if( parameters != null && parameters.length() > 0 )
-        {
-            if( context.equals(WikiContext.ATTACH) )
-            {
+    public String makeURL( final String context, final String name, final boolean absolute, String parameters ) {
+        if( parameters != null && parameters.length() > 0 ) {
+            if( context.equals(WikiContext.ATTACH) ) {
                 parameters = "?"+parameters;
-            }
-            else if( context.equals(WikiContext.NONE) )
-            {
+            } else if( context.equals(WikiContext.NONE) ) {
                 parameters = (name.indexOf('?') != -1 ) ? "&amp;" : "?" + parameters;
-            }
-            else
-            {
+            } else {
                 parameters = "&amp;"+parameters;
             }
-        }
-        else
-        {
+        } else {
             parameters = "";
         }
-        return makeURL( context, name, absolute )+parameters;
+        return makeURL( context, name, absolute ) + parameters;
     }
 
     /**
@@ -178,15 +155,9 @@ public class DefaultURLConstructor
      *
      *  {@inheritDoc}
      */
-    public String parsePage( String context,
-                             HttpServletRequest request,
-                             String encoding )
-        throws UnsupportedEncodingException
-    {
+    public String parsePage( final String context, final HttpServletRequest request, final Charset encoding ) {
         String pagereq = request.getParameter( "page" );
-
-        if( context.equals(WikiContext.ATTACH) )
-        {
+        if( context.equals(WikiContext.ATTACH) ) {
             pagereq = parsePageFromURL( request, encoding );
         }
 
@@ -194,42 +165,6 @@ public class DefaultURLConstructor
     }
 
     /**
-     *  There's a bug in Tomcat until 5.5.16 at least: The "+" sign is not
-     *  properly decoded by the servlet container, and therefore request.getPathInfo()
-     *  will return faulty results for paths which contains + signs to signify spaces.
-     *  <p>
-     *  This method provides a workaround by simply parsing the getRequestURI(), which
-     *  is returned from the servlet container undedecoded.
-     *  <p>
-     *  Please see <a href="http://issues.apache.org/bugzilla/show_bug.cgi?id=39278">Tomcat Bug 39278</a>
-     *  for more information.
-     *
-     *  @param request A HTTP servlet request
-     *  @param encoding The used encoding
-     *  @return a String, decoded by JSPWiki, specifying extra path information that comes
-     *          after the servlet path but before the query string in the request URL;
-     *          or null if the URL does not have any extra path information
-     *  @throws UnsupportedEncodingException
-     */
-    /*
-    private static String getPathInfo( HttpServletRequest request, String encoding )
-        throws UnsupportedEncodingException
-    {
-        String c = request.getContextPath(); // Undecoded
-        String s = request.getServletPath(); // Decoded
-        String u = request.getRequestURI();  // Undecoded
-
-        c = URLDecoder.decode( c, encoding );
-        u = URLDecoder.decode( u, encoding );
-
-        String pi = u.substring( s.length()+c.length() );
-
-        if( pi.length() == 0 ) pi = null;
-
-        return pi;
-    }
-    */
-    /**
      *  Takes the name of the page from the request URI.
      *  The initial slash is also removed.  If there is no page,
      *  returns null.
@@ -238,29 +173,18 @@ public class DefaultURLConstructor
      *  @param encoding The encoding to use
      *
      *  @return a parsed page name, or null, if it cannot be found
-     *
-     *  @throws UnsupportedEncodingException If the encoding is not recognized.
      */
-    public static String parsePageFromURL( HttpServletRequest request,
-                                           String encoding )
-        throws UnsupportedEncodingException
-    {
-        String name = request.getPathInfo();
-
-        if( name == null || name.length() <= 1 )
-        {
+    public static String parsePageFromURL( final HttpServletRequest request, final Charset encoding ) {
+        final String name = request.getPathInfo();
+        if( name == null || name.length() <= 1 ) {
             return null;
-        }
-        else if( name.charAt(0) == '/' )
-        {
-            name = name.substring(1);
+        } else if( name.charAt(0) == '/' ) {
+            return name.substring(1);
         }
 
         //
-        //  This is required, because by default all URLs are handled
-        //  as Latin1, even if they are really UTF-8.
+        //  This is required, because by default all URLs are handled as Latin1, even if they are really UTF-8.
         //
-
         // name = TextUtil.urlDecode( name, encoding );
 
         return name;
@@ -271,11 +195,10 @@ public class DefaultURLConstructor
      *  This method is not needed for the DefaultURLConstructor.
      *
      * @param request The HTTP Request that was used to end up in this page.
-     * @return "Wiki.jsp", "PageInfo.jsp", etc.  Just return the name,
-     *         JSPWiki will figure out the page.
+     * @return "Wiki.jsp", "PageInfo.jsp", etc.  Just return the name, JSPWiki will figure out the page.
      */
-    public String getForwardPage( HttpServletRequest request )
-    {
+    public String getForwardPage( final HttpServletRequest request ) {
         return "Wiki.jsp";
     }
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
index d4744c4..f686d50 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/ShortURLConstructor.java
@@ -18,18 +18,16 @@
  */
 package org.apache.wiki.url;
 
-import java.io.UnsupportedEncodingException;
-import java.util.Properties;
-
-import javax.servlet.http.HttpServletRequest;
-
 import org.apache.log4j.Logger;
-
 import org.apache.wiki.InternalWikiException;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.util.TextUtil;
 
+import javax.servlet.http.HttpServletRequest;
+import java.nio.charset.Charset;
+import java.util.Properties;
+
 
 /**
  *  Provides a way to do short URLs of the form /wiki/PageName.
@@ -200,16 +198,10 @@ public class ShortURLConstructor
     /**
      * {@inheritDoc}
      */
-    public String parsePage( String context,
-                             HttpServletRequest request,
-                             String encoding )
-        throws UnsupportedEncodingException
-    {
-        String pagereq = request.getParameter( "page" );
-
-        if( pagereq == null )
-        {
-            pagereq = parsePageFromURL( request, encoding );
+    public String parsePage( final String context, final HttpServletRequest request, final Charset encoding ) {
+        final String pagereq = request.getParameter( "page" );
+        if( pagereq == null ) {
+            return parsePageFromURL( request, encoding );
         }
 
         return pagereq;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
index 1f1cf0f..67c7da5 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/url/URLConstructor.java
@@ -18,12 +18,13 @@
  */
 package org.apache.wiki.url;
 
-import java.util.Properties;
-import java.io.IOException;
-import javax.servlet.http.HttpServletRequest;
-
 import org.apache.wiki.WikiEngine;
 
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
+import java.nio.charset.Charset;
+import java.util.Properties;
+
 
 /**
  *  Provides an interface through which JSPWiki constructs URLs.
@@ -67,7 +68,7 @@ public interface URLConstructor {
      *  @return This method must return the name of the resource.
      *  @throws IOException If parsing failes
      */
-    String parsePage( String context, HttpServletRequest request, String encoding ) throws IOException;
+    String parsePage( String context, HttpServletRequest request, Charset encoding ) throws IOException;
 
     /**
      *  Returns information which JSP page should continue handling this type of request.


[jspwiki] 03/24: removal of @deprecated code (3) - GroupDatabase: removal of commit(), no replacement as the method wasn't used anymore

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 c7709c0d612ed820a1cd3c0f9da72938a4111095
Author: juanpablo <ju...@apache.org>
AuthorDate: Fri Aug 16 20:16:45 2019 +0200

    removal of @deprecated code (3) - GroupDatabase: removal of commit(), no replacement as the method wasn't used anymore
---
 .../apache/wiki/auth/authorize/GroupDatabase.java    | 20 +++++---------------
 .../wiki/auth/authorize/JDBCGroupDatabase.java       | 15 ---------------
 .../apache/wiki/auth/authorize/XMLGroupDatabase.java | 16 +---------------
 3 files changed, 6 insertions(+), 45 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupDatabase.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupDatabase.java
index af105ff..ca03266 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupDatabase.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/GroupDatabase.java
@@ -18,29 +18,18 @@
  */
 package org.apache.wiki.auth.authorize;
 
-import java.security.Principal;
-import java.util.Properties;
-
 import org.apache.wiki.WikiEngine;
 import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
 import org.apache.wiki.auth.WikiSecurityException;
 
+import java.security.Principal;
+import java.util.Properties;
+
 /**
  * Defines an interface for loading, persisting and storing wiki groups.
  * @since 2.4.22
  */
-public interface GroupDatabase
-{
-    /**
-     * No-op method that in previous versions of JSPWiki was intended to 
-     * atomically commit changes to the user database. Now, the
-     * {@link #save(Group, Principal)} and {@link #delete(Group)} methods
-     * are atomic themselves.
-     * @throws WikiSecurityException never...
-     * @deprecated there is no need to call this method because the save and
-     * delete methods contain their own commit logic
-     */
-    void commit() throws WikiSecurityException;
+public interface GroupDatabase {
 
     /**
      * Looks up and deletes a {@link Group} from the group database. If the
@@ -90,4 +79,5 @@ public interface GroupDatabase
      * @throws WikiSecurityException if the groups cannot be returned by the back-end
      */
     Group[] groups() throws WikiSecurityException;
+
 }
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/JDBCGroupDatabase.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/JDBCGroupDatabase.java
index b6d573e..d5ac0d2 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/JDBCGroupDatabase.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/JDBCGroupDatabase.java
@@ -225,21 +225,6 @@ public class JDBCGroupDatabase implements GroupDatabase {
     private WikiEngine m_engine = null;
 
     /**
-     * No-op method that in previous versions of JSPWiki was intended to
-     * atomically commit changes to the user database. Now, the
-     * {@link #save(Group, Principal)} and {@link #delete(Group)} methods are
-     * atomic themselves.
-     * 
-     * @throws WikiSecurityException never...
-     * @deprecated there is no need to call this method because the save and
-     *             delete methods contain their own commit logic
-     */
-    @Deprecated
-    public void commit() throws WikiSecurityException
-    {
-    }
-
-    /**
      * Looks up and deletes a {@link Group} from the group database. If the
      * group database does not contain the supplied Group. this method throws a
      * {@link NoSuchPrincipalException}. The method commits the results of the
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/XMLGroupDatabase.java b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/XMLGroupDatabase.java
index de3594e..440e252 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/XMLGroupDatabase.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/auth/authorize/XMLGroupDatabase.java
@@ -109,21 +109,7 @@ public class XMLGroupDatabase implements GroupDatabase
 
     private WikiEngine            m_engine         = null;
 
-    private Map<String, Group>                   m_groups         = new HashMap<>();
-
-    /**
-     * No-op method that in previous versions of JSPWiki was intended to
-     * atomically commit changes to the user database. Now, the
-     * {@link #save(Group, Principal)} and {@link #delete(Group)} methods
-     * are atomic themselves.
-     * @throws WikiSecurityException never...
-     * @deprecated there is no need to call this method because the save and
-     * delete methods contain their own commit logic
-     */
-    @Deprecated
-    @Override
-    public void commit() throws WikiSecurityException
-    { }
+    private Map<String, Group>    m_groups         = new HashMap<>();
 
     /**
       * Looks up and deletes a {@link Group} from the group database. If the


[jspwiki] 21/24: removal of @deprecated code (13) - Editor: removed unused getUrl() method

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

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

commit 3600c981aeef284f1ba67f60449350743342df17
Author: juanpablo <ju...@apache.org>
AuthorDate: Mon Aug 19 22:05:56 2019 +0200

    removal of @deprecated code (13) - Editor: removed unused getUrl() method
---
 .../src/main/java/org/apache/wiki/ui/Editor.java   | 31 +++++-----------------
 1 file changed, 6 insertions(+), 25 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java b/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java
index e730be6..e4fff20 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/ui/Editor.java
@@ -37,31 +37,12 @@ public class Editor {
         m_editorManager = wikiContext.getEngine().getEditorManager();
     }
 
-    public String getName()
-    {
+    public String getName() {
         return m_editorName;
     }
 
-    // FIXME: Fails, if the editoriterator is on a non-editor page.
-    /** @deprecated */
-    public String getURL()
-    {
-        final String uri = m_wikiContext.getHttpRequest().getRequestURI();
-        String para = m_wikiContext.getHttpRequest().getQueryString();
-
-        // if para already contains editor parameter, replace instead of append it
-        // FIXME: Should cut out parameter instead of simple setting strin to null, maybe
-        // in futur releases it may change and theres the danger that trailing parameters get lost
-        final int idx = para.indexOf( EditorManager.PARA_EDITOR + "=" );
-        if( idx >= 0 ) {
-            para = para.substring( 0, idx - 1 );
-        }
-
-        return uri + "?" + para + "&amp;" + EditorManager.PARA_EDITOR + "=" + m_editorName;
-    }
-
     /**
-     *  Convinience method which returns XHTML for an option element.
+     *  Convenience method which returns XHTML for an option element.
      * @return "selected='selected'", if this editor is selected.
      */
     public String isSelected( )
@@ -75,15 +56,15 @@ public class Editor {
     }
 
     public String isSelected( final String ifSelected, final String ifNotSelected ) {
-        if ( m_editorName.equals(m_editorManager.getEditorName(m_wikiContext) ) )
-        {
+        if( m_editorName.equals( m_editorManager.getEditorName( m_wikiContext ) ) ) {
             return ifSelected;
         }
         return ifNotSelected;
     }
 
-    public String toString()
-    {
+    @Override
+    public String toString() {
         return m_editorName;
     }
+    
 }


[jspwiki] 14/24: removal of @deprecated code (11) - VariableManager: removal of isVariableLink(String), use LinkParsingOperations#isVariableLink(String) instead

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 9f1b363741a5ed8e39e2faeb3bf170bdac0e7d91
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Aug 17 01:33:05 2019 +0200

    removal of @deprecated code (11) - VariableManager: removal of isVariableLink(String), use LinkParsingOperations#isVariableLink(String) instead
---
 .../main/java/org/apache/wiki/VariableManager.java | 70 +++++++---------------
 1 file changed, 21 insertions(+), 49 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/VariableManager.java b/jspwiki-main/src/main/java/org/apache/wiki/VariableManager.java
index d41ce51..f7d1378 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/VariableManager.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/VariableManager.java
@@ -18,16 +18,6 @@
  */
 package org.apache.wiki;
 
-import java.lang.reflect.Method;
-import java.security.Principal;
-import java.util.Date;
-import java.util.List;
-import java.util.Properties;
-import java.util.ResourceBundle;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.api.engine.FilterManager;
 import org.apache.wiki.api.exceptions.NoSuchVariableException;
@@ -37,6 +27,15 @@ import org.apache.wiki.modules.InternalModule;
 import org.apache.wiki.parser.LinkParsingOperations;
 import org.apache.wiki.preferences.Preferences;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.lang.reflect.Method;
+import java.security.Principal;
+import java.util.Date;
+import java.util.List;
+import java.util.Properties;
+import java.util.ResourceBundle;
+
 /**
  *  Manages variables.  Variables are case-insensitive.  A list of all
  *  available variables is on a Wiki page called "WikiVariables".
@@ -69,22 +68,6 @@ public class VariableManager
     }
 
     /**
-     *  Returns true if the link is really command to insert
-     *  a variable.
-     *  <P>
-     *  Currently we just check if the link starts with "{$".
-     *
-     *  @param link The link text
-     *  @return true, if this represents a variable link.
-     *  @deprecated Use {@link LinkParsingOperations#isVariableLink(String)}
-     */
-    @Deprecated
-    public static boolean isVariableLink( String link )
-    {
-        return new LinkParsingOperations( null ).isVariableLink( link );
-    }
-
-    /**
      *  Parses the link and finds a value.  This is essentially used once
      *  {@link LinkParsingOperations#isVariableLink(String)} has found that
      *  the link text actually contains a variable.  For example, you could
@@ -97,17 +80,13 @@ public class VariableManager
      *          start with "{$", is zero length, etc.)
      *  @throws NoSuchVariableException If a variable is not known.
      */
-    public String parseAndGetValue( WikiContext context,
-                                    String link )
-        throws IllegalArgumentException,
-               NoSuchVariableException
-    {
-        if( !link.startsWith("{$") )
+    public String parseAndGetValue( WikiContext context, String link ) throws IllegalArgumentException, NoSuchVariableException {
+        if( !link.startsWith("{$") ) {
             throw new IllegalArgumentException( "Link does not start with {$" );
-
-        if( !link.endsWith("}") )
+        }
+        if( !link.endsWith("}") ) {
             throw new IllegalArgumentException( "Link does not end with }" );
-
+        }
         String varName = link.substring(2,link.length()-1);
 
         return getValue( context, varName.trim() );
@@ -126,9 +105,7 @@ public class VariableManager
      *  @return The source string with variables expanded.
      */
     // FIXME: somewhat slow.
-    public String expandVariables( WikiContext context,
-                                   String      source )
-    {
+    public String expandVariables( WikiContext context, String source ) {
     	StringBuilder result = new StringBuilder();
 
         for( int i = 0; i < source.length(); i++ )
@@ -222,22 +199,17 @@ public class VariableManager
      *  @throws IllegalArgumentException If the name is somehow broken.
      *  @throws NoSuchVariableException If a variable is not known.
      */
-    public String getValue( WikiContext context,
-                            String      varName )
-        throws IllegalArgumentException,
-               NoSuchVariableException
-    {
-        if( varName == null )
+    public String getValue( WikiContext context, String varName ) throws IllegalArgumentException, NoSuchVariableException {
+        if( varName == null ) {
             throw new IllegalArgumentException( "Null variable name." );
-
-        if( varName.length() == 0 )
+        }
+        if( varName.length() == 0 ) {
             throw new IllegalArgumentException( "Zero length variable name." );
-
+        }
         // Faster than doing equalsIgnoreCase()
         String name = varName.toLowerCase();
 
-        for( int i = 0; i < THE_BIG_NO_NO_LIST.length; i++ )
-        {
+        for( int i = 0; i < THE_BIG_NO_NO_LIST.length; i++ ) {
             if( name.equals(THE_BIG_NO_NO_LIST[i]) )
                 return ""; // FIXME: Should this be something different?
         }