You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jspwiki.apache.org by ju...@apache.org on 2020/01/28 20:34:04 UTC

[jspwiki] 03/32: apply fixes and formatting suggested by IntelliJ

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 ddb2cdd94e9c856fa629e6ed23677dd83d4cb97d
Author: juanpablo <ju...@apache.org>
AuthorDate: Sat Jan 18 00:21:02 2020 +0100

    apply fixes and formatting suggested by IntelliJ
---
 .../main/java/org/apache/wiki/rss/AtomFeed.java    | 109 +++------
 .../java/org/apache/wiki/rss/RSSGenerator.java     | 271 ++++++++-------------
 .../wiki/tasks/auth/SaveUserProfileTask.java       |  11 +-
 .../org/apache/wiki/xmlrpc/MetaWeblogHandler.java  | 205 ++++++----------
 4 files changed, 225 insertions(+), 371 deletions(-)

diff --git a/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java b/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
index 3548c21..b8d7449 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/rss/AtomFeed.java
@@ -36,20 +36,17 @@ import java.io.StringWriter;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 
 /**
  *  Provides an Atom 1.0 standard feed, with enclosures.
  *
  */
-public class AtomFeed extends Feed
-{
+public class AtomFeed extends Feed {
+
     private Namespace m_atomNameSpace = Namespace.getNamespace("http://www.w3.org/2005/Atom");
 
-    /**
-     *  Defines a SimpleDateFormat string for RFC3339-formatted dates.
-     */
+    /** Defines a SimpleDateFormat string for RFC3339-formatted dates. */
     public static final String RFC3339FORMAT = "yyyy-MM-dd'T'HH:mm:ssZZ";
 
     /**
@@ -57,14 +54,13 @@ public class AtomFeed extends Feed
      *  
      *  @param c A WikiContext.
      */
-    public AtomFeed( WikiContext c )
+    public AtomFeed( final WikiContext c )
     {
         super(c);
     }
 
     /**
-     *   This is a bit complicated right now, as there is no proper metadata
-     *   store in JSPWiki.
+     *   This is a bit complicated right now, as there is no proper metadata store in JSPWiki.
      *
      *   @return An unique feed ID.
      */
@@ -73,53 +69,39 @@ public class AtomFeed extends Feed
         return m_wikiContext.getEngine().getBaseURL(); // FIXME: This is not a feed id
     }
 
-    private String getEntryID( Entry e )
+    private String getEntryID( final Entry e )
     {
         return e.getURL(); // FIXME: Not really a feed id!
     }
 
-    private Collection<Element> getItems()
-    {
-        ArrayList<Element> list = new ArrayList<>();
-
-        WikiEngine engine = m_wikiContext.getEngine();
+    private Collection<Element> getItems() {
+        final ArrayList< Element > list = new ArrayList<>();
+        final WikiEngine engine = m_wikiContext.getEngine();
         ServletContext servletContext = null;
-
-        if( m_wikiContext.getHttpRequest() != null )
+        if( m_wikiContext.getHttpRequest() != null ) {
             servletContext = m_wikiContext.getHttpRequest().getSession().getServletContext();
+        }
 
-        for( Entry e : m_entries ) {
-            WikiPage p = e.getPage();
-
-            Element entryEl = getElement( "entry" );
+        for( final Entry e : m_entries ) {
+            final WikiPage p = e.getPage();
+            final Element entryEl = getElement( "entry" );
 
-            //
             //  Mandatory elements
-            //
-
             entryEl.addContent( getElement( "id" ).setText( getEntryID( e ) ) );
             entryEl.addContent( getElement( "title" ).setAttribute( "type", "html" ).setText( e.getTitle() ) );
             entryEl.addContent( getElement( "updated" ).setText( DateFormatUtils.formatUTC( p.getLastModified(), RFC3339FORMAT ) ) );
-            //
-            //  Optional elements
-            //
 
+            //  Optional elements
             entryEl.addContent( getElement( "author" ).addContent( getElement( "name" ).setText( e.getAuthor() ) ) );
             entryEl.addContent( getElement( "link" ).setAttribute( "rel", "alternate" ).setAttribute( "href", e.getURL() ) );
             entryEl.addContent( getElement( "content" ).setAttribute( "type", "html" ).setText( e.getContent() ) );
 
-            //
             //  Check for enclosures
-            //
-
             if( engine.getAttachmentManager().hasAttachments( p ) && servletContext != null ) {
                 try {
-                    List<Attachment> c = engine.getAttachmentManager().listAttachments( p );
-
-                    for( Iterator<Attachment> a = c.iterator(); a.hasNext(); ) {
-                        Attachment att = a.next();
-
-                        Element attEl = getElement( "link" );
+                    final List< Attachment > c = engine.getAttachmentManager().listAttachments( p );
+                    for( final Attachment att : c ) {
+                        final Element attEl = getElement( "link" );
                         attEl.setAttribute( "rel", "enclosure" );
                         attEl.setAttribute( "href", engine.getURL( WikiContext.ATTACH, att.getName(), null, true ) );
                         attEl.setAttribute( "length", Long.toString( att.getSize() ) );
@@ -127,7 +109,7 @@ public class AtomFeed extends Feed
 
                         entryEl.addContent( attEl );
                     }
-                } catch( ProviderException ex ) {
+                } catch( final ProviderException ex ) {
                     // FIXME: log.info("Can't get attachment data",ex);
                 }
             }
@@ -142,73 +124,56 @@ public class AtomFeed extends Feed
      *  {@inheritDoc}
      */
     @Override
-    public String getString()
-    {
-        Element root = getElement("feed");
-        WikiEngine engine = m_wikiContext.getEngine();
+    public String getString() {
+        final Element root = getElement("feed");
+        final WikiEngine engine = m_wikiContext.getEngine();
 
         Date lastModified = new Date(0L);
 
-        for( Iterator< Entry > i = m_entries.iterator(); i.hasNext(); )
-        {
-            Entry e = i.next();
-
-            if( e.getPage().getLastModified().after(lastModified) )
+        for( final Entry e : m_entries ) {
+            if( e.getPage().getLastModified().after( lastModified ) )
                 lastModified = e.getPage().getLastModified();
         }
 
-        //
         //  Mandatory parts
-        //
         root.addContent( getElement("title").setText( getChannelTitle() ) );
         root.addContent( getElement("id").setText(getFeedID()) );
         root.addContent( getElement("updated").setText(DateFormatUtils.formatUTC( lastModified,
                                                                                   RFC3339FORMAT ) ));
 
-        //
         //  Optional
-        //
         // root.addContent( getElement("author").addContent(getElement("name").setText(format())))
         root.addContent( getElement("link").setAttribute("href",engine.getBaseURL()));
         root.addContent( getElement("generator").setText("JSPWiki "+Release.VERSTR));
 
-        String rssFeedURL  = engine.getURL(WikiContext.NONE, "rss.jsp",
-                                           "page="+engine.encodeName(m_wikiContext.getPage().getName())+
-                                           "&mode="+m_mode+
-                                           "&type=atom",
+        final String rssFeedURL  = engine.getURL(WikiContext.NONE, "rss.jsp",
+                                                 "page=" + engine.encodeName( m_wikiContext.getPage().getName() ) +
+                                                 "&mode=" + m_mode +
+                                                 "&type=atom",
                                            true );
-        Element self = getElement("link").setAttribute("rel","self");
-        self.setAttribute("href",rssFeedURL);
-        root.addContent(self);
+        final Element self = getElement( "link" ).setAttribute( "rel","self" );
+        self.setAttribute( "href", rssFeedURL );
+        root.addContent( self );
 
-        //
         //  Items
-        //
-
         root.addContent( getItems() );
 
-        //
         //  aaand output
-        //
-        XMLOutputter output = new XMLOutputter();
-
+        final XMLOutputter output = new XMLOutputter();
         output.setFormat( Format.getPrettyFormat() );
 
-        try
-        {
-            StringWriter res = new StringWriter();
+        try {
+            final StringWriter res = new StringWriter();
             output.output( root, res );
 
             return res.toString();
-        }
-        catch( IOException e )
-        {
+        } catch( final IOException e ) {
             return null;
         }
     }
 
-    private Element getElement( String name )
-    {
+    private Element getElement( final String name ) {
         return new Element( name, m_atomNameSpace );
     }
+
 }
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 dfe9391..d48ea62 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
@@ -24,14 +24,11 @@ import org.apache.wiki.WikiEngine;
 import org.apache.wiki.WikiPage;
 import org.apache.wiki.WikiProvider;
 import org.apache.wiki.WikiSession;
-import org.apache.wiki.api.exceptions.NoRequiredPropertyException;
-import org.apache.wiki.api.exceptions.ProviderException;
 import org.apache.wiki.attachment.Attachment;
 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;
@@ -40,8 +37,7 @@ import java.util.Set;
 /**
  *  The master class for generating different kinds of Feeds (including RSS1.0, 2.0 and Atom).
  *  <p>
- *  This class can produce quite a few different styles of feeds.  The following modes are
- *  available:
+ *  This class can produce quite a few different styles of feeds.  The following modes are available:
  *  
  *  <ul>
  *  <li><b>wiki</b> - All the changes to the given page are enumerated and announced as diffs.</li>
@@ -56,12 +52,12 @@ import java.util.Set;
 // FIXME3.0: This class would need a bit of refactoring.  Method names, e.g. are confusing.
 public class RSSGenerator {
 
-    static Logger              log = Logger.getLogger( RSSGenerator.class );
-    private WikiEngine         m_engine;
+    private static final Logger log = Logger.getLogger( RSSGenerator.class );
+    private WikiEngine m_engine;
 
-    private String             m_channelDescription = "";
-    private String             m_channelLanguage    = "en-us";
-    private boolean            m_enabled = true;
+    private String m_channelDescription = "";
+    private String m_channelLanguage = "en-us";
+    private boolean m_enabled = true;
 
     /** Parameter value to represent RSS 1.0 feeds.  Value is <tt>{@value}</tt>. */
     public static final String RSS10 = "rss10";
@@ -82,8 +78,7 @@ public class RSSGenerator {
     public static final String MODE_FULL = "full";
 
     /**
-     *  Defines the property name for the RSS channel description.  Default value for the
-     *  channel description is an empty string.
+     *  Defines the property name for the RSS channel description.  Default value for the channel description is an empty string.
      *  @since 1.7.6.
      */
     public static final String PROP_CHANNEL_DESCRIPTION = "jspwiki.rss.channelDescription";
@@ -92,48 +87,47 @@ public class RSSGenerator {
      *  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";
+    public static final String PROP_CHANNEL_LANGUAGE = "jspwiki.rss.channelLanguage";
 
     /** Defines the property name for the RSS channel title.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_CHANNEL_TITLE       = "jspwiki.rss.channelTitle";
+    public static final String PROP_CHANNEL_TITLE = "jspwiki.rss.channelTitle";
 
     /**
      *  Defines the property name for the RSS generator main switch.
      *  @since 1.7.6.
      */
-    public static final String PROP_GENERATE_RSS        = "jspwiki.rss.generate";
+    public static final String PROP_GENERATE_RSS = "jspwiki.rss.generate";
 
     /**
      *  Defines the property name for the RSS file that the wiki should generate.
      *  @since 1.7.6.
      */
-    public static final String PROP_RSSFILE             = "jspwiki.rss.fileName";
+    public static final String PROP_RSSFILE = "jspwiki.rss.fileName";
 
     /**
      *  Defines the property name for the RSS generation interval in seconds.
      *  @since 1.7.6.
      */
-    public static final String PROP_INTERVAL            = "jspwiki.rss.interval";
+    public static final String PROP_INTERVAL = "jspwiki.rss.interval";
 
     /** Defines the property name for the RSS author.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_RSS_AUTHOR          = "jspwiki.rss.author";
+    public static final String PROP_RSS_AUTHOR = "jspwiki.rss.author";
 
     /** Defines the property name for the RSS author email.  Value is <tt>{@value}</tt>. */
-    public static final String PROP_RSS_AUTHOREMAIL     = "jspwiki.rss.author.email";
+    public static final String PROP_RSS_AUTHOREMAIL = "jspwiki.rss.author.email";
 
-    private static final int MAX_CHARACTERS             = Integer.MAX_VALUE-1;
+    private static final int MAX_CHARACTERS = Integer.MAX_VALUE-1;
 
     /**
      *  Initialize the RSS generator for a given WikiEngine.
      *
      *  @param engine The WikiEngine.
      *  @param properties The properties.
-     *  @throws NoRequiredPropertyException If something is missing from the given property set.
      */
-    public RSSGenerator( WikiEngine engine, Properties properties ) {
+    public RSSGenerator( final WikiEngine engine, final Properties properties ) {
         m_engine = engine;
         m_channelDescription = properties.getProperty( PROP_CHANNEL_DESCRIPTION, m_channelDescription );
-        m_channelLanguage    = properties.getProperty( PROP_CHANNEL_LANGUAGE, m_channelLanguage );
+        m_channelLanguage = properties.getProperty( PROP_CHANNEL_LANGUAGE, m_channelLanguage );
     }
 
     /**
@@ -143,8 +137,7 @@ public class RSSGenerator {
      *  @return A formatted string.
      */
     // FIXME: Replicates Feed.format().
-    public static String format( String s )
-    {
+    public static String format( String s ) {
         s = TextUtil.replaceString( s, "&", "&amp;" );
         s = TextUtil.replaceString( s, "<", "&lt;" );
         s = TextUtil.replaceString( s, "]]>", "]]&gt;" );
@@ -152,74 +145,60 @@ public class RSSGenerator {
         return s.trim();
     }
 
-    private String getAuthor( WikiPage page )
-    {
+    private String getAuthor( final WikiPage page ) {
         String author = page.getAuthor();
-
-        if( author == null ) author = "An unknown author";
+        if( author == null ) {
+            author = "An unknown author";
+        }
 
         return author;
     }
 
-    private String getAttachmentDescription( Attachment att )
-    {
-        String author = getAuthor(att);
-        StringBuilder sb = new StringBuilder();
+    private String getAttachmentDescription( final Attachment att ) {
+        final String author = getAuthor( att );
+        final StringBuilder sb = new StringBuilder();
 
-        if( att.getVersion() != 1 )
-        {
-            sb.append(author+" uploaded a new version of this attachment on "+att.getLastModified() );
-        }
-        else
-        {
-            sb.append(author+" created this attachment on "+att.getLastModified() );
+        if( att.getVersion() != 1 ) {
+            sb.append( author ).append( " uploaded a new version of this attachment on " ).append( att.getLastModified() );
+        } else {
+            sb.append( author ).append( " created this attachment on " ).append( att.getLastModified() );
         }
 
-        sb.append("<br /><hr /><br />");
-        sb.append( "Parent page: <a href=\""+
-                   m_engine.getURL( WikiContext.VIEW, att.getParentName(), null, true ) +
-                   "\">"+att.getParentName()+"</a><br />" );
-        sb.append( "Info page: <a href=\""+
-                   m_engine.getURL( WikiContext.INFO, att.getName(), null, true ) +
-                   "\">"+att.getName()+"</a>" );
+        sb.append( "<br /><hr /><br />" )
+          .append( "Parent page: <a href=\"" )
+          .append( m_engine.getURL( WikiContext.VIEW, att.getParentName(), null, true ) )
+          .append( "\">" ).append( att.getParentName() ).append( "</a><br />" )
+          .append( "Info page: <a href=\"" )
+          .append( m_engine.getURL( WikiContext.INFO, att.getName(), null, true ) )
+          .append( "\">" ).append( att.getName() ).append( "</a>" );
 
         return sb.toString();
     }
 
-    private String getPageDescription( WikiPage page )
-    {
-    	StringBuilder buf = new StringBuilder();
-        String author = getAuthor(page);
-
-        WikiContext ctx = new WikiContext( m_engine, page );
-        if( page.getVersion() > 1 )
-        {
-            String diff = m_engine.getDifferenceManager().getDiff( ctx,
-                                                          page.getVersion() - 1, // FIXME: Will fail when non-contiguous versions
-                                                                   page.getVersion() );
-
-            buf.append(author+" changed this page on "+page.getLastModified()+":<br /><hr /><br />" );
-            buf.append(diff);
-        }
-        else
-        {
-            buf.append(author+" created this page on "+page.getLastModified()+":<br /><hr /><br />" );
-            buf.append(m_engine.getRenderingManager().getHTML( page.getName() ));
+    private String getPageDescription( final WikiPage page ) {
+        final StringBuilder buf = new StringBuilder();
+        final String author = getAuthor( page );
+        final WikiContext ctx = new WikiContext( m_engine, page );
+        if( page.getVersion() > 1 ) {
+            final String diff = m_engine.getDifferenceManager().getDiff( ctx,
+                                                                page.getVersion() - 1, // FIXME: Will fail when non-contiguous versions
+                                                                         page.getVersion() );
+
+            buf.append( author ).append( " changed this page on " ).append( page.getLastModified() ).append( ":<br /><hr /><br />" );
+            buf.append( diff );
+        } else {
+            buf.append( author ).append( " created this page on " ).append( page.getLastModified() ).append( ":<br /><hr /><br />" );
+            buf.append( m_engine.getRenderingManager().getHTML( page.getName() ) );
         }
 
         return buf.toString();
     }
 
-    private String getEntryDescription( WikiPage page )
-    {
-        String res;
-
-        if( page instanceof Attachment )
-        {
+    private String getEntryDescription( final WikiPage page ) {
+        final String res;
+        if( page instanceof Attachment ) {
             res = getAttachmentDescription( (Attachment)page );
-        }
-        else
-        {
+        } else {
             res = getPageDescription( page );
         }
 
@@ -227,19 +206,18 @@ public class RSSGenerator {
     }
 
     // FIXME: This should probably return something more intelligent
-    private String getEntryTitle( WikiPage page )
+    private String getEntryTitle( final WikiPage page )
     {
-        return page.getName()+", version "+page.getVersion();
+        return page.getName() + ", version " + page.getVersion();
     }
 
     /**
-     *  Generates the RSS resource.  You probably want to output this
-     *  result into a file or something, or serve as output from a servlet.
+     *  Generates the RSS resource.  You probably want to output this result into a file or something, or serve as output from a servlet.
      *  
      *  @return A RSS 1.0 feed in the "full" mode.
      */
     public String generate() {
-        final WikiContext context = new WikiContext( m_engine,new WikiPage( m_engine, "__DUMMY" ) );
+        final WikiContext context = new WikiContext( m_engine, new WikiPage( m_engine, "__DUMMY" ) );
         context.setRequestContext( WikiContext.RSS );
         final Feed feed = new RSS10Feed( context );
         return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + generateFullWikiRSS( context, feed );
@@ -247,7 +225,8 @@ public class RSSGenerator {
 
     /**
      * Returns the content type of this RSS feed.
-     *  @since 2.3.15
+     *
+     * @since 2.3.15
      * @param mode the RSS mode: {@link #RSS10}, {@link #RSS20} or {@link #ATOM}.
      * @return the content type
      */
@@ -262,14 +241,13 @@ public class RSSGenerator {
     }
 
     /**
-     *  Generates a feed based on a context and list of changes.
+     * Generates a feed based on a context and list of changes.
+     *
      * @param wikiContext The WikiContext
      * @param changed A list of Entry objects
      * @param mode The mode (wiki/blog)
      * @param type The type (RSS10, RSS20, ATOM).  Default is RSS 1.0
      * @return Fully formed XML.
-     *
-     * @throws ProviderException If the underlying provider failed.
      * @throws IllegalArgumentException If an illegal mode is given.
      */
     public String generateFeed( final WikiContext wikiContext, final List< WikiPage > changed, final String mode, final String type ) throws IllegalArgumentException {
@@ -301,6 +279,7 @@ public class RSSGenerator {
 
     /**
      * Returns <code>true</code> if RSS generation is enabled.
+     *
      * @return whether RSS generation is currently enabled
      */
     public boolean isEnabled()
@@ -309,11 +288,9 @@ public class RSSGenerator {
     }
 
     /**
-     * Turns RSS generation on or off. This setting is used to set
-     * the "enabled" flag only for use by callers, and does not
-     * actually affect whether the {@link #generate()} or
-     * {@link #generateFeed(WikiContext, List, String, String)}
-     * methods output anything.
+     * Turns RSS generation on or off. This setting is used to set the "enabled" flag only for use by callers, and does not
+     * actually affect whether the {@link #generate()} or {@link #generateFeed(WikiContext, List, String, String)} methods output anything.
+     *
      * @param enabled whether RSS generation is considered enabled.
      */
     public synchronized void setEnabled( final boolean enabled )
@@ -339,12 +316,9 @@ public class RSSGenerator {
         final WikiSession session = WikiSession.guestSession( m_engine );
         int items = 0;
         for( final Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
-            WikiPage page = i.next();
+            final WikiPage page = i.next();
 
-            //
             //  Check if the anonymous user has view access to this page.
-            //
-
             if( !m_engine.getAuthorizationManager().checkPermission(session, new PagePermission(page,PagePermission.VIEW_ACTION) ) ) {
                 // No permission, skip to the next one.
                 continue;
@@ -371,64 +345,46 @@ public class RSSGenerator {
     }
 
     /**
-     *  Create RSS/Atom as if this page was a wikipage (in contrast to Blog mode).
+     * Create RSS/Atom as if this page was a wikipage (in contrast to Blog mode).
      *
      * @param wikiContext The WikiContext
      * @param changed A List of changed WikiPages.
      * @param feed A Feed object to fill.
      * @return the RSS representation of the wiki context
      */
-    protected String generateWikiPageRSS( WikiContext wikiContext, List< WikiPage > changed, Feed feed )
-    {
+    protected String generateWikiPageRSS( final WikiContext wikiContext, final List< WikiPage > changed, final Feed feed ) {
         feed.setChannelTitle( m_engine.getApplicationName()+": "+wikiContext.getPage().getName() );
         feed.setFeedURL( wikiContext.getViewURL( wikiContext.getPage().getName() ) );
-        String language = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
+        final String language = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
 
-        if( language != null )
+        if( language != null ) {
             feed.setChannelLanguage( language );
-        else
+        } else {
             feed.setChannelLanguage( m_channelLanguage );
+        }
+        final String channelDescription = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
 
-        String channelDescription = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
-
-        if( channelDescription != null )
-        {
+        if( channelDescription != null ) {
             feed.setChannelDescription( channelDescription );
         }
 
-        Collections.sort( changed, new PageTimeComparator() );
+        changed.sort( new PageTimeComparator() );
 
         int items = 0;
-        for( Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ )
-        {
-            WikiPage page = i.next();
-
-            Entry e = new Entry();
-
+        for( final Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
+            final WikiPage page = i.next();
+            final Entry e = new Entry();
             e.setPage( page );
-
             String url;
 
-            if( page instanceof Attachment )
-            {
-                url = m_engine.getURL( WikiContext.ATTACH,
-                                       page.getName(),
-                                       "version="+page.getVersion(),
-                                       true );
-            }
-            else
-            {
-                url = m_engine.getURL( WikiContext.VIEW,
-                                       page.getName(),
-                                       "version="+page.getVersion(),
-                                       true );
+            if( page instanceof Attachment ) {
+                url = m_engine.getURL( WikiContext.ATTACH, page.getName(), "version=" + page.getVersion(),true );
+            } else {
+                url = m_engine.getURL( WikiContext.VIEW, page.getName(), "version=" + page.getVersion(), true );
             }
 
-            // Unfortunately, this is needed because the code will again go through
-            // replacement conversion
-
+            // Unfortunately, this is needed because the code will again go through replacement conversion
             url = TextUtil.replaceString( url, "&amp;", "&" );
-
             e.setURL( url );
             e.setTitle( getEntryTitle(page) );
             e.setContent( getEntryDescription(page) );
@@ -446,18 +402,15 @@ public class RSSGenerator {
      *
      *  @param wikiContext The WikiContext, as usual.
      *  @param changed A list of the changed pages.
-     *  @param feed A valid Feed object.  The feed will be used to create the RSS/Atom, depending
-     *              on which kind of an object you want to put in it.
+     *  @param feed A valid Feed object.  The feed will be used to create the RSS/Atom, depending on which kind of an object you want to put in it.
      *  @return A String of valid RSS or Atom.
-     *  @throws ProviderException If reading of pages was not possible.
      */
-    protected String generateBlogRSS( WikiContext wikiContext, List< WikiPage > changed, Feed feed ) {
+    protected String generateBlogRSS( final WikiContext wikiContext, final List< WikiPage > changed, final Feed feed ) {
         if( log.isDebugEnabled() ) {
             log.debug( "Generating RSS for blog, size=" + changed.size() );
         }
 
-        String ctitle = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_TITLE );
-
+        final String ctitle = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_TITLE );
         if( ctitle != null ) {
             feed.setChannelTitle( ctitle );
         } else {
@@ -466,31 +419,26 @@ public class RSSGenerator {
 
         feed.setFeedURL( wikiContext.getViewURL( wikiContext.getPage().getName() ) );
 
-        String language = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
-
+        final String language = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_LANGUAGE );
         if( language != null ) {
             feed.setChannelLanguage( language );
         } else {
             feed.setChannelLanguage( m_channelLanguage );
         }
 
-        String channelDescription = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
-
+        final String channelDescription = m_engine.getVariableManager().getVariable( wikiContext, PROP_CHANNEL_DESCRIPTION );
         if( channelDescription != null ) {
             feed.setChannelDescription( channelDescription );
         }
 
-        Collections.sort( changed, new PageTimeComparator() );
+        changed.sort( new PageTimeComparator() );
 
         int items = 0;
-        for( Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
-            WikiPage page = i.next();
-
-            Entry e = new Entry();
-
+        for( final Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < 15; items++ ) {
+            final WikiPage page = i.next();
+            final Entry e = new Entry();
             e.setPage( page );
-
-            String url;
+            final String url;
 
             if( page instanceof Attachment ) {
                 url = m_engine.getURL( WikiContext.ATTACH, page.getName(),null,true );
@@ -500,14 +448,11 @@ public class RSSGenerator {
 
             e.setURL( url );
 
-            //
             //  Title
-            //
-
-            String pageText = m_engine.getPageManager().getPureText(page.getName(), WikiProvider.LATEST_VERSION );
+            String pageText = m_engine.getPageManager().getPureText( page.getName(), WikiProvider.LATEST_VERSION );
 
             String title = "";
-            int firstLine = pageText.indexOf('\n');
+            final int firstLine = pageText.indexOf('\n');
 
             if( firstLine > 0 ) {
                 title = pageText.substring( 0, firstLine ).trim();
@@ -524,31 +469,21 @@ public class RSSGenerator {
 
             e.setTitle( title );
 
-            //
             //  Description
-            //
-
             if( firstLine > 0 ) {
                 int maxlen = pageText.length();
-                if( maxlen > MAX_CHARACTERS ) maxlen = MAX_CHARACTERS;
-
-                if( maxlen > 0 ) {
-                    pageText = m_engine.getRenderingManager().textToHTML( wikiContext, pageText.substring( firstLine + 1, maxlen ).trim() );
-
-                    if( maxlen == MAX_CHARACTERS ) {
-                        pageText += "...";
-                    }
-
-                    e.setContent( pageText );
-                } else {
-                    e.setContent( title );
+                if( maxlen > MAX_CHARACTERS ) {
+                    maxlen = MAX_CHARACTERS;
                 }
+                pageText = m_engine.getRenderingManager().textToHTML( wikiContext, pageText.substring( firstLine + 1, maxlen ).trim() );
+                if( maxlen == MAX_CHARACTERS ) {
+                    pageText += "...";
+                }
+                e.setContent( pageText );
             } else {
                 e.setContent( title );
             }
-
             e.setAuthor( getAuthor(page) );
-
             feed.addEntry( e );
         }
 
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java b/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java
index 9a53bf8..7aee63c 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/tasks/auth/SaveUserProfileTask.java
@@ -1,10 +1,5 @@
 package org.apache.wiki.tasks.auth;
 
-import java.util.Locale;
-
-import javax.mail.MessagingException;
-import javax.mail.internet.AddressException;
-
 import org.apache.log4j.Logger;
 import org.apache.wiki.WikiContext;
 import org.apache.wiki.WikiEngine;
@@ -17,6 +12,10 @@ import org.apache.wiki.workflow.Outcome;
 import org.apache.wiki.workflow.Task;
 import org.apache.wiki.workflow.WorkflowManager;
 
+import javax.mail.MessagingException;
+import javax.mail.internet.AddressException;
+import java.util.Locale;
+
 
 /**
  * Handles the actual profile save action. 
@@ -32,7 +31,7 @@ public class SaveUserProfileTask extends Task {
      * Constructs a new Task for saving a user profile.
      * @param engine the wiki engine
      */
-    public SaveUserProfileTask( WikiEngine engine, Locale loc ) {
+    public SaveUserProfileTask( final WikiEngine engine, final Locale loc ) {
         super( TasksManager.USER_PROFILE_SAVE_TASK_MESSAGE_KEY );
         m_engine = engine;
         m_loc = loc;
diff --git a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
index d2d8c80..bf2a206 100644
--- a/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
+++ b/jspwiki-main/src/main/java/org/apache/wiki/xmlrpc/MetaWeblogHandler.java
@@ -51,17 +51,16 @@ import java.util.List;
  *  @since 2.1.7
  */
 
-public class MetaWeblogHandler
-    implements WikiRPCHandler
-{
-    private static Logger log = Logger.getLogger( MetaWeblogHandler.class );
+public class MetaWeblogHandler implements WikiRPCHandler {
+
+    private static final Logger log = Logger.getLogger( MetaWeblogHandler.class );
 
     private WikiContext m_context;
 
     /**
      *  {@inheritDoc}
      */
-    public void initialize( WikiContext context )
+    public void initialize( final WikiContext context )
     {
         m_context = context;
     }
@@ -73,36 +72,26 @@ public class MetaWeblogHandler
      *  <p>
      *  If there is no authentication enabled, returns normally.
      *
-     *  @throw XmlRpcException with the correct error message, if auth fails.
+     *  @throws XmlRpcException with the correct error message, if auth fails.
      */
-    private void checkPermissions( WikiPage page,
-                                   String username,
-                                   String password,
-                                   String permission )
-        throws XmlRpcException
-    {
-        try
-        {
-            AuthenticationManager amm = m_context.getEngine().getAuthenticationManager();
-            AuthorizationManager mgr = m_context.getEngine().getAuthorizationManager();
-
-            if( amm.login( m_context.getWikiSession(), m_context.getHttpRequest(), username, password ) )
-            {
-                if( !mgr.checkPermission( m_context.getWikiSession(), PermissionFactory.getPagePermission( page, permission ) ))
-                {
+    private void checkPermissions( final WikiPage page,
+                                   final String username,
+                                   final String password,
+                                   final String permission ) throws XmlRpcException {
+        try {
+            final AuthenticationManager amm = m_context.getEngine().getAuthenticationManager();
+            final AuthorizationManager mgr = m_context.getEngine().getAuthorizationManager();
+
+            if( amm.login( m_context.getWikiSession(), m_context.getHttpRequest(), username, password ) ) {
+                if( !mgr.checkPermission( m_context.getWikiSession(), PermissionFactory.getPagePermission( page, permission ) ) ) {
                     throw new XmlRpcException( 1, "No permission" );
                 }
-            }
-            else
-            {
+            } else {
                 throw new XmlRpcException( 1, "Unknown login" );
             }
-        }
-        catch( WikiSecurityException e )
-        {
+        } catch( final WikiSecurityException e ) {
             throw new XmlRpcException( 1, e.getMessage(), e );
         }
-        return;
     }
 
     /**
@@ -114,15 +103,13 @@ public class MetaWeblogHandler
      *  @throws XmlRpcException If something goes wrong
      *  @return An empty hashtable.
      */
-    public Hashtable getCategories( String blogid, String username, String password )  throws XmlRpcException {
+    public Hashtable< Object, Object > getCategories( final String blogid, final String username, final String password )  throws XmlRpcException {
         final WikiPage page = m_context.getEngine().getPageManager().getPage( blogid );
         checkPermissions( page, username, password, "view" );
-        final Hashtable ht = new Hashtable();
-
-        return ht;
+        return new Hashtable<>();
     }
 
-    private String getURL( String page ) {
+    private String getURL( final String page ) {
         return m_context.getEngine().getURL( WikiContext.VIEW, page,null, true ); // Force absolute urls
     }
 
@@ -132,21 +119,19 @@ public class MetaWeblogHandler
      *  @param page The actual entry page
      *  @return A metaWeblog entry struct.
      */
-    private Hashtable<String,Object> makeEntry( WikiPage page ) {
-        Hashtable<String, Object> ht = new Hashtable<>();
-
-        WikiPage firstVersion = m_context.getEngine().getPageManager().getPage( page.getName(), 1 );
-
-        ht.put("dateCreated", firstVersion.getLastModified());
-        ht.put("link", getURL(page.getName()));
-        ht.put("permaLink", getURL(page.getName()));
-        ht.put("postid", page.getName());
-        ht.put("userid", page.getAuthor());
+    private Hashtable< String,Object > makeEntry( final WikiPage page ) {
+        final WikiPage firstVersion = m_context.getEngine().getPageManager().getPage( page.getName(), 1 );
+        final Hashtable< String, Object > ht = new Hashtable<>();
+        ht.put( "dateCreated", firstVersion.getLastModified() );
+        ht.put( "link", getURL(page.getName() ) );
+        ht.put( "permaLink", getURL(page.getName() ) );
+        ht.put( "postid", page.getName() );
+        ht.put( "userid", page.getAuthor() );
 
         final String pageText = m_context.getEngine().getPageManager().getText(page.getName());
-        String title = "";
         final int firstLine = pageText.indexOf('\n');
 
+        String title = "";
         if( firstLine > 0 ) {
             title = pageText.substring( 0, firstLine );
         }
@@ -177,29 +162,22 @@ public class MetaWeblogHandler
      *  @return As per MetaweblogAPI specification
      */
     // FIXME: The implementation is suboptimal, as it goes through all of the blog entries.
-    public Hashtable getRecentPosts( String blogid, String username, String password, int numberOfPosts) throws XmlRpcException {
-        Hashtable<String, Hashtable<String, Object>> result = new Hashtable<>();
-
+    public Hashtable getRecentPosts( final String blogid, final String username, final String password, final int numberOfPosts ) throws XmlRpcException {
+        final Hashtable<String, Hashtable<String, Object>> result = new Hashtable<>();
         log.info( "metaWeblog.getRecentPosts() called");
-
-        WikiPage page = m_context.getEngine().getPageManager().getPage( blogid );
-
+        final WikiPage page = m_context.getEngine().getPageManager().getPage( blogid );
         checkPermissions( page, username, password, "view" );
 
         final WeblogPlugin plugin = new WeblogPlugin();
-        final List<WikiPage> changed = plugin.findBlogEntries( m_context.getEngine(), blogid, new Date( 0L ), new Date() );
-
+        final List< WikiPage > changed = plugin.findBlogEntries( m_context.getEngine(), blogid, new Date( 0L ), new Date() );
         changed.sort( new PageTimeComparator() );
 
         int items = 0;
-        for( Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < numberOfPosts; items++ )
-        {
-            WikiPage p = i.next();
-
+        for( final Iterator< WikiPage > i = changed.iterator(); i.hasNext() && items < numberOfPosts; items++ ) {
+            final WikiPage p = i.next();
             result.put( "entry", makeEntry( p ) );
         }
 
-
         return result;
     }
 
@@ -214,41 +192,32 @@ public class MetaWeblogHandler
      *  @return Returns an empty string
      *  @throws XmlRpcException If something goes wrong
      */
-    public String newPost( String blogid,
-                           String username,
-                           String password,
-                           Hashtable content,
-                           boolean publish )
-        throws XmlRpcException
-    {
+    public String newPost( final String blogid,
+                           final String username,
+                           final String password,
+                           final Hashtable< String, Object > content,
+                           final boolean publish ) throws XmlRpcException {
         log.info("metaWeblog.newPost() called");
-        WikiEngine engine = m_context.getEngine();
-
-        WikiPage page = engine.getPageManager().getPage( blogid );
+        final WikiEngine engine = m_context.getEngine();
+        final WikiPage page = engine.getPageManager().getPage( blogid );
         checkPermissions( page, username, password, "createPages" );
 
-        try
-        {
-            WeblogEntryPlugin plugin = new WeblogEntryPlugin();
-
-            String pageName = plugin.getNewEntryPage( engine, blogid );
-
-            WikiPage entryPage = new WikiPage( engine, pageName );
+        try {
+            final WeblogEntryPlugin plugin = new WeblogEntryPlugin();
+            final String pageName = plugin.getNewEntryPage( engine, blogid );
+            final WikiPage entryPage = new WikiPage( engine, pageName );
             entryPage.setAuthor( username );
 
-            WikiContext context = new WikiContext( engine, entryPage );
-
-            StringBuilder text = new StringBuilder();
-            text.append( "!"+content.get("title") );
+            final WikiContext context = new WikiContext( engine, entryPage );
+            final StringBuilder text = new StringBuilder();
+            text.append( "!" ).append( content.get( "title" ) );
             text.append( "\n\n" );
             text.append( content.get("description") );
 
             log.debug("Writing entry: "+text);
 
             engine.getPageManager().saveText( context, text.toString() );
-        }
-        catch( Exception e )
-        {
+        } catch( final Exception e ) {
             log.error("Failed to create weblog entry",e);
             throw new XmlRpcException( 0, "Failed to create weblog entry: "+e.getMessage() );
         }
@@ -267,29 +236,26 @@ public class MetaWeblogHandler
      *  @param content As per the MetaweblogAPI contract
      *  @return As per the MetaweblogAPI contract
      *  @throws XmlRpcException If something goes wrong
-     *
      */
-    public Hashtable newMediaObject( String blogid,
-                                     String username,
-                                     String password,
-                                     Hashtable content )
-        throws XmlRpcException
-    {
-        WikiEngine engine = m_context.getEngine();
-        String url = "";
+    public Hashtable< String, Object > newMediaObject( final String blogid,
+                                                       final String username,
+                                                       final String password,
+                                                       final Hashtable< String, Object > content ) throws XmlRpcException {
+        final WikiEngine engine = m_context.getEngine();
+        final String url;
 
-        log.info("metaWeblog.newMediaObject() called");
+        log.info( "metaWeblog.newMediaObject() called" );
 
-        WikiPage page = engine.getPageManager().getPage( blogid );
+        final WikiPage page = engine.getPageManager().getPage( blogid );
         checkPermissions( page, username, password, "upload" );
 
-        String name = (String) content.get( "name" );
-        byte[] data = (byte[]) content.get( "bits" );
+        final String name = (String) content.get( "name" );
+        final byte[] data = (byte[]) content.get( "bits" );
 
-        AttachmentManager attmgr = engine.getAttachmentManager();
+        final AttachmentManager attmgr = engine.getAttachmentManager();
 
         try {
-            Attachment att = new Attachment( engine, blogid, name );
+            final Attachment att = new Attachment( engine, blogid, name );
             att.setAuthor( username );
             attmgr.storeAttachment( att, new ByteArrayInputStream( data ) );
 
@@ -299,7 +265,7 @@ public class MetaWeblogHandler
             throw new XmlRpcException( 0, "Failed to upload media object: "+e.getMessage() );
         }
 
-        Hashtable<String, Object> result = new Hashtable<String, Object>();
+        final Hashtable< String, Object > result = new Hashtable<>();
         result.put("url", url);
 
         return result;
@@ -307,33 +273,28 @@ public class MetaWeblogHandler
 
 
     /**
-     *  Allows the user to edit a post.  It does not allow general
-     *   editability of wiki pages, because of the limitations of the
-     *  metaWeblog API.
+     *  Allows the user to edit a post.  It does not allow general editability of wiki pages, because of the limitations of the metaWeblog API.
      */
-    boolean editPost( String postid,
-                      String username,
-                      String password,
-                      Hashtable content,
-                      boolean publish )
-        throws XmlRpcException
-    {
-        WikiEngine engine = m_context.getEngine();
+    boolean editPost( final String postid,
+                      final String username,
+                      final String password,
+                      final Hashtable< String,Object > content,
+                      final boolean publish ) throws XmlRpcException {
+        final WikiEngine engine = m_context.getEngine();
         log.info("metaWeblog.editPost("+postid+") called");
 
         // FIXME: Is postid correct?  Should we determine it from the page name?
-        WikiPage page = engine.getPageManager().getPage( postid );
+        final WikiPage page = engine.getPageManager().getPage( postid );
         checkPermissions( page, username, password, "edit" );
 
-        try
-        {
-            WikiPage entryPage = (WikiPage)page.clone();
+        try {
+            final WikiPage entryPage = (WikiPage)page.clone();
             entryPage.setAuthor( username );
 
-            WikiContext context = new WikiContext( engine, entryPage );
+            final WikiContext context = new WikiContext( engine, entryPage );
 
-            StringBuilder text = new StringBuilder();
-            text.append( "!"+content.get("title") );
+            final StringBuilder text = new StringBuilder();
+            text.append( "!" ).append( content.get( "title" ) );
             text.append( "\n\n" );
             text.append( content.get("description") );
 
@@ -352,17 +313,11 @@ public class MetaWeblogHandler
      *  Gets the text of any page.  The title of the page is parsed
      *  (if any is provided).
      */
-    Hashtable getPost( String postid,
-                       String username,
-                       String password )
-        throws XmlRpcException
-    {
-        String wikiname = "FIXME";
-
-        WikiPage page = m_context.getEngine().getPageManager().getPage( wikiname );
-
+    Hashtable< String, Object > getPost( final String postid, final String username, final String password ) throws XmlRpcException {
+        final String wikiname = "FIXME";
+        final WikiPage page = m_context.getEngine().getPageManager().getPage( wikiname );
         checkPermissions( page, username, password, "view" );
-
         return makeEntry( page );
     }
+
 }