roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject svn commit: r1588757 [5/25] - in /roller/branches/rome2/app/src: main/java/org/apache/roller/ main/java/org/apache/roller/planet/business/ main/java/org/apache/roller/planet/business/fetcher/ main/java/org/apache/roller/planet/business/jpa/ main/java/o...
Date Sun, 20 Apr 2014 13:39:01 GMT
Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/PluginManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/PluginManagerImpl.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/PluginManagerImpl.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/PluginManagerImpl.java Sun Apr 20 13:38:51 2014
@@ -20,7 +20,6 @@ package org.apache.roller.weblogger.busi
 
 import java.util.ArrayList;
 import org.apache.roller.weblogger.business.plugins.entry.WeblogEntryPlugin;
-import java.util.Iterator;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
@@ -29,7 +28,7 @@ import org.apache.commons.logging.LogFac
 import org.apache.roller.weblogger.config.WebloggerConfig;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
 import org.apache.roller.weblogger.pojos.Weblog;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.roller.weblogger.business.plugins.comment.WeblogEntryCommentPlugin;
 import org.apache.roller.weblogger.pojos.WeblogEntryComment;
 import org.apache.roller.weblogger.util.HTMLSanitizer;
@@ -43,10 +42,10 @@ public class PluginManagerImpl implement
     private static Log log = LogFactory.getLog(PluginManagerImpl.class);
     
     // Plugin classes keyed by plugin name
-    static Map mPagePlugins = new LinkedHashMap();
+    static Map<String, Class> mPagePlugins = new LinkedHashMap<String, Class>();
     
     // Comment plugins
-    private List<WeblogEntryCommentPlugin> commentPlugins = new ArrayList();
+    private List<WeblogEntryCommentPlugin> commentPlugins = new ArrayList<WeblogEntryCommentPlugin>();
     
     
     /**
@@ -70,12 +69,10 @@ public class PluginManagerImpl implement
     /**
      * Create and init plugins for processing entries in a specified website.
      */
-    public Map getWeblogEntryPlugins(Weblog website) {
-        Map ret = new LinkedHashMap();
-        Iterator it = this.mPagePlugins.values().iterator();
-        while (it.hasNext()) {
+    public Map<String, WeblogEntryPlugin> getWeblogEntryPlugins(Weblog website) {
+        Map<String, WeblogEntryPlugin> ret = new LinkedHashMap<String, WeblogEntryPlugin>();
+        for (Class pluginClass : PluginManagerImpl.mPagePlugins.values()) {
             try {
-                Class pluginClass = (Class)it.next();
                 WeblogEntryPlugin plugin = (WeblogEntryPlugin)pluginClass.newInstance();
                 plugin.init(website);
                 ret.put(plugin.getName(), plugin);
@@ -86,17 +83,15 @@ public class PluginManagerImpl implement
         return ret;
     }
     
-    public String applyWeblogEntryPlugins(Map pagePlugins,WeblogEntry entry, String str) {
+    public String applyWeblogEntryPlugins(Map pagePlugins, WeblogEntry entry, String str) {
 
         String ret = str;
         WeblogEntry copy = new WeblogEntry(entry);
-        List entryPlugins = copy.getPluginsList();
+        List<String> entryPlugins = copy.getPluginsList();
 
-        if (entryPlugins != null && !entryPlugins.isEmpty()) {
-            Iterator iter = entryPlugins.iterator();
-            while (iter.hasNext()) {
-                String key = (String)iter.next();
-                WeblogEntryPlugin pagePlugin = (WeblogEntryPlugin)pagePlugins.get(key);
+        if (entryPlugins != null) {
+            for (String key : entryPlugins) {
+                WeblogEntryPlugin pagePlugin = (WeblogEntryPlugin) pagePlugins.get(key);
                 if (pagePlugin != null) {
                     ret = pagePlugin.render(entry, ret);
                 } else {
@@ -129,7 +124,7 @@ public class PluginManagerImpl implement
         String content = text;
         
         if (commentPlugins.size() > 0) {
-            for( WeblogEntryCommentPlugin plugin : commentPlugins ) {
+            for (WeblogEntryCommentPlugin plugin : commentPlugins) {
                 if(comment.getPlugins() != null &&
                         comment.getPlugins().contains(plugin.getId())) {
                     log.debug("Invoking comment plugin "+plugin.getId());
@@ -158,24 +153,24 @@ public class PluginManagerImpl implement
         if (pluginStr != null) {
             String[] plugins = StringUtils.stripAll(
                     StringUtils.split(pluginStr, ",") );
-            for (int i=0; i<plugins.length; i++) {
+            for (String plugin : plugins) {
                 if (log.isDebugEnabled()) {
-                    log.debug("try " + plugins[i]);
+                    log.debug("try " + plugin);
                 }
                 try {
-                    Class pluginClass = Class.forName(plugins[i]);
+                    Class pluginClass = Class.forName(plugin);
                     if (isPagePlugin(pluginClass)) {
-                        WeblogEntryPlugin plugin = (WeblogEntryPlugin)pluginClass.newInstance();
-                        mPagePlugins.put(plugin.getName(), pluginClass);
+                        WeblogEntryPlugin weblogEntryPlugin = (WeblogEntryPlugin)pluginClass.newInstance();
+                        mPagePlugins.put(weblogEntryPlugin.getName(), pluginClass);
                     } else {
                         log.warn(pluginClass + " is not a PagePlugin");
                     }
                 } catch (ClassNotFoundException e) {
-                    log.error("ClassNotFoundException for " + plugins[i]);
+                    log.error("ClassNotFoundException for " + plugin);
                 } catch (InstantiationException e) {
-                    log.error("InstantiationException for " + plugins[i]);
+                    log.error("InstantiationException for " + plugin);
                 } catch (IllegalAccessException e) {
-                    log.error("IllegalAccessException for " + plugins[i]);
+                    log.error("IllegalAccessException for " + plugin);
                 }
             }
         }
@@ -222,9 +217,11 @@ public class PluginManagerImpl implement
     
     private static boolean isPagePlugin(Class pluginClass) {
         Class[] interfaces = pluginClass.getInterfaces();
-        for (int i=0; i<interfaces.length; i++) {
-            if (interfaces[i].equals(WeblogEntryPlugin.class)) {
-                return true;
+        if (interfaces != null) {
+            for (Class clazz : interfaces) {
+                if (clazz.equals(WeblogEntryPlugin.class)) {
+                    return true;
+                }
             }
         }
         return false;

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/comment/LinkMarkupPlugin.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/comment/LinkMarkupPlugin.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/comment/LinkMarkupPlugin.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/comment/LinkMarkupPlugin.java Sun Apr 20 13:38:51 2014
@@ -36,7 +36,7 @@ import org.apache.roller.weblogger.util.
 public class LinkMarkupPlugin implements WeblogEntryCommentPlugin {
     private static final Log LOG = LogFactory.getLog(LinkMarkupPlugin.class);
 
-    private static final Pattern pattern = Pattern.compile(
+    private static final Pattern PATTERN = Pattern.compile(
             "http[s]?://[^/][\\S]+", Pattern.CASE_INSENSITIVE);  
     
     public LinkMarkupPlugin() {
@@ -77,7 +77,7 @@ public class LinkMarkupPlugin implements
         
         if (text != null) {
             Matcher matcher;
-            matcher = pattern.matcher(text);
+            matcher = PATTERN.matcher(text);
 
             int start = 0;
             int end = text.length();
@@ -112,9 +112,6 @@ public class LinkMarkupPlugin implements
                 }
             }
         }
-        else {
-            result.append(text);    
-        }
 
         return result.toString();
     }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/AcronymsPlugin.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/AcronymsPlugin.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/AcronymsPlugin.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/AcronymsPlugin.java Sun Apr 20 13:38:51 2014
@@ -18,11 +18,10 @@
 
 package org.apache.roller.weblogger.business.plugins.entry;
 
-import java.util.Iterator;
 import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
@@ -66,7 +65,7 @@ public class AcronymsPlugin implements W
     
     
     public String getDescription() {
-        return StringEscapeUtils.escapeJavaScript(description);
+        return StringEscapeUtils.escapeEcmaScript(description);
     }
     
     
@@ -74,8 +73,7 @@ public class AcronymsPlugin implements W
     
     
     public String render(WeblogEntry entry, String str) {
-        String text = str;
-        
+
         if (LOG.isDebugEnabled()) {
             LOG.debug("render(entry = "+entry.getId()+")");
         }
@@ -86,7 +84,7 @@ public class AcronymsPlugin implements W
         Properties acronyms = loadAcronyms(entry.getWebsite());
         LOG.debug("acronyms.size()=" + acronyms.size());
         if (acronyms.size() == 0) {
-            return text;
+            return str;
         }
         
         /*
@@ -95,8 +93,8 @@ public class AcronymsPlugin implements W
         Pattern[] acronymPatterns = new Pattern[acronyms.size()];
         String[] acronymTags = new String[acronyms.size()];
         int count = 0;
-        for (Iterator iter = acronyms.keySet().iterator(); iter.hasNext();) {
-            String acronym = (String) iter.next();
+        for (Object acrObj : acronyms.keySet()) {
+            String acronym = (String) acrObj;
             acronymPatterns[count] = Pattern.compile("\\b" + acronym + "\\b");
             LOG.debug("match '" + acronym + "'");
             acronymTags[count] =
@@ -109,11 +107,11 @@ public class AcronymsPlugin implements W
         }
         
         // if there are none, no work to do
-        if (acronymPatterns == null || acronymPatterns.length == 0) {
-            return text;
+        if (acronymPatterns.length == 0) {
+            return str;
         }
         
-        return matchAcronyms(text, acronymPatterns, acronymTags);
+        return matchAcronyms(str, acronymPatterns, acronymTags);
     }
     
     
@@ -121,7 +119,6 @@ public class AcronymsPlugin implements W
      * Look for any _acronyms Page and parse it into Properties.
      * @param website
      * @return
-     * @throws WebloggerException
      */
     private Properties loadAcronyms(Weblog website) {
         Properties acronyms = new Properties();
@@ -145,7 +142,8 @@ public class AcronymsPlugin implements W
      * acronyms in the entry text with acronym html-tags.
      *
      * @param text entry text
-     * @param acronyms user provided set of acronyms
+     * @param acronymPatterns user provided set of acronyms
+     * @param acronymTags
      * @return entry text with acronym explanations
      */
     private String matchAcronyms(String text, Pattern[] acronymPatterns, String[] acronymTags) {
@@ -153,7 +151,7 @@ public class AcronymsPlugin implements W
             LOG.debug("matchAcronyms("+text+")");
         }
         
-        Matcher matcher = null;
+        Matcher matcher;
         for (int i=0; i<acronymPatterns.length; i++) {
             matcher = acronymPatterns[i].matcher(text);
             text = matcher.replaceAll(acronymTags[i]);
@@ -174,8 +172,9 @@ public class AcronymsPlugin implements W
         if (LOG.isDebugEnabled()) {
             LOG.debug("parsing _acronyms template: \n'"+rawAcronyms+"'");
         }
-        
-        String regex = "\n"; // end of line
+
+        // split by end of line
+        String regex = "\n";
         String[] lines = rawAcronyms.split(regex);
         
         if (lines != null) {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin.java Sun Apr 20 13:38:51 2014
@@ -19,16 +19,13 @@
 package org.apache.roller.weblogger.business.plugins.entry;
 
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.regex.PatternSyntaxException;
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
-import org.apache.roller.weblogger.business.BookmarkManager;
-import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.pojos.WeblogBookmark;
 import org.apache.roller.weblogger.pojos.WeblogBookmarkFolder;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
@@ -59,7 +56,7 @@ public class BookmarkPlugin implements W
     
     
     public String getDescription() {
-        return StringEscapeUtils.escapeJavaScript(description);
+        return StringEscapeUtils.escapeEcmaScript(description);
     }
     
     
@@ -67,50 +64,28 @@ public class BookmarkPlugin implements W
     
     
     public String render(WeblogEntry entry, String str) {
-        String text = str;
-        try {
-            BookmarkManager bMgr = WebloggerFactory.getWeblogger().getBookmarkManager();
-            WeblogBookmarkFolder rootFolder = bMgr.getRootFolder(entry.getWebsite());
-            text = matchBookmarks(text, rootFolder);
-            text = lookInFolders(text, rootFolder.getFolders());
-        } catch (WebloggerException e) {
-            // nothing much I can do, go with default "Weblog" value
-            // could be WebloggerException or NullPointerException
-            mLogger.warn(e);
-        }
-        return text;
+        return lookInFolders(str, entry.getWebsite().getBookmarkFolders());
     }
     
     
     /**
-     * Recursively travel down Folder tree, attempting
-     * to match up Bookmarks in each Folder.
+     * Travel given collection of folders, attempting to match up Bookmarks in each one.
      *
-     * @param text
-     * @param folders
-     * @return
+     * @param text blog entry text
+     * @param folders list of bookmark folders to match against
+     * @return text with hyperlinks to blogroll items added
      */
-    private String lookInFolders(String text, Collection folders) {
-        
-        Iterator it = folders.iterator();
-        while (it.hasNext()) {
-            WeblogBookmarkFolder folder = (WeblogBookmarkFolder)it.next();
+    private String lookInFolders(String text, Collection<WeblogBookmarkFolder> folders) {
+        for (WeblogBookmarkFolder folder: folders) {
             text = matchBookmarks(text, folder);
-            
-            if (!folder.getFolders().isEmpty()) {
-                lookInFolders(text, folder.getFolders());
-            }
         }
-        
         return text;
     }
     
     
-    private String matchBookmarks(String text,WeblogBookmarkFolder folder) {
-        Iterator bookmarks = folder.getBookmarks().iterator();
+    private String matchBookmarks(String text, WeblogBookmarkFolder folder) {
         String workingText = text;
-        while (bookmarks.hasNext()) {
-            WeblogBookmark bookmark = (WeblogBookmark)bookmarks.next();
+        for (WeblogBookmark bookmark : folder.getBookmarks()) {
             String bkDescription = bookmark.getDescription();
             if (bkDescription == null) {
                 bkDescription = "";
@@ -131,19 +106,18 @@ public class BookmarkPlugin implements W
                 StringBuffer textBuf = new StringBuffer(workingText.length());
                 int inLink = 0;
                 while (m.find()) {
+                    // if m.group(1) is null, self-closed anchor tag <a  ... /> so ignore
                     if (m.group(1) != null) {
-                        // self-closed anchor tag <a  ... /> -- ignore
-                    } else if (m.group(2) != null) {
-                        // matched opening anchor tag <a ...>
-                        inLink++;
-                    } else if (m.group(3) != null) {
-                        // closing anchor tag </a>, but ignore nonmatching ones
-                        if (inLink > 0) {
-                            inLink--;
-                        }
-                    } else if (m.group(4) != null) {
-                        // matched the bookmark -- replace, but only if not within a link tag.
-                        if (inLink == 0) {
+                        if (m.group(2) != null) {
+                            // matched opening anchor tag <a ...>
+                            inLink++;
+                        } else if (m.group(3) != null) {
+                            // closing anchor tag </a>, but ignore nonmatching ones
+                            if (inLink > 0) {
+                                inLink--;
+                            }
+                        } else if (m.group(4) != null && inLink == 0) {
+                            // matched the bookmark -- replace, but only if not within a link tag.
                             m.appendReplacement(textBuf, bookmarkLink);
                         }
                     }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/ObfuscateEmailPlugin.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/ObfuscateEmailPlugin.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/ObfuscateEmailPlugin.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/ObfuscateEmailPlugin.java Sun Apr 20 13:38:51 2014
@@ -18,7 +18,7 @@
 
 package org.apache.roller.weblogger.business.plugins.entry;
 
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
@@ -51,7 +51,7 @@ public class ObfuscateEmailPlugin implem
     
     
     public String getDescription() {
-        return StringEscapeUtils.escapeJavaScript(description);
+        return StringEscapeUtils.escapeEcmaScript(description);
     }
     
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/SearchPluginBase.java Sun Apr 20 13:38:51 2014
@@ -69,12 +69,14 @@ public abstract class SearchPluginBase {
     public String render(WeblogEntry entry, String str) {
         Pattern pattern = getPattern();
         Matcher m = pattern.matcher(str);
-        StringBuffer result = new StringBuffer(str.length() + 128);   // rough guess at a reasonable length
+        // rough guess at a reasonable length
+        StringBuffer result = new StringBuffer(str.length() + 128);
         Object[] args = new Object[]{"", "", null, null};
         while (m.find()) {
             // parse out the parts of the match
             String type = m.group(1);
-            boolean feelinLucky = type.equals("!");   // are ya feelin lucky? are ya punk?
+            // are ya feelin lucky? are ya punk?
+            boolean feelinLucky = type.equals("!");
             String linkText = m.group(2);
             String searchText = m.group(3);
             if (searchText == null || searchText.length() == 0) {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/SmileysPlugin.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/SmileysPlugin.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/SmileysPlugin.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/SmileysPlugin.java Sun Apr 20 13:38:51 2014
@@ -22,7 +22,7 @@ import java.util.Enumeration;
 import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-import org.apache.commons.lang.StringEscapeUtils;
+import org.apache.commons.lang3.StringEscapeUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
@@ -36,8 +36,9 @@ import org.apache.roller.weblogger.pojos
 public class SmileysPlugin implements WeblogEntryPlugin {
     
     private static Log log = LogFactory.getLog(SmileysPlugin.class);
-    
-    public static Pattern[] smileyPatterns = new Pattern[0]; // public for tests
+
+    // public for tests
+    public static Pattern[] smileyPatterns = new Pattern[0];
     static String[] imageTags = new String[0];
     private static Properties smileyDefs = new Properties();
     
@@ -66,7 +67,7 @@ public class SmileysPlugin implements We
     
     
     public String getDescription() {
-        return StringEscapeUtils.escapeJavaScript(description);
+        return StringEscapeUtils.escapeEcmaScript(description);
     }
     
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/TopicTagPlugin.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/TopicTagPlugin.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/TopicTagPlugin.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/TopicTagPlugin.java Sun Apr 20 13:38:51 2014
@@ -33,7 +33,6 @@ import java.net.URLEncoder;
 import java.text.FieldPosition;
 import java.text.MessageFormat;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
@@ -301,31 +300,26 @@ public class TopicTagPlugin implements W
      * If ignoreBookmarks property is set, an empty map is returned.
      * @return map of the user's bookmarks (type BookmarkData), keyed by name (type String).
      */
-    protected Map buildBookmarkMap(Weblog website) throws WebloggerException
+    protected Map<String, WeblogBookmark> buildBookmarkMap(Weblog website) throws WebloggerException
     {
-        Map bookmarkMap = new HashMap();
+        Map<String, WeblogBookmark> bookmarkMap = new HashMap<String, WeblogBookmark>();
         if (WebloggerConfig.getBooleanProperty("plugins.topictag.ignoreBookmarks")) {
             return bookmarkMap;
         }
-        if (website == null)
-        {
+        if (website == null) {
             LOG.debug("Init called without website.  Skipping bookmark initialization.");
         }
-        else
-        {
+        else {
             BookmarkManager bMgr = WebloggerFactory.getWeblogger().getBookmarkManager();
-            List bookmarks = bMgr.getBookmarks(bMgr.getRootFolder(website), true);
+            List<WeblogBookmark> bookmarks = bMgr.getBookmarks(bMgr.getDefaultFolder(website));
 
-            for (Iterator i = bookmarks.iterator(); i.hasNext();)
-            {
-                WeblogBookmark b = (WeblogBookmark) i.next();
+            for (WeblogBookmark b : bookmarks) {
                 bookmarkMap.put(b.getName(), b);
             }
         }
         return bookmarkMap;
     }
 
-
     // Sets up properties.  For better and worse, doesn't use reflection
     private void initializeProperties()
     {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/RefererManager.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/RefererManager.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/RefererManager.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/RefererManager.java Sun Apr 20 13:38:51 2014
@@ -20,6 +20,7 @@ package org.apache.roller.weblogger.busi
 
 import java.util.List;
 import org.apache.roller.weblogger.WebloggerException;
+import org.apache.roller.weblogger.pojos.StatCount;
 import org.apache.roller.weblogger.pojos.WeblogReferrer;
 import org.apache.roller.weblogger.pojos.Weblog;
 
@@ -56,35 +57,35 @@ public interface RefererManager {    
     /**
      * Get all referers for specified weblog.
      * @param weblog
-     * @return List of type RefererData
+     * @return List of type WeblogReferrer
      */
-    List getReferers(Weblog weblog) throws WebloggerException;
+    List<WeblogReferrer> getReferers(Weblog weblog) throws WebloggerException;
     
     /**
-     * Get all referers for specified user that were made today.
-     * @param userName Name of user.
-     * @return List of type RefererData
+     * Get all referers for specified website that were made today.
+     * @param weblog
+     * @return List of type WeblogReferrer
      */
-    List getTodaysReferers(Weblog website) throws WebloggerException;
+    List<WeblogReferrer> getTodaysReferers(Weblog weblog) throws WebloggerException;
     
     /**
      * Get referers for a specified date.
-     * @param userName Name of user.
+     * @param weblog
      * @param date YYYYMMDD format of day's date.
-     * @return List of type RefererData.
+     * @return List of type WeblogReferrer
      * @throws WebloggerException
      */
-    List getReferersToDate(Weblog website, String date)
+    List<WeblogReferrer> getReferersToDate(Weblog weblog, String date)
         throws WebloggerException;    
         
     /**
      * Returns hot weblogs as StatCount objects, in descending order by today's hits.
      * @param sinceDays Restrict to last X days (or -1 for all)
      * @param offset    Offset into results (for paging)
-     * @param len       Maximum number of results to return (for paging)
+     * @param length       Maximum number of results to return (for paging)
      * @return List of StatCount objects.
      */
-    List getHotWeblogs(int sinceDays, int offset, int length)
+    List<StatCount> getHotWeblogs(int sinceDays, int offset, int length)
         throws WebloggerException; 
 
     /**
@@ -93,7 +94,7 @@ public interface RefererManager {    
      * @return List of RefererData objects.
      * @throws WebloggerException
      */
-    List getReferersToEntry(String entryid) throws WebloggerException;
+    List<WeblogReferrer> getReferersToEntry(String entryid) throws WebloggerException;
     
     /** 
      * Get user's day hits 

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/ReferrerProcessingJob.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/ReferrerProcessingJob.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/ReferrerProcessingJob.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/ReferrerProcessingJob.java Sun Apr 20 13:38:51 2014
@@ -40,7 +40,7 @@ public class ReferrerProcessingJob imple
     
     private static Log mLogger = LogFactory.getLog(ReferrerProcessingJob.class);
     
-    Map inputs = null;
+    Map<String, Object> inputs = null;
     IncomingReferrer referrer = null;
     
     public ReferrerProcessingJob() {}
@@ -79,7 +79,7 @@ public class ReferrerProcessingJob imple
     /**
      * Set input.
      */
-    public void input(Map input) {
+    public void input(Map<String, Object> input) {
         this.inputs = input;
         
         // we are looking for the "referrer" key
@@ -94,7 +94,7 @@ public class ReferrerProcessingJob imple
     /**
      * Get output.
      */
-    public Map output() {
+    public Map<String, Object> output() {
         
         return null;
     }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/ReferrerQueueManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/ReferrerQueueManagerImpl.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/ReferrerQueueManagerImpl.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/referrers/ReferrerQueueManagerImpl.java Sun Apr 20 13:38:51 2014
@@ -21,10 +21,10 @@ package org.apache.roller.weblogger.busi
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.Weblogger;
 import org.apache.roller.weblogger.business.runnable.ContinuousWorkerThread;
@@ -61,37 +61,32 @@ public class ReferrerQueueManagerImpl im
     private final Weblogger roller;
     
     private boolean asyncMode = false;
-    private int numWorkers = 1;
-    private int sleepTime = 10000;
-    private List workers = null;
-    private List referrerQueue = null;
+    private List<WorkerThread> workers = null;
+    private List<IncomingReferrer> referrerQueue = null;
     private int referrerCount = 0;
     private int maxAsyncQueueSize = 0;
 
     // private because we are a singleton
     @com.google.inject.Inject
     protected ReferrerQueueManagerImpl(Weblogger roller) {
-        
         mLogger.info("Instantiating Referrer Queue Manager");
-        
         this.roller = roller;
+        int sleepTime = 10000;
+        int numWorkers = 1;
 
         // lookup config options
         this.asyncMode = WebloggerConfig.getBooleanProperty("referrers.asyncProcessing.enabled");
-        
         mLogger.info("Asynchronous referrer processing = "+this.asyncMode);
-        
+
         if(this.asyncMode) {
-            
-            
             String num = WebloggerConfig.getProperty("referrers.queue.numWorkers");
             String sleep = WebloggerConfig.getProperty("referrers.queue.sleepTime");
             
             try {
-                this.numWorkers = Integer.parseInt(num);
+                numWorkers = Integer.parseInt(num);
                 
-                if(numWorkers < 1) {
-                    this.numWorkers = 1;
+                if (numWorkers < 1) {
+                    numWorkers = 1;
                 }
                 
             } catch(NumberFormatException nfe) {
@@ -100,21 +95,21 @@ public class ReferrerQueueManagerImpl im
             
             try {
                 // multiply by 1000 because we expect input in seconds
-                this.sleepTime = Integer.parseInt(sleep) * 1000;
+                sleepTime = Integer.parseInt(sleep) * RollerConstants.SEC_IN_MS;
             } catch(NumberFormatException nfe) {
                 mLogger.warn("Invalid sleep time ["+sleep+"], using default");
             }
             
             // create the processing queue
-            this.referrerQueue = Collections.synchronizedList(new ArrayList());
+            this.referrerQueue = Collections.synchronizedList(new ArrayList<IncomingReferrer>());
             
             // start up workers
-            this.workers = new ArrayList();
-            ContinuousWorkerThread worker = null;
-            QueuedReferrerProcessingJob job = null;
-            for(int i=0; i < this.numWorkers; i++) {
+            this.workers = new ArrayList<WorkerThread>();
+            ContinuousWorkerThread worker;
+            QueuedReferrerProcessingJob job;
+            for (int i = 0; i < numWorkers; i++) {
                 job = new QueuedReferrerProcessingJob();
-                worker = new ContinuousWorkerThread("ReferrerWorker"+i, job, this.sleepTime);
+                worker = new ContinuousWorkerThread("ReferrerWorker" + i, job, sleepTime);
                 workers.add(worker);
                 worker.start();
             }
@@ -142,7 +137,7 @@ public class ReferrerQueueManagerImpl im
             ReferrerProcessingJob job = new ReferrerProcessingJob();
             
             // setup input
-            HashMap inputs = new HashMap();
+            HashMap<String, Object> inputs = new HashMap<String, Object>();
             inputs.put("referrer", referrer);
             job.input(inputs);
             
@@ -182,7 +177,7 @@ public class ReferrerQueueManagerImpl im
     public synchronized IncomingReferrer dequeue() {
         
         if(!this.referrerQueue.isEmpty()) {
-            return (IncomingReferrer) this.referrerQueue.remove(0);
+            return this.referrerQueue.remove(0);
         }
         
         return null;
@@ -201,10 +196,7 @@ public class ReferrerQueueManagerImpl im
                 mLogger.info("Max Async Referrer queue size: " + maxAsyncQueueSize);
             }
             // kill all of our threads
-            WorkerThread worker = null;
-            Iterator it = this.workers.iterator();
-            while(it.hasNext()) {
-                worker = (WorkerThread) it.next();
+            for (WorkerThread worker : workers) {
                 worker.interrupt();
             }
         }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ContinuousWorkerThread.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ContinuousWorkerThread.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ContinuousWorkerThread.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ContinuousWorkerThread.java Sun Apr 20 13:38:51 2014
@@ -26,37 +26,28 @@ import org.apache.commons.logging.LogFac
  * A worker that performs a given job continuously.
  */
 public class ContinuousWorkerThread extends WorkerThread {
-    
     private static Log mLogger = LogFactory.getLog(ContinuousWorkerThread.class);
-    
-    // default sleep time is 10 seconds
-    long sleepTime = 10000;
-    
-    
+    private static final int DEFAULT_SLEEP_IN_MS = 10000;
+    long sleepTime = DEFAULT_SLEEP_IN_MS;
+
     public ContinuousWorkerThread(String id) {
         super(id);
     }
-    
-    
+
     public ContinuousWorkerThread(String id, long sleep) {
         super(id);
-        
         this.sleepTime = sleep;
     }
-    
-    
+
     public ContinuousWorkerThread(String id, Job job) {
         super(id, job);
     }
-    
-    
+
     public ContinuousWorkerThread(String id, Job job, long sleep) {
         super(id, job);
-        
         this.sleepTime = sleep;
     }
-    
-    
+
     /**
      * Thread execution.
      *
@@ -77,10 +68,10 @@ public class ContinuousWorkerThread exte
             
             // job is done, lets sleep it off for a bit
             try {
-                mLogger.debug(this.id+" SLEEPING for "+this.sleepTime+" milliseconds ...");
+                mLogger.debug(this.id + " SLEEPING for " + this.sleepTime + " milliseconds ...");
                 this.sleep(this.sleepTime);
             } catch (InterruptedException e) {
-                mLogger.info(this.id+" INTERRUPT: "+e.getMessage());
+                mLogger.info(this.id + " INTERRUPT: " + e.getMessage());
                 break;
             }
         }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/HitCountProcessingJob.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/HitCountProcessingJob.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/HitCountProcessingJob.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/HitCountProcessingJob.java Sun Apr 20 13:38:51 2014
@@ -19,15 +19,14 @@
 package org.apache.roller.weblogger.business.runnable;
 
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.HitCountQueue;
 import org.apache.roller.weblogger.business.WebloggerFactory;
-import org.apache.roller.weblogger.business.UserManager;
 import org.apache.roller.weblogger.business.WeblogEntryManager;
 import org.apache.roller.weblogger.business.WeblogManager;
 import org.apache.roller.weblogger.pojos.Weblog;
@@ -53,25 +52,21 @@ public class HitCountProcessingJob imple
      */
     public void execute() {
         
-        UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
         WeblogManager wmgr = WebloggerFactory.getWeblogger().getWeblogManager();
         WeblogEntryManager emgr = WebloggerFactory.getWeblogger().getWeblogEntryManager();
         
         HitCountQueue hitCounter = HitCountQueue.getInstance();
         
         // first get the current set of hits
-        List currentHits = hitCounter.getHits();
+        List<String> currentHits = hitCounter.getHits();
         
         // now reset the queued hits
         hitCounter.resetHits();
         
         // tally the counts, grouped by weblog handle
-        Map hitsTally = new HashMap();
-        String weblogHandle = null;
-        for(int i=0; i < currentHits.size(); i++) {
-            weblogHandle = (String) currentHits.get(i);
-            
-            Long count = (Long) hitsTally.get(weblogHandle);
+        Map<String, Long> hitsTally = new HashMap<String, Long>();
+        for (String weblogHandle : currentHits) {
+            Long count = hitsTally.get(weblogHandle);
             if(count == null) {
                 count = 1L;
             } else {
@@ -79,31 +74,27 @@ public class HitCountProcessingJob imple
             }
             hitsTally.put(weblogHandle, count);
         }
-        
+
         // iterate over the tallied hits and store them in the db
         try {
             long startTime = System.currentTimeMillis();
             
-            Weblog weblog = null;
-            String key = null;
-            Iterator it = hitsTally.keySet().iterator();
-            while(it.hasNext()) {
-                key = (String) it.next();
-                
+            Weblog weblog;
+            for (Map.Entry<String, Long> entry : hitsTally.entrySet()) {
                 try {
-                    weblog = wmgr.getWeblogByHandle(key);
-                    emgr.incrementHitCount(weblog, ((Long)hitsTally.get(key)).intValue());
+                    weblog = wmgr.getWeblogByHandle(entry.getKey());
+                    emgr.incrementHitCount(weblog, entry.getValue().intValue());
                 } catch (WebloggerException ex) {
                     log.error(ex);
                 }
             }
-            
+
             // flush the results to the db
             WebloggerFactory.getWeblogger().flush();
             
             long endTime = System.currentTimeMillis();
             
-            log.debug("Completed: "+ (endTime-startTime)/1000 + " secs");
+            log.debug("Completed: "+ (endTime-startTime)/ RollerConstants.SEC_IN_MS + " secs");
             
         } catch (WebloggerException ex) {
             log.error("Error persisting updated hit counts", ex);
@@ -114,11 +105,11 @@ public class HitCountProcessingJob imple
     }
     
     
-    public void input(Map input) {
+    public void input(Map<String, Object> input) {
         // no-op
     }
     
-    public Map output() {
+    public Map<String, Object> output() {
         return null;
     }
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/Job.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/Job.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/Job.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/Job.java Sun Apr 20 13:38:51 2014
@@ -41,12 +41,12 @@ public interface Job {
     /**
      * Pass in input to be used for the job.
      */
-    void input(Map input);
+    void input(Map<String, Object> input);
     
     
     /**
      * Get any output from the job.
      */
-    Map output();
+    Map<String, Object> output();
     
 }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ResetHitCountsTask.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ResetHitCountsTask.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ResetHitCountsTask.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ResetHitCountsTask.java Sun Apr 20 13:38:51 2014
@@ -44,10 +44,10 @@ public class ResetHitCountsTask extends 
     private String startTimeDesc = "startOfDay";
     
     // interval at which the task is run, default is 1 day
-    private int interval = 1440;
+    private int interval = RollerTask.DEFAULT_INTERVAL_MINS;
     
     // lease time given to task lock, default is 30 minutes
-    private int leaseTime = 30;
+    private int leaseTime = RollerTaskWithLeasing.DEFAULT_LEASE_MINS;
     
     
     public String getClientId() {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/RollerTask.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/RollerTask.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/RollerTask.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/RollerTask.java Sun Apr 20 13:38:51 2014
@@ -34,6 +34,7 @@ import org.apache.roller.util.DateUtil;
  */
 public abstract class RollerTask implements Runnable {
     private String taskName = null;
+    protected static final int DEFAULT_INTERVAL_MINS = 1440;
 
     
     /**

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/RollerTaskWithLeasing.java Sun Apr 20 13:38:51 2014
@@ -30,7 +30,7 @@ import org.apache.roller.weblogger.busin
  */
 public abstract class RollerTaskWithLeasing extends RollerTask {
     private static Log log = LogFactory.getLog(RollerTaskWithLeasing.class);
-    
+    protected static final int DEFAULT_LEASE_MINS = 30;
     
     /**
      * Run the task.

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ScheduledEntriesTask.java Sun Apr 20 13:38:51 2014
@@ -19,7 +19,6 @@
 package org.apache.roller.weblogger.business.runnable;
 
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 import org.apache.commons.logging.Log;
@@ -29,6 +28,7 @@ import org.apache.roller.weblogger.busin
 import org.apache.roller.weblogger.business.WeblogEntryManager;
 import org.apache.roller.weblogger.business.search.IndexManager;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
+import org.apache.roller.weblogger.pojos.WeblogEntrySearchCriteria;
 import org.apache.roller.weblogger.util.cache.CacheManager;
 
 
@@ -53,7 +53,7 @@ public class ScheduledEntriesTask extend
     private int interval = 1;
     
     // lease time given to task lock, default is 30 minutes
-    private int leaseTime = 30;
+    private int leaseTime = RollerTaskWithLeasing.DEFAULT_LEASE_MINS;
     
 
     public String getClientId() {
@@ -138,48 +138,29 @@ public class ScheduledEntriesTask extend
             log.debug("looking up scheduled entries older than "+now);
             
             // get all published entries older than current time
-            List scheduledEntries = wMgr.getWeblogEntries(
-                    
-                    null,   // website
-                    null,   // user
-                    null,   // startDate
-                    now,    // endDate
-                    null,   // catName
-                    null,WeblogEntry.SCHEDULED, // status
-                    null,   // text
-                    null,   // sortBy
-                    null,   // sortOrder
-                    null,   // locale
-                    0, -1); // offset, length
-                    
+            WeblogEntrySearchCriteria wesc = new WeblogEntrySearchCriteria();
+            wesc.setEndDate(now);
+            wesc.setStatus(WeblogEntry.SCHEDULED);
+            List<WeblogEntry> scheduledEntries = wMgr.getWeblogEntries(wesc);
             log.debug("promoting "+scheduledEntries.size()+" entries to PUBLISHED state");
             
-            WeblogEntry entry = null;
-            Iterator it = scheduledEntries.iterator();
-            while(it.hasNext()) {
-                entry = (WeblogEntry) it.next();
-                
-                // update status to PUBLISHED and save
+            for (WeblogEntry entry : scheduledEntries) {
                 entry.setStatus(WeblogEntry.PUBLISHED);
                 wMgr.saveWeblogEntry(entry);
             }
-            
+
             // commit the changes
             WebloggerFactory.getWeblogger().flush();
             
             // take a second pass to trigger reindexing and cache invalidations
             // this is because we need the updated entries flushed first
-            it = scheduledEntries.iterator();
-            while(it.hasNext()) {
-                entry = (WeblogEntry) it.next();
-                
+            for (WeblogEntry entry : scheduledEntries) {
                 // trigger a cache invalidation
                 CacheManager.invalidate(entry);
-                
                 // trigger search index on entry
                 searchMgr.addEntryReIndexOperation(entry);
             }
-            
+
         } catch (WebloggerException e) {
             log.error("Error getting scheduled entries", e);
         } catch(Exception e) {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/TaskScheduler.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/TaskScheduler.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/TaskScheduler.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/TaskScheduler.java Sun Apr 20 13:38:51 2014
@@ -26,6 +26,7 @@ import java.util.concurrent.Executors;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.util.DateUtil;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.pojos.TaskLock;
 
@@ -45,9 +46,6 @@ import org.apache.roller.weblogger.pojos
 public class TaskScheduler implements Runnable {
     
     private static Log log = LogFactory.getLog(TaskScheduler.class);
-    
-    private static final long ONE_MINUTE_MS = (60 * 1000);
-    
     private final ExecutorService pool;
     private final List<RollerTask> tasks;
     
@@ -132,14 +130,13 @@ public class TaskScheduler implements Ru
         
         ThreadManager tmgr = WebloggerFactory.getWeblogger().getThreadManager();
         
-        for( RollerTask task : tasks ) {
+        for (RollerTask task : tasks) {
             try {
                 // get tasklock for the task
                 TaskLock tasklock = tmgr.getTaskLockByName(task.getName());
                 
                 // TODO: check if task is enabled, otherwise skip
-                if(tasklock == null) {
-                    log.debug("SKIPPING task : "+tasklock.getName());
+                if (tasklock == null) {
                     continue;
                 }
                 
@@ -151,14 +148,15 @@ public class TaskScheduler implements Ru
                 // if we missed the last scheduled run time then see when the
                 // most appropriate next run time should be and wait 'til then
                 boolean needToWait = false;
-                if(currentTime.getTime() > (nextRunTime.getTime() + ONE_MINUTE_MS)) {
+                if(currentTime.getTime() > (nextRunTime.getTime() + RollerConstants.MIN_IN_MS)) {
                     
                     log.debug("MISSED last run, checking if waiting is necessary");
-                    if("startOfDay".equals(task.getStartTimeDesc())) {
+                    // add delays if task is non-immediate
+                    if ("startOfDay".equals(task.getStartTimeDesc())) {
                         // for daily tasks we only run during the first 
                         // couple minutes of the day
                         Date startOfDay = DateUtil.getStartOfDay(currentTime);
-                        if(currentTime.getTime() > startOfDay.getTime() + (2 * ONE_MINUTE_MS)) {
+                        if(currentTime.getTime() > startOfDay.getTime() + (2 * RollerConstants.MIN_IN_MS)) {
                             needToWait = true;
                             log.debug("WAITING for next reasonable run time");
                         }
@@ -166,12 +164,10 @@ public class TaskScheduler implements Ru
                         // for hourly tasks we only run during the first
                         // couple minutes of the hour
                         Date startOfHour = DateUtil.getStartOfHour(currentTime);
-                        if(currentTime.getTime() > startOfHour.getTime() + (2 * ONE_MINUTE_MS)) {
+                        if(currentTime.getTime() > startOfHour.getTime() + (2 * RollerConstants.MIN_IN_MS)) {
                             needToWait = true;
                             log.debug("WAITING for next reasonable run time");
                         }
-                    } else {
-                        // for immediate tasks we just go ahead and run
                     }
                 }
                 

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ThreadManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ThreadManagerImpl.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ThreadManagerImpl.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/ThreadManagerImpl.java Sun Apr 20 13:38:51 2014
@@ -24,9 +24,10 @@ import java.util.List;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.InitializationException;
 import org.apache.roller.weblogger.config.WebloggerConfig;
@@ -106,7 +107,7 @@ public abstract class ThreadManagerImpl 
         TaskScheduler scheduler = new TaskScheduler(webloggerTasks);
         
         // start scheduler thread, but only if it's not already running
-        if (schedulerThread == null && scheduler != null) {
+        if (schedulerThread == null) {
             LOG.debug("Starting scheduler thread");
             schedulerThread = new Thread(scheduler, "Roller Weblogger Task Scheduler");
             // set thread priority between MAX and NORM so we get slightly preferential treatment
@@ -118,7 +119,7 @@ public abstract class ThreadManagerImpl 
     
     public void executeInBackground(Runnable runnable)
             throws InterruptedException {
-        Future task = serviceScheduler.submit(runnable);
+        serviceScheduler.submit(runnable);
     }
     
     
@@ -130,7 +131,7 @@ public abstract class ThreadManagerImpl 
         // thread, here we can add a little code here to loop until it realizes 
         // the task is done
         while(!task.isDone()) {
-            Thread.sleep(500);
+            Thread.sleep(RollerConstants.HALF_SEC_IN_MS);
         }
     }
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/TurnoverReferersTask.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/TurnoverReferersTask.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/TurnoverReferersTask.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/runnable/TurnoverReferersTask.java Sun Apr 20 13:38:51 2014
@@ -43,10 +43,10 @@ public class TurnoverReferersTask extend
     private String startTimeDesc = "startOfDay";
     
     // interval at which the task is run, default is 1 day
-    private int interval = 1440;
+    private int interval = RollerTask.DEFAULT_INTERVAL_MINS;
     
     // lease time given to task lock, default is 30 minutes
-    private int leaseTime = 30;
+    private int leaseTime = RollerTaskWithLeasing.DEFAULT_LEASE_MINS;
 
     
     public String getClientId() {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/FieldConstants.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/FieldConstants.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/FieldConstants.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/FieldConstants.java Sun Apr 20 13:38:51 2014
@@ -43,9 +43,8 @@ public final class FieldConstants {
     public static final String C_EMAIL = "email";
     public static final String C_NAME = "name";
     public static final String CONSTANT = "constant";
-    public static final String CONSTANT_V = "v"; // must be lowercase, or match
-                                                 // the transform rules of
-                                                 // the analyzer
+    // CONSTANT_V must be lowercase or match transform rules of analyzer
+    public static final String CONSTANT_V = "v";
     public static final String WEBSITE_HANDLE = "handle";
     public static final String LOCALE = "locale";
 }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/IndexUtil.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/IndexUtil.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/IndexUtil.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/IndexUtil.java Sun Apr 20 13:38:51 2014
@@ -31,7 +31,7 @@ import org.apache.lucene.index.Term;
  * 
  * @author Mindaugas Idzelis (min@idzelis.com)
  */
-public class IndexUtil {
+public final class IndexUtil {
 
     private IndexUtil() {}
 

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/RebuildWebsiteIndexOperation.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/RebuildWebsiteIndexOperation.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/RebuildWebsiteIndexOperation.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/RebuildWebsiteIndexOperation.java Sun Apr 20 13:38:51 2014
@@ -20,13 +20,13 @@ package org.apache.roller.weblogger.busi
 
 import java.text.MessageFormat;
 import java.util.Date;
-import java.util.Iterator;
 import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WeblogEntryManager;
 import org.apache.roller.weblogger.business.Weblogger;
@@ -35,6 +35,7 @@ import org.apache.roller.weblogger.busin
 import org.apache.roller.weblogger.business.search.IndexUtil;
 import org.apache.roller.weblogger.pojos.Weblog;
 import org.apache.roller.weblogger.pojos.WeblogEntry;
+import org.apache.roller.weblogger.pojos.WeblogEntrySearchCriteria;
 
 /**
  * An index operation that rebuilds a given users index (or all indexes).
@@ -116,24 +117,18 @@ public class RebuildWebsiteIndexOperatio
                 // Add Doc
                 WeblogEntryManager weblogManager = roller
                         .getWeblogEntryManager();
-                List entries = weblogManager.getWeblogEntries(website, // website
-                        null, null, // startDate
-                        null, // endDate
-                        null, // catName
-                        null, WeblogEntry.PUBLISHED, // status
-                        null, // text
-                        null, // sortby (null means pubTime)
-                        null, null, 0, -1); // offset, length, locale
+                WeblogEntrySearchCriteria wesc = new WeblogEntrySearchCriteria();
+                wesc.setWeblog(website);
+                wesc.setStatus(WeblogEntry.PUBLISHED);
+                List<WeblogEntry> entries = weblogManager.getWeblogEntries(wesc);
 
                 mLogger.debug("Entries to index: " + entries.size());
 
-                for (Iterator wbItr = entries.iterator(); wbItr.hasNext();) {
-                    WeblogEntry entry = (WeblogEntry) wbItr.next();
+                for (WeblogEntry entry : entries) {
                     writer.addDocument(getDocument(entry));
                     mLogger.debug(MessageFormat.format(
                             "Indexed entry {0}: {1}",
-                            new Object[] { entry.getPubTime(),
-                                    entry.getAnchor() }));
+                            entry.getPubTime(), entry.getAnchor()));
                 }
 
                 // release the database connection
@@ -149,7 +144,7 @@ public class RebuildWebsiteIndexOperatio
         }
 
         Date end = new Date();
-        double length = (end.getTime() - start.getTime()) / (double) 1000;
+        double length = (end.getTime() - start.getTime()) / (double) RollerConstants.SEC_IN_MS;
 
         if (website == null) {
             mLogger.info("Completed rebuilding index for all users in '"

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/RemoveWebsiteIndexOperation.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/RemoveWebsiteIndexOperation.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/RemoveWebsiteIndexOperation.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/RemoveWebsiteIndexOperation.java Sun Apr 20 13:38:51 2014
@@ -25,6 +25,7 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.Term;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.Weblogger;
 import org.apache.roller.weblogger.business.search.FieldConstants;
@@ -105,7 +106,7 @@ public class RemoveWebsiteIndexOperation
         }
 
         Date end = new Date();
-        double length = (end.getTime() - start.getTime()) / (double) 1000;
+        double length = (end.getTime() - start.getTime()) / (double) RollerConstants.SEC_IN_MS;
 
         if (website != null) {
             mLogger.info("Completed deleting indices for website '"

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/search/operations/SearchOperation.java Sun Apr 20 13:38:51 2014
@@ -76,8 +76,6 @@ public class SearchOperation extends Rea
     private String locale;
     private String parseError;
 
-    private int nMax = 500; // Limit documents.
-
     // ~ Constructors
     // ===========================================================
 
@@ -103,8 +101,8 @@ public class SearchOperation extends Rea
      * @see java.lang.Runnable#run()
      */
     public void doRun() {
+        final int docLimit = 500;
         searchresults = null;
-
         searcher = null;
 
         try {
@@ -155,7 +153,7 @@ public class SearchOperation extends Rea
                 query = bQuery;
             }
 
-            searchresults = searcher.search(query, null/* Filter */, nMax,
+            searchresults = searcher.search(query, null/* Filter */, docLimit,
                     SORTER);
 
         } catch (IOException e) {
@@ -211,7 +209,7 @@ public class SearchOperation extends Rea
 
     /**
      * Gets the parses the error.
-     * 
+     *
      * @return the parses the error
      */
     public String getParseError() {

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/ClasspathDatabaseScriptProvider.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/ClasspathDatabaseScriptProvider.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/ClasspathDatabaseScriptProvider.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/ClasspathDatabaseScriptProvider.java Sun Apr 20 13:38:51 2014
@@ -19,6 +19,7 @@
 package org.apache.roller.weblogger.business.startup;
 
 import java.io.InputStream;
+import java.net.URL;
 
 /**
  * Reads dbscripts from the classpath.
@@ -33,4 +34,17 @@ public class ClasspathDatabaseScriptProv
         return this.getClass().getResourceAsStream(resourcePath);
     }
 
+    /**
+     * Gets the script url.
+     * 
+     * @param path
+     *            the path
+     * 
+     * @return the script url
+     */
+    public URL getScriptURL(String path) {
+        String resourcePath = "/dbscripts/" + path;
+        return ClasspathDatabaseScriptProvider.class.getResource(resourcePath);
+    }
+
 }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java Sun Apr 20 13:38:51 2014
@@ -258,7 +258,7 @@ public class DatabaseInstaller {
     }
 
     /**
-     * Upgrade database for Roller 4.0.0
+     * Upgrade database to Roller 4.0.0
      */
     private void upgradeTo400(Connection con, boolean runScripts) throws StartupException {
         
@@ -701,7 +701,7 @@ public class DatabaseInstaller {
     
     
     /**
-     * Upgrade database for Roller 4.1.0
+     * Upgrade database to Roller 5.0
      */
     private void upgradeTo500(Connection con, boolean runScripts) throws StartupException {
         
@@ -727,6 +727,9 @@ public class DatabaseInstaller {
         }        
     }
 
+    /**
+     * Upgrade database to Roller 5.1
+     */
 	private void upgradeTo510(Connection con, boolean runScripts) throws StartupException {
         
         // first we need to run upgrade scripts 
@@ -782,7 +785,6 @@ public class DatabaseInstaller {
      * Return true if named table exists in database.
      */
     private boolean tableExists(Connection con, String tableName) throws SQLException {
-        String[] types = {"TABLE"};
         ResultSet rs = con.getMetaData().getTables(null, null, "%", null);
         while (rs.next()) {
             if (tableName.equalsIgnoreCase(rs.getString("TABLE_NAME").toLowerCase())) {
@@ -814,10 +816,8 @@ public class DatabaseInstaller {
                 // however, if roller_properties is not empty then we at least
                 // we have someone upgrading from 1.2.x
                 rs = stmt.executeQuery("select count(*) from roller_properties");
-                if(rs.next()) {
-                    if(rs.getInt(1) > 0) {
-                        dbversion = 120;
-                    }
+                if (rs.next() && rs.getInt(1) > 0) {
+                    dbversion = 120;
                 }
             }
             
@@ -856,7 +856,7 @@ public class DatabaseInstaller {
             } else {
                 myversion = parsed;
             }
-        } catch(Exception e) {}  
+        } catch(Exception e) {}
         
         return myversion;
     }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/SQLScriptRunner.java Sun Apr 20 13:38:51 2014
@@ -18,7 +18,7 @@
 
 package org.apache.roller.weblogger.business.startup;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 
 import java.io.*;
 import java.sql.Connection;
@@ -49,8 +49,9 @@ public class SQLScriptRunner {
         String line;
         while ((line = in.readLine()) != null) {
             line = line.trim();
-            
-            if (!line.startsWith("--")) { // ignore lines starting with "--"    
+
+            // ignore lines starting with "--"
+            if (!line.startsWith("--")) {
                 
                 if (line.indexOf("--") > 0) {
                     // trim comment off end of line
@@ -67,7 +68,8 @@ public class SQLScriptRunner {
                     commands.add(cmd);
                     command = "";
                 } else if (StringUtils.isNotEmpty(command)) {
-                    command += " "; // still more command coming so add space
+                    // still more command coming so add space
+                    command += " ";
                 }
             } 
         }
@@ -149,4 +151,23 @@ public class SQLScriptRunner {
         messages.add(msg);
     }
     
+    
+    /**
+     * Gets the commands.
+     * 
+     * @return the commands
+     */
+    public List<String> getCommands() {
+        return commands;
+    }
+
+    /**
+     * Sets the commands.
+     * 
+     * @param commands
+     *            the new commands
+     */
+    public void setCommands(List<String> commands) {
+        this.commands = commands;
+    }
 }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/StartupException.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/StartupException.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/StartupException.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/StartupException.java Sun Apr 20 13:38:51 2014
@@ -33,12 +33,12 @@ public class StartupException extends We
     
     public StartupException(String msg) {
         super(msg);
-        this.startupLog = Collections.EMPTY_LIST;
+        this.startupLog = Collections.emptyList();
     }
     
     public StartupException(String msg, Throwable t) {
         super(msg, t);
-        this.startupLog = Collections.EMPTY_LIST;
+        this.startupLog = Collections.emptyList();
     }
     
     public StartupException(String msg, List<String> log) {
@@ -47,7 +47,7 @@ public class StartupException extends We
         if(log != null) {
             this.startupLog = log;
         } else {
-            this.startupLog = Collections.EMPTY_LIST;
+            this.startupLog = Collections.emptyList();
         }
     }
     
@@ -57,7 +57,7 @@ public class StartupException extends We
         if(log != null) {
             this.startupLog = log;
         } else {
-            this.startupLog = Collections.EMPTY_LIST;
+            this.startupLog = Collections.emptyList();
         }
     }
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/WebloggerStartup.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/WebloggerStartup.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/WebloggerStartup.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/startup/WebloggerStartup.java Sun Apr 20 13:38:51 2014
@@ -191,7 +191,7 @@ public final class WebloggerStartup {
             // if we are doing manual install then all that is needed is the
             // app handled database upgrade work, not the db scripts
             DatabaseInstaller dbInstaller = getDatabaseInstaller();
-            if(dbInstaller.isUpgradeRequired()) {
+            if (dbInstaller.isUpgradeRequired()) {
                 dbInstaller.upgradeDatabase(false);
             }
             
@@ -201,7 +201,7 @@ public final class WebloggerStartup {
             
             // we are in auto install mode, so see if there is any work to do
             DatabaseInstaller dbInstaller = getDatabaseInstaller();
-            if(!dbInstaller.isCreationRequired() && 
+            if (!dbInstaller.isCreationRequired() &&
                     !dbInstaller.isUpgradeRequired()) {
                 prepared = true;
             }

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedTheme.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedTheme.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedTheme.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedTheme.java Sun Apr 20 13:38:51 2014
@@ -30,7 +30,7 @@ import java.util.List;
  * A SharedTheme is a theme implementation which is designed to be shared by
  * multiple weblogs using a common set of resources.
  */
-public abstract class SharedTheme implements Theme, Serializable, Comparable {
+public abstract class SharedTheme implements Theme, Serializable, Comparable<SharedTheme> {
     
     protected String id = null;
     protected String name = null;
@@ -40,7 +40,7 @@ public abstract class SharedTheme implem
     protected Date lastModified = null;
     protected boolean enabled = false;
     
-    public abstract List getResources();
+    public abstract List<ThemeResource> getResources();
     
     public abstract ThemeResource getPreviewImage();
     
@@ -48,8 +48,7 @@ public abstract class SharedTheme implem
     /**
      * @see java.lang.Comparable#compareTo(java.lang.Object)
      */
-    public int compareTo(Object o) {
-        SharedTheme other = (SharedTheme) o;
+    public int compareTo(SharedTheme other) {
         return getName().compareTo(other.getName());
     }
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeFromDir.java Sun Apr 20 13:38:51 2014
@@ -18,7 +18,7 @@
 
 package org.apache.roller.weblogger.business.themes;
 
-import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -50,20 +50,17 @@ public class SharedThemeFromDir extends 
     private ThemeTemplate stylesheet = null;
 
     // we keep templates in a Map for faster lookups by name
-    // the Map contains ... (template name, ThemeTemplate)
-    private Map templatesByName = new HashMap();
+    private Map<String, ThemeTemplate> templatesByName = new HashMap<String, ThemeTemplate>();
 
     // we keep templates in a Map for faster lookups by link
-    // the Map contains ... (template link, List<tThemeTemplate>)
-    private Map templatesByLink = new HashMap();
+    private Map<String, ThemeTemplate> templatesByLink = new HashMap<String, ThemeTemplate>();
 
     // we keep templates in a Map for faster lookups by action
-    // the Map contains ... (template action, ThemeTemplate)
-    private Map templatesByAction = new HashMap();
+    private Map<String, ThemeTemplate> templatesByAction = new HashMap<String, ThemeTemplate>();
 
     // we keep resources in a Map for faster lookups by path
     // the Map contains ... (resource path, ThemeResource)
-    private Map resources = new HashMap();
+    private Map<String, ThemeResource> resources = new HashMap<String, ThemeResource>();
 
     public SharedThemeFromDir(String themeDirPath)
             throws ThemeInitializationException {
@@ -84,8 +81,8 @@ public class SharedThemeFromDir extends 
     /**
      * Get the collection of all templates associated with this Theme.
      */
-    public List getTemplates() {
-        return new ArrayList(this.templatesByName.values());
+    public List<ThemeTemplate> getTemplates() {
+        return new ArrayList<ThemeTemplate>(this.templatesByName.values());
     }
 
     /**
@@ -100,8 +97,7 @@ public class SharedThemeFromDir extends 
      * cannot be found.
      */
     public ThemeTemplate getDefaultTemplate() {
-        return (ThemeTemplate) this.templatesByAction
-                .get(ThemeTemplate.ACTION_WEBLOG);
+        return this.templatesByAction.get(ThemeTemplate.ACTION_WEBLOG);
     }
 
     /**
@@ -109,7 +105,7 @@ public class SharedThemeFromDir extends 
      * cannot be found.
      */
     public ThemeTemplate getTemplateByName(String name) {
-        return (ThemeTemplate) this.templatesByName.get(name);
+        return this.templatesByName.get(name);
     }
 
     /**
@@ -117,7 +113,7 @@ public class SharedThemeFromDir extends 
      * cannot be found.
      */
     public ThemeTemplate getTemplateByLink(String link) {
-        return (ThemeTemplate) this.templatesByLink.get(link);
+        return this.templatesByLink.get(link);
     }
 
     /**
@@ -125,7 +121,7 @@ public class SharedThemeFromDir extends 
      * cannot be found.
      */
     public ThemeTemplate getTemplateByAction(String action) {
-        return (ThemeTemplate) this.templatesByAction.get(action);
+        return this.templatesByAction.get(action);
     }
 
     /**
@@ -133,10 +129,10 @@ public class SharedThemeFromDir extends 
      * 
      * It is assured that the resources are returned sorted by pathname.
      */
-    public List getResources() {
+    public List<ThemeResource> getResources() {
 
+        List<ThemeResource> myResources = new ArrayList<ThemeResource>(this.resources.values());
         // make sure resources are sorted.
-        List myResources = new ArrayList(this.resources.values());
         Collections.sort(myResources);
 
         return myResources;
@@ -147,7 +143,7 @@ public class SharedThemeFromDir extends 
      * cannot be found.
      */
     public ThemeResource getResource(String path) {
-        return (ThemeResource) this.resources.get(path);
+        return this.resources.get(path);
     }
 
     public String toString() {
@@ -155,14 +151,12 @@ public class SharedThemeFromDir extends 
         sb.append(name);
         sb.append("\n");
 
-        Iterator it = this.templatesByName.values().iterator();
-        while (it.hasNext()) {
-            sb.append(it.next());
+        for (ThemeTemplate template : templatesByName.values()) {
+            sb.append(template);
             sb.append("\n");
         }
 
         return sb.toString();
-
     }
 
     /**
@@ -172,7 +166,7 @@ public class SharedThemeFromDir extends 
 
         log.debug("Parsing theme descriptor for " + this.themeDir);
 
-        ThemeMetadata themeMetadata = null;
+        ThemeMetadata themeMetadata;
         try {
             // lookup theme descriptor and parse it
             ThemeMetadataParser parser = new ThemeMetadataParser();
@@ -260,7 +254,7 @@ public class SharedThemeFromDir extends 
                 // here we set content and template language from standard
                 // template code assuming it is the default
                 SharedThemeTemplate theme_template = new SharedThemeTemplate(
-                        this, themeMetadata.getId() + ":"
+                        themeMetadata.getId() + ":"
                                 + stylesheetTmpl.getName(),
                         WeblogTemplate.ACTION_CUSTOM, stylesheetTmpl.getName(),
                         stylesheetTmpl.getDescription(), contents,
@@ -294,11 +288,7 @@ public class SharedThemeFromDir extends 
         }
 
         // go through static resources and add them to the theme
-        String resourcePath = null;
-        Iterator resourcesIter = themeMetadata.getResources().iterator();
-        while (resourcesIter.hasNext()) {
-            resourcePath = (String) resourcesIter.next();
-
+        for (String resourcePath : themeMetadata.getResources()) {
             // construct ThemeResource object from resource
             File resourceFile = new File(this.themeDir + File.separator
                     + resourcePath);
@@ -324,11 +314,8 @@ public class SharedThemeFromDir extends 
         }
 
         // go through templates and read in contents to a ThemeTemplate
-        SharedThemeTemplate theme_template = null;
-        ThemeMetadataTemplate templateMetadata = null;
-        Iterator templatesIter = themeMetadata.getTemplates().iterator();
-        while (templatesIter.hasNext()) {
-            templateMetadata = (ThemeMetadataTemplate) templatesIter.next();
+        SharedThemeTemplate theme_template;
+        for (ThemeMetadataTemplate templateMetadata : themeMetadata.getTemplates()) {
 
             // getting the template codes for available types
             ThemeMetadataTemplateCode standardTemplateCode = templateMetadata
@@ -367,7 +354,7 @@ public class SharedThemeFromDir extends 
             }
 
             // construct ThemeTemplate representing this file
-            theme_template = new SharedThemeTemplate(this,
+            theme_template = new SharedThemeTemplate(
                     themeMetadata.getId() + ":" + templateMetadata.getName(),
                     templateMetadata.getAction(), templateMetadata.getName(),
                     templateMetadata.getDescription(), contents,
@@ -408,7 +395,7 @@ public class SharedThemeFromDir extends 
             return null;
         }
 
-        char[] chars = null;
+        char[] chars;
         int length;
         try {
             chars = new char[(int) templateFile.length()];

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeResourceFromDir.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeResourceFromDir.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeResourceFromDir.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeResourceFromDir.java Sun Apr 20 13:38:51 2014
@@ -36,7 +36,7 @@ import org.apache.roller.weblogger.pojos
  * of this class.
  */
 public class SharedThemeResourceFromDir 
-        implements ThemeResource, Serializable, Comparable {
+        implements ThemeResource, Serializable {
     
     // the physical java.io.File backing this resource
     private File resourceFile = null;
@@ -54,8 +54,7 @@ public class SharedThemeResourceFromDir 
     /**
      * @see java.lang.Comparable#compareTo(java.lang.Object)
      */
-    public int compareTo(Object o) {
-        ThemeResource other = (ThemeResource) o;
+    public int compareTo(ThemeResource other) {
         return getPath().compareTo(other.getPath());
     }
     

Modified: roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java
URL: http://svn.apache.org/viewvc/roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java?rev=1588757&r1=1588756&r2=1588757&view=diff
==============================================================================
--- roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java (original)
+++ roller/branches/rome2/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java Sun Apr 20 13:38:51 2014
@@ -45,8 +45,6 @@ public class SharedThemeTemplate impleme
     private boolean navbar = false;
     private String  outputContentType = null;
     private String type = null;
-    
-    private SharedTheme myTheme = null;
 
     //hash map to cache template Code objects parsed
     private HashMap<String, TemplateCode> templateCodeHashMap = new HashMap<String, TemplateCode>();
@@ -54,11 +52,10 @@ public class SharedThemeTemplate impleme
     
     public SharedThemeTemplate() {}
     
-    public SharedThemeTemplate(SharedTheme theme, String id, String action, String name, 
+    public SharedThemeTemplate(String id, String action, String name,
             String desc, String contents, String link, Date date, 
             String tempLang, boolean hid, boolean navbar) {
         
-        this.myTheme = theme;
         this.id = id;
         this.action = action;
         this.name = name;



Mime
View raw message