roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1597539 - in /roller/trunk/app/src/main/java/org/apache/roller: util/ weblogger/business/jpa/ weblogger/business/search/ weblogger/business/themes/ weblogger/ui/core/security/ weblogger/ui/core/util/menu/ weblogger/ui/rendering/model/ webl...
Date Mon, 26 May 2014 09:31:35 GMT
Author: gmazza
Date: Mon May 26 09:31:34 2014
New Revision: 1597539

URL: http://svn.apache.org/r1597539
Log:
Fixed some Sonar issues.

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/util/RegexUtil.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/search/IndexManagerImpl.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/search/IndexUtil.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataTemplate.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/core/util/menu/MenuHelper.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/util/cache/SiteWideCache.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/WebappResourceLoader.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/I18nMessages.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/util/RegexUtil.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/util/RegexUtil.java?rev=1597539&r1=1597538&r2=1597539&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/util/RegexUtil.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/util/RegexUtil.java Mon May 26 09:31:34
2014
@@ -20,6 +20,7 @@ package org.apache.roller.util;
 
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
+import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import org.apache.commons.codec.binary.Hex;
@@ -80,10 +81,10 @@ public final class RegexUtil {
      * @param pattern The Pattern to use.
      * @param match The String to match against.
      * @param group The group number to return in case of a match.
-     * @return
+     * @return List of matched groups from the pattern.
      */
-    public static ArrayList getMatches(Pattern pattern, String match, int group) {
-        ArrayList matches = new ArrayList();
+    public static List<String> getMatches(Pattern pattern, String match, int group)
{
+        List<String> matches = new ArrayList<String>();
         Matcher matcher = pattern.matcher(match);
         while (matcher.find()) {
             matches.add( matcher.group(group) );

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=1597539&r1=1597538&r2=1597539&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
Mon May 26 09:31:34 2014
@@ -66,7 +66,7 @@ public class JPAWeblogEntryManagerImpl i
     private final JPAPersistenceStrategy strategy;
     
     // cached mapping of entryAnchors -> entryIds
-    private HashMap<String, String> entryAnchorToIdMap = new HashMap<String, String>();
+    private Map<String, String> entryAnchorToIdMap = new HashMap<String, String>();
     
     /* inline creation of reverse comparator, anonymous inner class */
     private static final Comparator REVERSE_COMPARATOR = new ReverseComparator();

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/search/IndexManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/search/IndexManagerImpl.java?rev=1597539&r1=1597538&r2=1597539&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/search/IndexManagerImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/search/IndexManagerImpl.java
Mon May 26 09:31:34 2014
@@ -362,29 +362,18 @@ public class IndexManagerImpl implements
             public void doRun() {
                 Directory dir = getIndexDirectory();
                 Directory fsdir = getFSDirectory(true);
-
                 IndexWriter writer = null;
-
                 try {
-                    IndexWriterConfig config = new IndexWriterConfig(
-                            FieldConstants.LUCENE_VERSION,
-                            new LimitTokenCountAnalyzer(
-                                    IndexManagerImpl.getAnalyzer(),
+                    IndexWriterConfig config = new IndexWriterConfig(FieldConstants.LUCENE_VERSION,
+                            new LimitTokenCountAnalyzer(IndexManagerImpl.getAnalyzer(),
                                     IndexWriterConfig.DEFAULT_TERM_INDEX_INTERVAL));
-
                     writer = new IndexWriter(fsdir, config);
-
                     writer.addIndexes(new Directory[] { dir });
-
                     writer.commit();
-
                     indexConsistencyMarker.delete();
-
                 } catch (IOException e) {
                     mLogger.error("Problem saving index to disk", e);
-
-                    // Delete the directory, since there was a problem saving
-                    // the RAM contents
+                    // Delete the directory, since there was a problem saving the RAM contents
                     getFSDirectory(true);
                 } finally {
                     try {
@@ -395,7 +384,6 @@ public class IndexManagerImpl implements
                         mLogger.warn("Unable to close IndexWriter.");
                     }
                 }
-
             }
         };
     }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/search/IndexUtil.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/search/IndexUtil.java?rev=1597539&r1=1597538&r2=1597539&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/search/IndexUtil.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/search/IndexUtil.java
Mon May 26 09:31:34 2014
@@ -45,7 +45,7 @@ public final class IndexUtil {
      * 
      * @return Lucene search term
      */
-    public static final Term getTerm(String field, String input) {
+    public static Term getTerm(String field, String input) {
 
         if (input == null || field == null) {
             return null;

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java?rev=1597539&r1=1597538&r2=1597539&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/SharedThemeTemplate.java
Mon May 26 09:31:34 2014
@@ -25,6 +25,7 @@ import org.apache.roller.weblogger.pojos
 import java.io.Serializable;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Map;
 
 
 /**
@@ -47,7 +48,7 @@ public class SharedThemeTemplate impleme
     private String type = null;
 
     //hash map to cache template Code objects parsed
-    private HashMap<String, TemplateCode> templateCodeHashMap = new HashMap<String,
TemplateCode>();
+    private Map<String, TemplateCode> templateCodeHashMap = new HashMap<String,
TemplateCode>();
     
     
     public SharedThemeTemplate() {}

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java?rev=1597539&r1=1597538&r2=1597539&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/ThemeManagerImpl.java
Mon May 26 09:31:34 2014
@@ -83,7 +83,7 @@ public class ThemeManagerImpl implements
 	private Map<String, Theme> themes = null;
 
 	// list of available types for templates
-	private static ArrayList<String> typeList = new ArrayList<String>();
+	private static List<String> typeList = new ArrayList<String>();
 
 	@com.google.inject.Inject
 	protected ThemeManagerImpl(Weblogger roller) {
@@ -472,7 +472,7 @@ public class ThemeManagerImpl implements
         ThemeManagerImpl.getTypesList().add("mobile");
 	}
 
-	public static ArrayList<String> getTypesList() {
+	public static List<String> getTypesList() {
 		return typeList;
 	}
 

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataTemplate.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataTemplate.java?rev=1597539&r1=1597538&r2=1597539&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataTemplate.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/ThemeMetadataTemplate.java
Mon May 26 09:31:34 2014
@@ -19,6 +19,7 @@
 package org.apache.roller.weblogger.business.themes;
 
 import java.util.HashMap;
+import java.util.Map;
 
 /**
  * A parsed 'template' element of a theme metadata descriptor.
@@ -36,7 +37,7 @@ public class ThemeMetadataTemplate {
     private String contentsFile = null;
     private String type = null;
     // Hash table to keep metadata about parsed template code files
-    private HashMap<String, ThemeMetadataTemplateCode> templateCodeTable
+    private Map<String, ThemeMetadataTemplateCode> templateCodeTable
             = new HashMap<String, ThemeMetadataTemplateCode>();
 
     public String getAction() {
@@ -127,7 +128,7 @@ public class ThemeMetadataTemplate {
         return this.getTemplateCodeTable().get(type);
     }
 
-    public HashMap<String, ThemeMetadataTemplateCode> getTemplateCodeTable() {
+    public Map<String, ThemeMetadataTemplateCode> getTemplateCodeTable() {
         return templateCodeTable;
     }
 

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=1597539&r1=1597538&r2=1597539&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
Mon May 26 09:31:34 2014
@@ -53,7 +53,7 @@ public class RollerUserDetailsService im
                 }
                 String name;
                 String password;
-                ArrayList<SimpleGrantedAuthority> authorities;
+                List<SimpleGrantedAuthority> authorities;
                 
                 // We are not throwing UsernameNotFound exception in case of 
                 // openid authentication in order to receive OpenID Simple Registration (SREG)
@@ -81,7 +81,7 @@ public class RollerUserDetailsService im
                 if (userData == null) {
                     throw new UsernameNotFoundException("ERROR no user: " + userName);
                 }
-                ArrayList<SimpleGrantedAuthority> authorities =  getAuthorities(userData,
umgr);
+                List<SimpleGrantedAuthority> authorities =  getAuthorities(userData,
umgr);
                 return new org.springframework.security.core.userdetails.User(userData.getUserName(),
userData.getPassword(),
                         true, true, true, true, authorities);
             }            
@@ -92,9 +92,9 @@ public class RollerUserDetailsService im
 
     }
         
-     private ArrayList<SimpleGrantedAuthority> getAuthorities(User userData, UserManager
umgr) throws WebloggerException {
+     private List<SimpleGrantedAuthority> getAuthorities(User userData, UserManager
umgr) throws WebloggerException {
          List<String> roles = umgr.getRoles(userData);
-         ArrayList<SimpleGrantedAuthority> authorities = new ArrayList<SimpleGrantedAuthority>(roles.size());
+         List<SimpleGrantedAuthority> authorities = new ArrayList<SimpleGrantedAuthority>(roles.size());
          for (String role : roles) {
              authorities.add(new SimpleGrantedAuthority(role));
          }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/util/menu/MenuHelper.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/util/menu/MenuHelper.java?rev=1597539&r1=1597538&r2=1597539&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/util/menu/MenuHelper.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/core/util/menu/MenuHelper.java
Mon May 26 09:31:34 2014
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.logging.Log;
@@ -52,10 +53,10 @@ public final class MenuHelper {
 
     private static Log log = LogFactory.getLog(MenuHelper.class);
 
-    private static HashMap<String, ParsedMenu> menus = new HashMap<String, ParsedMenu>();
+    private static Map<String, ParsedMenu> menus = new HashMap<String, ParsedMenu>();
 
     // menu, menuName, tabName action/subaction check
-    private static HashMap<String, HashMap<String, HashSet<String>>> itemMenu
= new HashMap<String, HashMap<String, HashSet<String>>>();
+    private static Map<String, HashMap<String, HashSet<String>>> itemMenu
= new HashMap<String, HashMap<String, HashSet<String>>>();
 
     private MenuHelper() {
     }

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=1597539&r1=1597538&r2=1597539&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
Mon May 26 09:31:34 2014
@@ -66,7 +66,7 @@ public class SearchResultsModel extends 
 	private URLStrategy urlStrategy = null;
 
 	// the actual search results mapped by Day -> Set of entries
-	private TreeMap<Date, TreeSet<WeblogEntryWrapper>> results
+	private Map<Date, TreeSet<WeblogEntryWrapper>> results
             = new TreeMap<Date, TreeSet<WeblogEntryWrapper>>(new ReverseComparator());
 
 	// the pager used by the 3.0+ rendering system
@@ -270,7 +270,7 @@ public class SearchResultsModel extends 
 		return limit;
 	}
 
-	public TreeMap getResults() {
+	public Map getResults() {
 		return results;
 	}
 

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=1597539&r1=1597538&r2=1597539&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
Mon May 26 09:31:34 2014
@@ -52,7 +52,7 @@ import org.apache.roller.weblogger.util.
 /**
  * Cache for site-wide weblog content.
  */
-public class SiteWideCache implements CacheHandler {
+public final class SiteWideCache implements CacheHandler {
     
     private static Log log = LogFactory.getLog(SiteWideCache.class);
     
@@ -66,8 +66,7 @@ public class SiteWideCache implements Ca
     
     // keep a cached version of last expired time
     private ExpiringCacheEntry lastUpdateTime = null;
-    private long timeout = RollerConstants.FIFTEEN_MIN_IN_MS;
-    
+
     // reference to our singleton instance
     private static SiteWideCache singletonInstance = new SiteWideCache();
     
@@ -169,7 +168,7 @@ public class SiteWideCache implements Ca
         // still null, we need to get a fresh value
         if(lastModified == null) {
             lastModified = new Date();
-            this.lastUpdateTime = new ExpiringCacheEntry(lastModified, this.timeout);
+            this.lastUpdateTime = new ExpiringCacheEntry(lastModified, RollerConstants.FIFTEEN_MIN_IN_MS);
         }
         
         return lastModified;
@@ -287,7 +286,7 @@ public class SiteWideCache implements Ca
         
         StringBuilder key = new StringBuilder();
         
-        key.append(this.CACHE_ID).append(":");
+        key.append(CACHE_ID).append(":");
         key.append("feed/");
         key.append(feedRequest.getWeblogHandle());
         

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/WebappResourceLoader.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/WebappResourceLoader.java?rev=1597539&r1=1597538&r2=1597539&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/WebappResourceLoader.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/velocity/WebappResourceLoader.java
Mon May 26 09:31:34 2014
@@ -21,6 +21,7 @@ package org.apache.roller.weblogger.ui.r
 import java.io.File;
 import java.io.InputStream;
 import java.util.HashMap;
+import java.util.Map;
 
 import javax.servlet.ServletContext;
 
@@ -62,7 +63,7 @@ public class WebappResourceLoader extend
 
 	// The root paths for templates (relative to webapp's root).
 	protected String[] paths = null;
-	protected HashMap<String, String> templatePaths = null;
+	protected Map<String, String> templatePaths = null;
 	protected ServletContext servletContext = null;
 
 	/**
@@ -148,21 +149,16 @@ public class WebappResourceLoader extend
 		}
 
 		if (result == null) {
-
-			for (int i = 0; i < paths.length; i++) {
-
-				String path = paths[i] + split[0];
-
+            for (String pathSegment : paths) {
+				String path = pathSegment + split[0];
 				try {
-
 					result = servletContext.getResourceAsStream(path);
 
 					// save the path and exit the loop if we found the template
 					if (result != null) {
-						templatePaths.put(name, paths[i]);
+						templatePaths.put(name, pathSegment);
 						break;
 					}
-
 				} catch (NullPointerException npe) {
 					// no servletContext was set, whine about it!
 					throw npe;
@@ -255,8 +251,8 @@ public class WebappResourceLoader extend
 		 * found in the previously saved path
 		 */
 		File currentFile = null;
-		for (int i = 0; i < paths.length; i++) {
-			currentFile = new File(rootPath + paths[i], fileName);
+		for (String path : paths) {
+			currentFile = new File(rootPath + path, fileName);
 			if (currentFile.canRead()) {
 				/*
 				 * stop at the first resource found (just like in

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/I18nMessages.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/I18nMessages.java?rev=1597539&r1=1597538&r2=1597539&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/I18nMessages.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/util/I18nMessages.java Mon
May 26 09:31:34 2014
@@ -107,7 +107,7 @@ public final class I18nMessages {
     /**
      * The locale representing this message utils.
      */
-    public final Locale getLocale() {
+    public Locale getLocale() {
         return this.locale;
     }
     
@@ -115,7 +115,7 @@ public final class I18nMessages {
     /**
      * Get a message from the bundle.
      */
-    public final String getString(String key) {
+    public String getString(String key) {
         
         try {
             return bundle.getString(key);
@@ -131,7 +131,7 @@ public final class I18nMessages {
      * Get a message from the bundle and substitute the given args into
      * the message contents.
      */
-    public final String getString(String key, List args) {
+    public String getString(String key, List args) {
         
         try {
             String msg = bundle.getString(key);
@@ -148,7 +148,7 @@ public final class I18nMessages {
      * Get a message from the bundle and substitute the given args into
      * the message contents.
      */
-    public final String getString(String key, Object[] args) {
+    public String getString(String key, Object[] args) {
         
         try {
             String msg = bundle.getString(key);



Mime
View raw message