roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1585640 - in /roller/trunk/app/src/main/java/org/apache/roller: planet/tasks/ util/ weblogger/business/jpa/ weblogger/pojos/ weblogger/ui/core/filters/ weblogger/ui/core/security/ weblogger/ui/rendering/model/ weblogger/ui/rendering/util/c...
Date Tue, 08 Apr 2014 01:41:23 GMT
Author: gmazza
Date: Tue Apr  8 01:41:22 2014
New Revision: 1585640

URL: http://svn.apache.org/r1585640
Log:
Various Sonar complaints fixed.

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/planet/tasks/GeneratePlanetTask.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/JPAPersistenceStrategy.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/filters/LoadSaltFilter.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SiteModel.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/PlanetCache.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SaltCache.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/struts2/editor/MediaFileSearchBean.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/ExpiringLRUCacheImpl.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomHandler.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/BloggerAPIHandler.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java?rev=1585640&r1=1585639&r2=1585640&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/planet/tasks/GeneratePlanetTask.java
Tue Apr  8 01:41:22 2014
@@ -47,8 +47,7 @@ public class GeneratePlanetTask extends 
     
     public void run() {
         try {            
-            Weblogger weblogger = WebloggerFactory.getWeblogger();
-//          PlanetManager planetManager = weblogger.getPlanetManager();
+//          PlanetManager planetManager = WebloggerFactory.getWeblogger().getPlanetManager();
                         
             // Ignore values from database
             //String mainPage = planetManager.getConfiguration().getMainPage();

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=1585640&r1=1585639&r2=1585640&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 Tue Apr  8
01:41:22 2014
@@ -31,6 +31,8 @@ public final class RollerConstants {
     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;
+    public static final int FIFTEEN_MIN_IN_MS = 15 * MIN_IN_MS;
+    public static final int HOUR_IN_MS = 60 * MIN_IN_MS;
 
     public static final int TEXTWIDTH_255 = 255;
 

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.java?rev=1585640&r1=1585639&r2=1585640&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAPersistenceStrategy.java
Tue Apr  8 01:41:22 2014
@@ -297,8 +297,7 @@ public class JPAPersistenceStrategy {
     public Query getNamedUpdate(String queryName)
     throws WebloggerException {
         EntityManager em = getEntityManager(true);
-        Query q = em.createNamedQuery(queryName);
-        return q;
+        return em.createNamedQuery(queryName);
     }
     
     /**

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java?rev=1585640&r1=1585639&r2=1585640&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/Weblog.java Tue Apr 
8 01:41:22 2014
@@ -52,6 +52,8 @@ public class Weblog implements Serializa
     public static final long serialVersionUID = 206437645033737127L;
     
     private static Log log = LogFactory.getLog(Weblog.class);
+
+    private static final int MAX_ENTRIES = 100;
     
     // Simple properties
     private String  id               = UUIDGenerator.generateUUID();
@@ -759,8 +761,8 @@ public class Weblog implements Serializa
         if (cat != null && "nil".equals(cat)) {
             cat = null;
         }
-        if (length > 100) {
-            length = 100;
+        if (length > MAX_ENTRIES) {
+            length = MAX_ENTRIES;
         }
         List<WeblogEntry> recentEntries = new ArrayList<WeblogEntry>();
         if (length < 1) {
@@ -790,8 +792,8 @@ public class Weblog implements Serializa
         if (tag != null && "nil".equals(tag)) {
             tag = null;
         }
-        if (length > 100) {
-            length = 100;
+        if (length > MAX_ENTRIES) {
+            length = MAX_ENTRIES;
         }
         List<WeblogEntry> recentEntries = new ArrayList<WeblogEntry>();
         List<String> tags = new ArrayList<String>();
@@ -821,8 +823,8 @@ public class Weblog implements Serializa
      * @return List of comment objects.
      */
     public List<WeblogEntryComment> getRecentComments(int length) {
-        if (length > 100) {
-            length = 100;
+        if (length > MAX_ENTRIES) {
+            length = MAX_ENTRIES;
         }
         List<WeblogEntryComment> recentComments = new ArrayList<WeblogEntryComment>();
         if (length < 1) {

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/filters/LoadSaltFilter.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/filters/LoadSaltFilter.java?rev=1585640&r1=1585639&r2=1585640&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/filters/LoadSaltFilter.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/filters/LoadSaltFilter.java
Tue Apr  8 01:41:22 2014
@@ -32,7 +32,6 @@ import org.apache.roller.weblogger.ui.re
  * Roller. See also: ValidateSalt filter.
  */
 public class LoadSaltFilter implements Filter {
-    private static Log log = LogFactory.getLog(LoadSaltFilter.class);
 
     //@Override
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java?rev=1585640&r1=1585639&r2=1585640&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/security/RollerUserDetailsService.java
Tue Apr  8 01:41:22 2014
@@ -38,7 +38,7 @@ public class RollerUserDetailsService im
         }
         try {
             UserManager umgr = roller.getUserManager();
-            User userData = null;  
+            User userData;
             // OpenID user
             if (userName.startsWith("http://") || userName.startsWith("https://")) {
                 if (userName.endsWith("/")) {
@@ -69,10 +69,8 @@ public class RollerUserDetailsService im
                      name = userData.getUserName();
                      password = userData.getPassword();
                 }
-                UserDetails usr = new org.springframework.security.core.userdetails.User(name,
password,
+                return new org.springframework.security.core.userdetails.User(name, password,
                         true, true, true, true, authorities);
-                return  usr;
-                
             } else {
                 // standard username/password auth
                 try {
@@ -97,7 +95,6 @@ public class RollerUserDetailsService im
      private ArrayList<SimpleGrantedAuthority> getAuthorities(User userData, UserManager
umgr) throws WebloggerException {
          List<String> roles = umgr.getRoles(userData);
          ArrayList<SimpleGrantedAuthority> authorities = new ArrayList<SimpleGrantedAuthority>(roles.size());
-         int i = 0;
          for (String role : roles) {
              authorities.add(new SimpleGrantedAuthority(role));
          }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SiteModel.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SiteModel.java?rev=1585640&r1=1585639&r2=1585640&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SiteModel.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/model/SiteModel.java
Tue Apr  8 01:41:22 2014
@@ -112,7 +112,7 @@ public class SiteModel implements Model 
      */
     public Pager getWeblogEntriesPager(int sinceDays, int length) {
         
-        String pagerUrl = null;
+        String pagerUrl;
         
         if (feedRequest != null) {
             pagerUrl = urlStrategy.getWeblogFeedURL(weblog, 
@@ -170,7 +170,7 @@ public class SiteModel implements Model 
      */   
     public Pager getWeblogEntriesPager(WeblogWrapper queryWeblog, User user, String cat,
int sinceDays, int length) {
         
-        String pagerUrl = null;
+        String pagerUrl;
         if (feedRequest != null) {
             pagerUrl = urlStrategy.getWeblogFeedURL(weblog, 
                     weblogRequest.getLocale(), feedRequest.getType(),
@@ -201,7 +201,7 @@ public class SiteModel implements Model 
      */
     public Pager getCommentsPager(int sinceDays, int length) {
         
-        String pagerUrl = null;
+        String pagerUrl;
         if (feedRequest != null) {
             pagerUrl = urlStrategy.getWeblogFeedURL(weblog, 
                     weblogRequest.getLocale(), feedRequest.getType(),
@@ -226,7 +226,7 @@ public class SiteModel implements Model 
     /* Get pager of users whose names begin with specified letter */
     public Pager getUsersByLetterPager(String letter, int sinceDays, int length) {
         
-        String pagerUrl = null;
+        String pagerUrl;
         if (feedRequest != null) {
             pagerUrl = urlStrategy.getWeblogFeedURL(weblog, 
                     weblogRequest.getLocale(), feedRequest.getType(),
@@ -470,7 +470,6 @@ public class SiteModel implements Model 
         cal.add(Calendar.DATE, -1 * sinceDays);
         Date startDate = cal.getTime();
         try {            
-            Weblogger roller = WebloggerFactory.getWeblogger();
             results = WebloggerFactory.getWeblogger().getWeblogManager().getMostCommentedWeblogs(
                     startDate, new Date(), 0, length);
         } catch (Exception e) {

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/PlanetCache.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/PlanetCache.java?rev=1585640&r1=1585639&r2=1585640&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/PlanetCache.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/PlanetCache.java
Tue Apr  8 01:41:22 2014
@@ -49,7 +49,7 @@ public final class PlanetCache {
     
     // keep a cached version of last expired time
     private ExpiringCacheEntry lastUpdateTime = null;
-    private long timeout = 15 * RollerConstants.MIN_IN_MS;
+    private long timeout = RollerConstants.FIFTEEN_MIN_IN_MS;
     
     // reference to our singleton instance
     private static PlanetCache singletonInstance = new PlanetCache();

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SaltCache.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SaltCache.java?rev=1585640&r1=1585639&r2=1585640&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SaltCache.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/SaltCache.java
Tue Apr  8 01:41:22 2014
@@ -98,7 +98,7 @@ public class SaltCache {
     
     public void put(String key, Object value) {
 		// expire after 60 minutes
-        contentCache.put(key, new ExpiringCacheEntry(value, 60 * RollerConstants.MIN_IN_MS));
+        contentCache.put(key, new ExpiringCacheEntry(value, RollerConstants.HOUR_IN_MS));
         log.debug("PUT "+key);
     }
     

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=1585640&r1=1585639&r2=1585640&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
Tue Apr  8 01:41:22 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 * RollerConstants.MIN_IN_MS;
+    private long timeout = RollerConstants.FIFTEEN_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/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=1585640&r1=1585639&r2=1585640&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
Tue Apr  8 01:41:22 2014
@@ -35,31 +35,31 @@ public class MediaFileSearchBean {
     private transient ResourceBundle bundle =
             ResourceBundle.getBundle("ApplicationResources");
 
-    public static int PAGE_SIZE = 10;
+    public static final int PAGE_SIZE = 10;
 
     // Media file name as search criteria
-    String name;
+    private String name;
 
     // Media file type as search criteria
-    String type;
+    private String type;
 
     // Type of size filter as search criteria
-    String sizeFilterType;
+    private String sizeFilterType;
 
     // Size of file as search criteria
-    long size;
+    private long size;
 
     // Size unit
-    String sizeUnit;
+    private String sizeUnit;
 
     // Tags as search criteria
-    String tags;
+    private String tags;
 
     // Page number of results
-    int pageNum = 0;
+    private int pageNum = 0;
     
     // Sort option for search results
-    int sortOption;
+    private int sortOption;
 
     public String getName() {
         return name;

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=1585640&r1=1585639&r2=1585640&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 Tue
Apr  8 01:41:22 2014
@@ -453,7 +453,7 @@ public class HTMLSanitizer {
         public String text = "";
         public String val = "";
         public boolean isValid = true;
-        public List<String> invalidTags = new ArrayList();
+        public List<String> invalidTags = new ArrayList<String>();
     }
 
     public static String encode(String s) {
@@ -466,8 +466,7 @@ public class HTMLSanitizer {
 
     public static final String htmlEncodeApexes(String source) {
         if (source != null) {
-            String result = replaceAllNoRegex(source, new String[]{"\"", "'"}, new String[]{"&quot;",
"&#39;"});
-            return result;
+            return replaceAllNoRegex(source, new String[]{"\"", "'"}, new String[]{"&quot;",
"&#39;"});
         } else {
             return null;
         }
@@ -475,8 +474,7 @@ public class HTMLSanitizer {
 
     public static final String htmlEncodeTag(String source) {
         if (source != null) {
-            String result = replaceAllNoRegex(source, new String[]{"<", ">"}, new String[]{"&lt;",
"&gt;"});
-            return result;
+            return replaceAllNoRegex(source, new String[]{"<", ">"}, new String[]{"&lt;",
"&gt;"});
         } else {
             return null;
         }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/cache/ExpiringLRUCacheImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/cache/ExpiringLRUCacheImpl.java?rev=1585640&r1=1585639&r2=1585640&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/cache/ExpiringLRUCacheImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/cache/ExpiringLRUCacheImpl.java
Tue Apr  8 01:41:22 2014
@@ -36,7 +36,7 @@ public class ExpiringLRUCacheImpl extend
     protected ExpiringLRUCacheImpl(String id) {
         
         super(id);
-        this.timeout = 60 * RollerConstants.MIN_IN_MS;
+        this.timeout = RollerConstants.HOUR_IN_MS;
     }
     
     

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomHandler.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomHandler.java?rev=1585640&r1=1585639&r2=1585640&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomHandler.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/atomprotocol/RollerAtomHandler.java
Tue Apr  8 01:41:22 2014
@@ -96,13 +96,13 @@ public class RollerAtomHandler implement
     protected int maxEntries = 20;
     protected String atomURL = null;
     
-    protected static final boolean throttle;
+    protected static final boolean THROTTLE;
     
     protected static Log log =
             LogFactory.getFactory().getInstance(RollerAtomHandler.class);
     
     static {
-        throttle = WebloggerConfig
+        THROTTLE = WebloggerConfig
             .getBooleanProperty("webservices.atomprotocol.oneSecondThrottle", true);
     }
     
@@ -514,7 +514,7 @@ public class RollerAtomHandler implement
     public static void oneSecondThrottle() {
         // Throttle one entry per second per weblog because time-
         // stamp in MySQL and other DBs has only 1 sec resolution
-        if (throttle) {
+        if (THROTTLE) {
             try {
                 synchronized (RollerAtomHandler.class) {
                     Thread.sleep(RollerConstants.SEC_IN_MS);

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/BloggerAPIHandler.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/BloggerAPIHandler.java?rev=1585640&r1=1585639&r2=1585640&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/BloggerAPIHandler.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/webservices/xmlrpc/BloggerAPIHandler.java
Tue Apr  8 01:41:22 2014
@@ -272,8 +272,6 @@ public class BloggerAPIHandler extends B
         Vector result = new Vector();
         if (validateUser(userid, password)) {
             try {
-                String contextUrl = WebloggerRuntimeConfig.getAbsoluteContextURL();
-                
                 UserManager umgr = WebloggerFactory.getWeblogger().getUserManager();
                 User user = umgr.getUserByUserName(userid);
                 



Mime
View raw message