roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1582167 - in /roller/trunk/app/src/main/java/org/apache/roller: planet/business/fetcher/ util/ weblogger/business/jpa/ weblogger/business/plugins/entry/ weblogger/business/startup/ weblogger/config/ weblogger/pojos/ weblogger/ui/rendering/...
Date Thu, 27 Mar 2014 03:06:36 GMT
Author: gmazza
Date: Thu Mar 27 03:06:35 2014
New Revision: 1582167

URL: http://svn.apache.org/r1582167
Log:
Fixed several Sonar issues.

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/planet/business/fetcher/RomeFeedFetcher.java
    roller/trunk/app/src/main/java/org/apache/roller/util/RollerConstants.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/WebloggerStartup.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/config/WebloggerRuntimeConfig.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/GlobalPermission.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsFeedModel.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsModel.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/CommentServlet.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogCacheWarmupJob.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/VelocityRenderer.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearchBean.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/tags/StringW.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/HTMLSanitizer.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/cache/ExpiringLRUCacheFactoryImpl.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/planet/business/fetcher/RomeFeedFetcher.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/planet/business/fetcher/RomeFeedFetcher.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/planet/business/fetcher/RomeFeedFetcher.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/planet/business/fetcher/RomeFeedFetcher.java
Thu Mar 27 03:06:35 2014
@@ -38,6 +38,7 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 import org.apache.commons.lang3.StringEscapeUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.planet.pojos.SubscriptionEntry;
@@ -220,10 +221,8 @@ public class RomeFeedFetcher implements 
         }
         
         // no content, try summary
-        if (newEntry.getText() == null || newEntry.getText().trim().length() == 0) {
-            if (romeEntry.getDescription() != null) {
-                newEntry.setText(romeEntry.getDescription().getValue());
-            }
+        if (StringUtils.isBlank(newEntry.getText()) && romeEntry.getDescription()
!= null)  {
+            newEntry.setText(romeEntry.getDescription().getValue());
         }
         
         // copy categories

Modified: roller/trunk/app/src/main/java/org/apache/roller/util/RollerConstants.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/util/RollerConstants.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/util/RollerConstants.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/util/RollerConstants.java Thu Mar 27
03:06:35 2014
@@ -26,11 +26,13 @@ public final class RollerConstants {
     public static final int EIGHT_KB_IN_BYTES = 8192;
     public static final int TWENTYFOUR_KB_IN_BYTES = 24576;
 
+    public static final int ONE_MB_IN_BYTES = ONE_KB_IN_BYTES * 2;
+
     public static final int HALF_SEC_IN_MS = 500;
     public static final int SEC_IN_MS = 1000;
     public static final int MIN_IN_MS = 60 * SEC_IN_MS;
 
-    private RollerConstants(){
+    private RollerConstants() {
         // never instantiable
         throw new AssertionError();
     }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPABookmarkManagerImpl.java
Thu Mar 27 03:06:35 2014
@@ -96,12 +96,10 @@ public class JPABookmarkManagerImpl impl
     }
 
     public void saveFolder(WeblogBookmarkFolder folder) throws WebloggerException {
-        
-        if (folder.getId() == null || this.getFolder(folder.getId()) == null) {
-            // New folder, so make sure name is unique
-            if (isDuplicateFolderName(folder)) {
-                throw new WebloggerException("Duplicate folder name");
-            }
+
+        // If new folder make sure name is unique
+        if ((folder.getId() == null || this.getFolder(folder.getId()) == null) &&
isDuplicateFolderName(folder)) {
+            throw new WebloggerException("Duplicate folder name");
         }
 
         this.strategy.store(folder);
@@ -147,7 +145,7 @@ public class JPABookmarkManagerImpl impl
             // Iterate through children of OPML body, importing each
             Element body = doc.getRootElement().getChild("body");
             for (Object elem : body.getChildren()) {
-                importOpmlElement(website, (Element) elem, newFolder );
+                importOpmlElement((Element) elem, newFolder );
             }
         } catch (Exception ex) {
             throw new WebloggerException(ex);
@@ -158,13 +156,12 @@ public class JPABookmarkManagerImpl impl
     // NOTE: this method does not commit any changes; 
     // that is done higher up in execution chain
     private void importOpmlElement(
-            Weblog website, Element elem, WeblogBookmarkFolder folder)
+            Element elem, WeblogBookmarkFolder folder)
             throws WebloggerException {
         String text = elem.getAttributeValue("text");
         String title = elem.getAttributeValue("title");
         String desc = elem.getAttributeValue("description");
         String url = elem.getAttributeValue("url");
-        //String type = elem.getAttributeValue("type");
         String xmlUrl = elem.getAttributeValue("xmlUrl");
         String htmlUrl = elem.getAttributeValue("htmlUrl");
 
@@ -208,7 +205,7 @@ public class JPABookmarkManagerImpl impl
         } else {
             // Import suboutline's children into folder
             for (Object subelem : elem.getChildren("outline")) {
-                importOpmlElement( website, (Element) subelem, folder );
+                importOpmlElement((Element) subelem, folder );
             }
         }
     }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogEntryManagerImpl.java
Thu Mar 27 03:06:35 2014
@@ -29,6 +29,7 @@ import org.apache.commons.lang3.StringUt
 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.pojos.WeblogEntryComment;
@@ -91,12 +92,10 @@ public class JPAWeblogEntryManagerImpl i
      */
     public void saveWeblogCategory(WeblogCategory cat) throws WebloggerException {
         boolean exists = getWeblogCategory(cat.getId()) != null;
-        if (!exists) {
-            if (isDuplicateWeblogCategoryName(cat)) {
-                throw new WebloggerException("Duplicate category name, cannot save category");
-            }
+        if (!exists && isDuplicateWeblogCategoryName(cat)) {
+            throw new WebloggerException("Duplicate category name, cannot save category");
         }
-        
+
         // update weblog last modified date.  date updated by saveWebsite()
         roller.getWeblogManager().saveWeblog(cat.getWeblog());
         this.strategy.store(cat);
@@ -208,7 +207,7 @@ public class JPAWeblogEntryManagerImpl i
         // we only consider an entry future published if it is scheduled
         // more than 1 minute into the future
         if ("PUBLISHED".equals(entry.getStatus()) &&
-                entry.getPubTime().after(new Date(System.currentTimeMillis() + 60000))) {
+                entry.getPubTime().after(new Date(System.currentTimeMillis() + RollerConstants.MIN_IN_MS)))
{
             entry.setStatus(WeblogEntry.SCHEDULED);
         }
         

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAWeblogManagerImpl.java
Thu Mar 27 03:06:35 2014
@@ -18,6 +18,7 @@
 
 package org.apache.roller.weblogger.business.jpa;
 
+import org.apache.commons.lang3.BooleanUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.roller.weblogger.WebloggerException;
@@ -55,6 +56,7 @@ import org.apache.roller.weblogger.pojos
 import org.apache.roller.weblogger.pojos.WeblogThemeTemplateCode;
 
 
+
 /*
  * JPAWeblogManagerImpl.java
  * Created on May 31, 2006, 4:08 PM
@@ -505,10 +507,8 @@ public class JPAWeblogManagerImpl implem
         List<WeblogPermission> perms = roller.getUserManager().getWeblogPermissions(user);
         for (WeblogPermission perm : perms) {
             Weblog weblog = perm.getWeblog();
-            if (!enabledOnly || weblog.getEnabled()) {
-                if (weblog.getActive() != null && weblog.getActive()) {
-                    weblogs.add(weblog);
-                }
+            if ((!enabledOnly || weblog.getEnabled()) && BooleanUtils.isTrue(weblog.getActive()))
{
+                weblogs.add(weblog);
             }
         }
         return weblogs;

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/plugins/entry/BookmarkPlugin.java
Thu Mar 27 03:06:35 2014
@@ -116,11 +116,9 @@ public class BookmarkPlugin implements W
                             if (inLink > 0) {
                                 inLink--;
                             }
-                        } else if (m.group(4) != null) {
+                        } else if (m.group(4) != null && inLink == 0) {
                             // matched the bookmark -- replace, but only if not within a
link tag.
-                            if (inLink == 0) {
-                                m.appendReplacement(textBuf, bookmarkLink);
-                            }
+                            m.appendReplacement(textBuf, bookmarkLink);
                         }
                     }
                     // Any remaining case indicates a bug.  One could add an else with assertion
here.  Conservatively don't substitute.

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/DatabaseInstaller.java
Thu Mar 27 03:06:35 2014
@@ -816,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;
                 }
             }
             

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/WebloggerStartup.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/WebloggerStartup.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/WebloggerStartup.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/startup/WebloggerStartup.java
Thu Mar 27 03:06:35 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/trunk/app/src/main/java/org/apache/roller/weblogger/config/WebloggerRuntimeConfig.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/config/WebloggerRuntimeConfig.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/config/WebloggerRuntimeConfig.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/config/WebloggerRuntimeConfig.java
Thu Mar 27 03:06:35 2014
@@ -23,6 +23,7 @@ import java.io.InputStreamReader;
 import java.io.StringWriter;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.config.runtime.RuntimeConfigDefs;
 import org.apache.roller.weblogger.config.runtime.RuntimeConfigDefsParser;
 import org.apache.roller.weblogger.business.PropertiesManager;
@@ -157,7 +158,7 @@ public final class WebloggerRuntimeConfi
                     new InputStreamReader(WebloggerConfig.class.getResourceAsStream(RUNTIME_CONFIG));
             StringWriter configString = new StringWriter();
             
-            char[] buf = new char[8196];
+            char[] buf = new char[RollerConstants.EIGHT_KB_IN_BYTES];
             int length = 0;
             while((length = reader.read(buf)) > 0) {
                 configString.write(buf, 0, length);

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/GlobalPermission.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/GlobalPermission.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/GlobalPermission.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/GlobalPermission.java
Thu Mar 27 03:06:35 2014
@@ -21,6 +21,9 @@ package org.apache.roller.weblogger.pojo
 import java.security.Permission;
 import java.util.ArrayList;
 import java.util.List;
+
+import org.apache.commons.lang3.builder.EqualsBuilder;
+import org.apache.commons.lang3.builder.HashCodeBuilder;
 import org.apache.roller.weblogger.WebloggerException;
 import org.apache.roller.weblogger.business.WebloggerFactory;
 import org.apache.roller.weblogger.config.WebloggerConfig;
@@ -138,14 +141,6 @@ public class GlobalPermission extends Ro
         return sb.toString();
     }
 
-    public boolean equals(Object arg0) {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
-    public int hashCode() {
-        throw new UnsupportedOperationException("Not supported yet.");
-    }
-
     @Override
     public void setActions(String actions) {
         this.actions = actions;
@@ -155,4 +150,26 @@ public class GlobalPermission extends Ro
     public String getActions() {
         return actions;
     }
+
+    @Override
+    public boolean equals(Object other) {
+        if (other == this) {
+            return true;
+        }
+        if (!(other instanceof GlobalPermission)) {
+            return false;
+        }
+        GlobalPermission o = (GlobalPermission) other;
+        return new EqualsBuilder()
+                .append(getActions(), o.getActions())
+                .isEquals();
+    }
+
+    @Override
+    public int hashCode() {
+        return new HashCodeBuilder()
+                .append(getActions())
+                .toHashCode();
+    }
+
 }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/WeblogRequestMapper.java
Thu Mar 27 03:06:35 2014
@@ -59,12 +59,12 @@ public class WeblogRequestMapper impleme
     
     
     // url patterns that are not allowed to be considered weblog handles
-    Set restricted = null;
+    Set<String> restricted = null;
     
     
     public WeblogRequestMapper() {
         
-        this.restricted = new HashSet();
+        this.restricted = new HashSet<String>();
         
         // build roller restricted list
         String restrictList = 
@@ -135,12 +135,10 @@ public class WeblogRequestMapper impleme
 
         String weblogAbsoluteURL =
             WebloggerConfig.getProperty("weblog.absoluteurl." + weblogHandle);
-        if (weblogAbsoluteURL != null) {
-            // An absolute URL is specified for this weblog, make sure request URL matches
-            if (!request.getRequestURL().toString().startsWith(weblogAbsoluteURL)) {
-                log.debug("SKIPPED "+weblogHandle);
-                return false;
-            }
+        // If an absolute URL is specified for this weblog, make sure request URL matches
+        if (weblogAbsoluteURL != null && !request.getRequestURL().toString().startsWith(weblogAbsoluteURL))
{
+            log.debug("SKIPPED " + weblogHandle);
+            return false;
         }
         
         log.debug("WEBLOG_URL "+request.getServletPath());

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsFeedModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsFeedModel.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsFeedModel.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsFeedModel.java
Thu Mar 27 03:06:35 2014
@@ -201,9 +201,9 @@ public class SearchResultsFeedModel impl
 			Weblogger roller = WebloggerFactory.getWeblogger();
 			WeblogEntryManager weblogMgr = roller.getWeblogEntryManager();
 
-			WeblogEntry entry = null;
-			Document doc = null;
-			String handle = null;
+			WeblogEntry entry;
+			Document doc;
+			String handle;
 			Timestamp now = new Timestamp(new Date().getTime());
 			for (int i = offset; i < offset + limit; i++) {
 				doc = search.getSearcher().doc(hits[i].doc);
@@ -213,12 +213,9 @@ public class SearchResultsFeedModel impl
                 entry = weblogMgr.getWeblogEntry(doc.getField(
                         FieldConstants.ID).stringValue());
 
-				if (!(websiteSpecificSearch
-						&& handle.equals(feedRequest.getWeblogHandle()))) {
-					if (doc.getField(FieldConstants.CATEGORY) != null) {
-						categories.add(doc.getField(FieldConstants.CATEGORY)
-								.stringValue());
-					}
+				if (!(websiteSpecificSearch && handle.equals(feedRequest.getWeblogHandle()))
+                        && doc.getField(FieldConstants.CATEGORY) != null) {
+                    categories.add(doc.getField(FieldConstants.CATEGORY).stringValue());
 				}
 
 				// maybe null if search result returned inactive user

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsModel.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsModel.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SearchResultsModel.java
Thu Mar 27 03:06:35 2014
@@ -209,13 +209,10 @@ public class SearchResultsModel extends 
                 entry = weblogMgr.getWeblogEntry(doc.getField(
                         FieldConstants.ID).stringValue());
 
-				if (!(websiteSpecificSearch
-						&& handle.equals(searchRequest.getWeblogHandle()))) {
-					if (doc.getField(FieldConstants.CATEGORY) != null) {
-						categories.add(doc.getField(FieldConstants.CATEGORY)
-								.stringValue());
-					}
-				}
+                if (!(websiteSpecificSearch && handle.equals(searchRequest.getWeblogHandle()))
+                        && doc.getField(FieldConstants.CATEGORY) != null) {
+                    categories.add(doc.getField(FieldConstants.CATEGORY).stringValue());
+                }
 
 				// maybe null if search result returned inactive user
 				// or entry's user is not the requested user.

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/CommentServlet.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/CommentServlet.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/CommentServlet.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/CommentServlet.java
Thu Mar 27 03:06:35 2014
@@ -29,6 +29,7 @@ import javax.servlet.http.HttpServletReq
 import javax.servlet.http.HttpServletResponse;
 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.config.WebloggerConfig;
 import org.apache.roller.weblogger.config.WebloggerRuntimeConfig;
@@ -110,12 +111,12 @@ public class CommentServlet extends Http
                         e);
             }
 
-            int interval = 60000;
+            int interval = RollerConstants.MIN_IN_MS;
             try {
                 interval = Integer.parseInt(WebloggerConfig
                         .getProperty("comment.throttle.interval"));
                 // convert from seconds to milliseconds
-                interval = interval * 1000;
+                interval = interval * RollerConstants.SEC_IN_MS;
             } catch (Exception e) {
                 log.warn(
                         "bad input for config property comment.throttle.interval",

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/PageServlet.java
Thu Mar 27 03:06:35 2014
@@ -350,12 +350,9 @@ public class PageServlet extends HttpSer
         if (pageRequest.getWeblogPageName() != null && page.isHidden()) {
             invalid = true;
         }
-        if (pageRequest.getLocale() != null) {
-
-            // locale view only allowed if weblog has enabled it
-            if (!pageRequest.getWeblog().isEnableMultiLang()) {
-                invalid = true;
-            }
+        // locale view allowed only if weblog has enabled it
+        if (pageRequest.getLocale() != null && !pageRequest.getWeblog().isEnableMultiLang())
{
+            invalid = true;
         }
         if (pageRequest.getWeblogAnchor() != null) {
 

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SiteWideCache.java
Thu Mar 27 03:06:35 2014
@@ -66,7 +66,7 @@ public class SiteWideCache implements Ca
     
     // keep a cached version of last expired time
     private ExpiringCacheEntry lastUpdateTime = null;
-    private long timeout = 15 * 60 * RollerConstants.SEC_IN_MS;
+    private long timeout = 15 * RollerConstants.MIN_IN_MS;
     
     // reference to our singleton instance
     private static SiteWideCache singletonInstance = new SiteWideCache();

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogCacheWarmupJob.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogCacheWarmupJob.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogCacheWarmupJob.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogCacheWarmupJob.java
Thu Mar 27 03:06:35 2014
@@ -31,7 +31,6 @@ import org.apache.roller.weblogger.pojos
 import org.apache.roller.weblogger.ui.rendering.Renderer;
 import org.apache.roller.weblogger.ui.rendering.RendererManager;
 import org.apache.roller.weblogger.ui.rendering.mobile.MobileDeviceRepository.DeviceType;
-import org.apache.roller.weblogger.ui.rendering.model.Model;
 import org.apache.roller.weblogger.ui.rendering.model.ModelLoader;
 import org.apache.roller.weblogger.ui.rendering.util.WeblogFeedRequest;
 import org.apache.roller.weblogger.util.cache.CachedContent;

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/VelocityRenderer.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/VelocityRenderer.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/VelocityRenderer.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/VelocityRenderer.java
Thu Mar 27 03:06:35 2014
@@ -30,7 +30,6 @@ import org.apache.roller.weblogger.pojos
 import org.apache.roller.weblogger.ui.rendering.Renderer;
 import org.apache.roller.weblogger.ui.rendering.RenderingException;
 import org.apache.roller.weblogger.ui.rendering.mobile.MobileDeviceRepository;
-import org.apache.roller.weblogger.ui.rendering.model.Model;
 import org.apache.roller.weblogger.ui.rendering.model.UtilitiesModel;
 import org.apache.velocity.VelocityContext;
 import org.apache.velocity.context.Context;

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/core/Profile.java
Thu Mar 27 03:06:35 2014
@@ -145,12 +145,9 @@ public class Profile extends UIAction {
 
     
     public void myValidate() {
-
-        // check that passwords match if they were specified
-        if (!StringUtils.isEmpty(getBean().getPasswordText())) {
-            if (!getBean().getPasswordText().equals(getBean().getPasswordConfirm())) {
-                addError("Register.error.passowordMismatch");
-            }
+        // check that passwords match if they were specified (w/StringUtils.equals, null
== null)
+        if (!StringUtils.equals(getBean().getPasswordText(), getBean().getPasswordConfirm()))
{
+            addError("userRegister.error.mismatchedPasswords");
         }
     }
 

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/CategoryEdit.java
Thu Mar 27 03:06:35 2014
@@ -78,7 +78,7 @@ public class CategoryEdit extends UIActi
     @SkipValidation
     public String execute() {
         
-        if(getCategory() == null) {
+        if (getCategory() == null) {
             // TODO: i18n
             addError("Cannot edit null category");
             return ERROR;
@@ -145,10 +145,9 @@ public class CategoryEdit extends UIActi
         // name is required, has max length, no html
         
         // make sure new name is not a duplicate of an existing category
-        if(!getCategory().getName().equals(getBean().getName())) {
-            if(getCategory().getWeblog().hasCategory(getBean().getName())) {
-                addError("categoryForm.error.duplicateName", getBean().getName());
-            }
+        if (!getCategory().getName().equals(bean.getName()) &&
+            getCategory().getWeblog().hasCategory(bean.getName())) {
+            addError("categoryForm.error.duplicateName", bean.getName());
         }
     }
 

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileBase.java
Thu Mar 27 03:06:35 2014
@@ -103,9 +103,9 @@ public class MediaFileBase extends UIAct
             if (fileIds != null && fileIds.length > 0) {
                 log.debug("Processing delete of " + fileIds.length
                         + " media files.");
-                for (int index = 0; index < fileIds.length; index++) {
-                    log.debug("Deleting media file - " + fileIds[index]);
-                    MediaFile mediaFile = manager.getMediaFile(fileIds[index]);
+                for (String fileId : fileIds) {
+                    log.debug("Deleting media file - " + fileId);
+                    MediaFile mediaFile = manager.getMediaFile(fileId);
                     if (mediaFile != null) {
                         manager.removeMediaFile(getActionWeblog(), mediaFile);
                     }
@@ -116,14 +116,11 @@ public class MediaFileBase extends UIAct
                 log.debug("Processing delete of " + dirIds.length
                         + " media directories.");
                 manager = WebloggerFactory.getWeblogger().getMediaFileManager();
-                for (int index = 0; index < dirIds.length; index++) {
-                    log.debug("Deleting media file directory - "
-                            + dirIds[index]);
-                    MediaFileDirectory mediaFileDir = manager
-                            .getMediaFileDirectory(dirIds[index]);
+                for (String dirId : dirIds) {
+                    log.debug("Deleting media file directory - " + dirId);
+                    MediaFileDirectory mediaFileDir = manager.getMediaFileDirectory(dirId);
                     if (mediaFileDir != null) {
-                        mediaFileDir.getParent().removeChildDirectory(
-                                mediaFileDir);
+                        mediaFileDir.getParent().removeChildDirectory(mediaFileDir);
                         manager.removeMediaFileDirectory(mediaFileDir);
                     }
                 }
@@ -159,16 +156,13 @@ public class MediaFileBase extends UIAct
                         + " media files.");
                 MediaFileDirectory targetDirectory = manager
                         .getMediaFileDirectory(this.selectedDirectory);
-                for (int index = 0; index < fileIds.length; index++) {
-                    log.debug("Moving media file - " + fileIds[index]
+                for (String fileId : fileIds) {
+                    log.debug("Moving media file - " + fileId
                             + " to directory - " + this.selectedDirectory);
-                    MediaFile mediaFile = manager.getMediaFile(fileIds[index]);
-                    if (mediaFile != null) {
-                        if (!mediaFile.getDirectory().getId()
-                                .equals(targetDirectory.getId())) {
-                            manager.moveMediaFile(mediaFile, targetDirectory);
-                            movedFiles++;
-                        }
+                    MediaFile mediaFile = manager.getMediaFile(fileId);
+                    if (mediaFile != null && !mediaFile.getDirectory().getId().equals(targetDirectory.getId()))
{
+                        manager.moveMediaFile(mediaFile, targetDirectory);
+                        movedFiles++;
                     }
                 }
             }
@@ -179,20 +173,16 @@ public class MediaFileBase extends UIAct
                         + " media files directories.");
                 MediaFileDirectory targetDirectory = manager
                         .getMediaFileDirectory(this.selectedDirectory);
-                for (int index = 0; index < dirIds.length; index++) {
-                    log.debug("Moving media file - " + dirIds[index]
+                for (String dirId : dirIds) {
+                    log.debug("Moving media file - " + dirId
                             + " to directory - " + this.selectedDirectory);
                     MediaFileDirectory mediaFileDir = manager
-                            .getMediaFileDirectory(dirIds[index]);
-                    if (mediaFileDir != null) {
-                        if (!mediaFileDir.getId().equals(
-                                targetDirectory.getId())
-                                && !mediaFileDir.getParent().getId()
-                                        .equals(targetDirectory.getId())) {
-                            manager.moveMediaFileDirectory(mediaFileDir,
-                                    targetDirectory);
-                            movedDirs++;
-                        }
+                            .getMediaFileDirectory(dirId);
+                    if (mediaFileDir != null
+                            && !mediaFileDir.getId().equals(targetDirectory.getId())
+                            && !mediaFileDir.getParent().getId().equals(targetDirectory.getId()))
{
+                        manager.moveMediaFileDirectory(mediaFileDir,targetDirectory);
+                        movedDirs++;
                     }
                 }
             }
@@ -220,8 +210,7 @@ public class MediaFileBase extends UIAct
         try {
             MediaFileManager mgr = WebloggerFactory.getWeblogger()
                     .getMediaFileManager();
-            List<MediaFileDirectory> directories = mgr
-                    .getMediaFileDirectories(getActionWeblog());
+            List<MediaFileDirectory> directories = mgr.getMediaFileDirectories(getActionWeblog());
             List<MediaFileDirectory> sortedDirList = new ArrayList<MediaFileDirectory>();
             sortedDirList.addAll(directories);
             Collections.sort(sortedDirList, new MediaFileDirectoryComparator(

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearchBean.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearchBean.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearchBean.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/MediaFileSearchBean.java
Thu Mar 27 03:06:35 2014
@@ -22,6 +22,7 @@ import java.util.List;
 
 import java.util.ResourceBundle;
 import org.apache.commons.lang3.StringUtils;
+import org.apache.roller.util.RollerConstants;
 import org.apache.roller.weblogger.pojos.MediaFileFilter;
 import org.apache.roller.weblogger.pojos.MediaFileType;
 import org.apache.roller.weblogger.pojos.MediaFileFilter.MediaFileOrder;
@@ -116,9 +117,9 @@ public class MediaFileSearchBean {
         return tags;
     }
 
- /*   public void setTags(String tags) {
+    public void setTags(String tags) {
         this.tags = tags;
-    } */
+    }
 
     public int getPageNum() {
         return pageNum;
@@ -175,9 +176,9 @@ public class MediaFileSearchBean {
 
             long filterSize = this.size ;
             if ("mediaFileView.kb".equals(this.sizeUnit)) {
-                filterSize = this.size * 1024;
+                filterSize = this.size * RollerConstants.ONE_KB_IN_BYTES;
             } else if ("mediaFileView.mb".equals(this.sizeUnit)) {
-                    filterSize = this.size * 1024 * 1024;
+                    filterSize = this.size * RollerConstants.ONE_MB_IN_BYTES;
             }
             dataHolder.setSize(filterSize);
         }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/tags/StringW.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/tags/StringW.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/tags/StringW.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/tags/StringW.java Thu Mar
27 03:06:35 2014
@@ -154,12 +154,8 @@ public final class StringW {
 //                System.err.println("loop[i] is now: "+i);
 //                System.err.println("ounfd-whitespace: '"+substr.charAt(idx+1)+"'.");
                 // Erase a space after a delim. Is this too obscure?
-                if(substr.length() > idx+1) {
-                    if(substr.charAt(idx+1) != '\n') {
-                        if(Character.isWhitespace(substr.charAt(idx+1))) {
-                            i++;
-                        }
-                    }
+                if (substr.length() > idx+1 && (substr.charAt(idx+1) != '\n')
&& Character.isWhitespace(substr.charAt(idx+1))) {
+                    i++;
                 }
 //                System.err.println("i -= "+width+"-"+idx);
                 continue;

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/HTMLSanitizer.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/HTMLSanitizer.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/HTMLSanitizer.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/HTMLSanitizer.java Thu
Mar 27 03:06:35 2014
@@ -169,11 +169,9 @@ public class HTMLSanitizer {
 							ret.invalidTags.add("<" + tag + ">");
 							continue;
 						}
-					} else if ("td".equals(tag) || "th".equals(tag)) {
-						if (openTags.search("tr") < 1) {
-							ret.invalidTags.add("<" + tag + ">");
-							continue;
-						}
+					} else if (("td".equals(tag) || "th".equals(tag)) && openTags.search("tr") <
1) {
+                        ret.invalidTags.add("<" + tag + ">");
+                        continue;
 					}
 
 

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/cache/ExpiringLRUCacheFactoryImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/cache/ExpiringLRUCacheFactoryImpl.java?rev=1582167&r1=1582166&r2=1582167&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/cache/ExpiringLRUCacheFactoryImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/cache/ExpiringLRUCacheFactoryImpl.java
Thu Mar 27 03:06:35 2014
@@ -63,7 +63,7 @@ public class ExpiringLRUCacheFactoryImpl
         
         Cache cache = new ExpiringLRUCacheImpl(id, size, timeout);
         
-        log.debug("new cache constructed. size="+size+", timeout="+timeout);
+        log.debug("new cache constructed. size=" + size + ", timeout=" + timeout);
         
         return cache;
     }



Mime
View raw message