roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gma...@apache.org
Subject svn commit: r1520831 - in /roller/trunk/app/src/main/java/org/apache/roller/weblogger: business/jpa/ business/search/ business/themes/ pojos/ ui/rendering/servlets/ ui/rendering/util/cache/ ui/rendering/velocity/ ui/struts2/editor/
Date Sun, 08 Sep 2013 02:55:23 GMT
Author: gmazza
Date: Sun Sep  8 02:55:23 2013
New Revision: 1520831

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

Modified:
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl.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/themes/WeblogSharedTheme.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/MediaFile.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/FeedServlet.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/WeblogFeedCache.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache.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/ui/struts2/editor/Pings.java
    roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl.java?rev=1520831&r1=1520830&r2=1520831&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/jpa/JPAPingTargetManagerImpl.java
Sun Sep  8 02:55:23 2013
@@ -102,7 +102,9 @@ public class JPAPingTargetManagerImpl im
     public boolean isNameUnique(PingTarget pingTarget) 
             throws WebloggerException {
         String name = pingTarget.getName();
-        if (name == null || name.trim().length() == 0) return false;
+        if (name == null || name.trim().length() == 0) {
+            return false;
+        }
         
         String id = pingTarget.getId();
         
@@ -135,7 +137,9 @@ public class JPAPingTargetManagerImpl im
     public boolean isUrlWellFormed(PingTarget pingTarget) 
             throws WebloggerException {
         String url = pingTarget.getPingUrl();
-        if (url == null || url.trim().length() == 0) return false;
+        if (url == null || url.trim().length() == 0) {
+            return false;
+        }
         try {
             URL parsedUrl = new URL(url);
             // OK.  If we get here, it parses ok.  Now just check 
@@ -153,11 +157,15 @@ public class JPAPingTargetManagerImpl im
     public boolean isHostnameKnown(PingTarget pingTarget) 
             throws WebloggerException {
         String url = pingTarget.getPingUrl();
-        if (url == null || url.trim().length() == 0) return false;
+        if (url == null || url.trim().length() == 0) {
+            return false;
+        }
         try {
             URL parsedUrl = new URL(url);
             String host = parsedUrl.getHost();
-            if (host == null || host.trim().length() == 0) return false;
+            if (host == null || host.trim().length() == 0) {
+                return false;
+            }
             InetAddress addr = InetAddress.getByName(host);
             return true;
         } catch (MalformedURLException e) {

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=1520831&r1=1520830&r2=1520831&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
Sun Sep  8 02:55:23 2013
@@ -102,8 +102,9 @@ public class IndexManagerImpl implements
 
         // check config to see if the internal search is enabled
         String enabled = WebloggerConfig.getProperty("search.enabled");
-        if ("false".equalsIgnoreCase(enabled))
+        if ("false".equalsIgnoreCase(enabled)) {
             this.searchEnabled = false;
+        }
 
         // we also need to know what our index directory is
         // Note: system property expansion is now handled by WebloggerConfig
@@ -314,11 +315,13 @@ public class IndexManagerImpl implements
             directory = FSDirectory.open(new File(indexDir));
 
             if (delete && directory != null) {
-                String[] files = directory.listAll(); // clear old files
+                // clear old files
+                String[] files = directory.listAll();
                 for (int i = 0; i < files.length; i++) {
                     File file = new File(indexDir, files[i]);
-                    if (!file.delete())
+                    if (!file.delete()) {
                         throw new IOException("couldn't delete " + files[i]);
+                    }
                 }
             }
 
@@ -385,8 +388,9 @@ public class IndexManagerImpl implements
                     getFSDirectory(true);
                 } finally {
                     try {
-                        if (writer != null)
+                        if (writer != null) {
                             writer.close();
+                        }
                     } catch (IOException e1) {
                         mLogger.warn("Unable to close IndexWriter.");
                     }
@@ -408,8 +412,9 @@ public class IndexManagerImpl implements
         }
 
         try {
-            if (reader != null)
+            if (reader != null) {
                 reader.close();
+            }
         } catch (IOException e) {
             // won't happen, since it was
         }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/WeblogSharedTheme.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/WeblogSharedTheme.java?rev=1520831&r1=1520830&r2=1520831&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/WeblogSharedTheme.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/business/themes/WeblogSharedTheme.java
Sun Sep  8 02:55:23 2013
@@ -153,8 +153,9 @@ public class WeblogSharedTheme extends W
      */
     public ThemeTemplate getTemplateByAction(String action) throws WebloggerException {
         
-        if(action == null)
+        if (action == null) {
             return null;
+        }
         
         // NOTE: we specifically do *NOT* return templates by action from the
         // weblog's custom templates if the weblog is using a theme because we
@@ -169,14 +170,15 @@ public class WeblogSharedTheme extends W
      */
     public ThemeTemplate getTemplateByName(String name) throws WebloggerException {
         
-        if(name == null)
+        if (name == null) {
             return null;
+        }
         
         ThemeTemplate template = null;
         
         // if name refers to the stylesheet then return result of getStylesheet()
         ThemeTemplate stylesheet = getStylesheet();
-        if(stylesheet != null && name.equals(stylesheet.getName())) {
+        if (stylesheet != null && name.equals(stylesheet.getName())) {
             return stylesheet;
         }
         
@@ -185,7 +187,7 @@ public class WeblogSharedTheme extends W
         template = this.theme.getTemplateByName(name);
         
         // if we didn't get the Template from a theme then look in the db
-        if(template == null) {
+        if (template == null) {
             template = WebloggerFactory.getWeblogger().getWeblogManager().getPageByName(this.weblog,
name);
         }
         
@@ -199,8 +201,9 @@ public class WeblogSharedTheme extends W
      */
      public ThemeTemplate getTemplateByLink(String link) throws WebloggerException {
 
-        if(link == null)
+        if (link == null) {
             return null;
+        }
 
         ThemeTemplate template = null;
 
@@ -230,8 +233,9 @@ public class WeblogSharedTheme extends W
      */
     public ThemeResource getResource(String path) {
         
-        if(path == null)
+        if (path == null) {
             return null;
+        }
         
         ThemeResource resource = null;
         

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/MediaFile.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/MediaFile.java?rev=1520831&r1=1520830&r2=1520831&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/MediaFile.java (original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/pojos/MediaFile.java Sun Sep
 8 02:55:23 2013
@@ -219,13 +219,15 @@ public class MediaFile implements Serial
         Locale localeObject = getWeblog() != null ? getWeblog()
                 .getLocaleInstance() : Locale.getDefault();
         name = Utilities.normalizeTag(name, localeObject);
-        if (name.length() == 0)
+        if (name.length() == 0) {
             return;
+        }
 
         for (Iterator it = getTags().iterator(); it.hasNext();) {
             MediaFileTag tag = (MediaFileTag) it.next();
-            if (tag.getName().equals(name))
+            if (tag.getName().equals(name)) {
                 return;
+            }
         }
 
         MediaFileTag tag = new MediaFileTag();
@@ -260,8 +262,8 @@ public class MediaFile implements Serial
                 .getLocaleInstance() : Locale.getDefault();
 
         for (Iterator<String> it = updatedTags.iterator(); it.hasNext();) {
-            String name = it.next();
-            newTags.add(Utilities.normalizeTag(name, localeObject));
+            String inName = it.next();
+            newTags.add(Utilities.normalizeTag(inName, localeObject));
         }
 
         HashSet removeTags = new HashSet();
@@ -526,10 +528,12 @@ public class MediaFile implements Serial
     }
 
     public boolean equals(Object other) {
-        if (other == this)
+        if (other == this) {
             return true;
-        if (other instanceof MediaFile != true)
+        }
+        if (!(other instanceof MediaFile)) {
             return false;
+        }
         MediaFile o = (MediaFile) other;
         return new EqualsBuilder().append(getName(), o.getName())
                 .append(getDirectory(), o.getDirectory())

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/FeedServlet.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/FeedServlet.java?rev=1520831&r1=1520830&r2=1520831&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/FeedServlet.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/servlets/FeedServlet.java
Sun Sep  8 02:55:23 2013
@@ -167,17 +167,12 @@ public class FeedServlet extends HttpSer
         } else {
             log.debug("MISS "+cacheKey);
         }
-        
-        
+
         // validation.  make sure that request input makes sense.
         boolean invalid = false;
-        if(feedRequest.getLocale() != null) {
-            
-            // locale view only allowed if weblog has enabled it
-            if(!feedRequest.getWeblog().isEnableMultiLang()) {
-                invalid = true;
-            }
-            
+        if (feedRequest.getLocale() != null
+                && !feedRequest.getWeblog().isEnableMultiLang()) {
+            invalid = true;
         }
         if(feedRequest.getWeblogCategoryName() != null) {
             
@@ -198,7 +193,9 @@ public class FeedServlet extends HttpSer
         }
         
         if(invalid) {
-            if(!response.isCommitted()) response.reset();
+            if (!response.isCommitted()) {
+                response.reset();
+            }
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
@@ -234,7 +231,7 @@ public class FeedServlet extends HttpSer
 
             // define url strategy
             initData.put("urlStrategy", WebloggerFactory.getWeblogger().getUrlStrategy());
-            
+
             // Load models for feeds
             String feedModels = WebloggerConfig.getProperty("rendering.feedModels");
             ModelLoader.loadModels(feedModels, model, initData, true);
@@ -257,7 +254,9 @@ public class FeedServlet extends HttpSer
         } catch (WebloggerException ex) {
             log.error("ERROR loading model for page", ex);
 
-            if(!response.isCommitted()) response.reset();
+            if(!response.isCommitted()) {
+                response.reset();
+            }
             response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
             return;
         }
@@ -281,7 +280,9 @@ public class FeedServlet extends HttpSer
             // get this far if we expect the template to be found
             //log.error("Couldn't find renderer for page "+pageId, e);
 
-            if(!response.isCommitted()) response.reset();
+            if (!response.isCommitted()) {
+                response.reset();
+            }
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }
@@ -295,11 +296,13 @@ public class FeedServlet extends HttpSer
             // flush rendered output and close
             rendererOutput.flush();
             rendererOutput.close();
-        } catch(Exception e) {
+        } catch (Exception e) {
             // bummer, error during rendering
             log.error("Error during rendering for page "+pageId, e);
 
-            if(!response.isCommitted()) response.reset();
+            if (!response.isCommitted()) {
+                response.reset();
+            }
             response.sendError(HttpServletResponse.SC_NOT_FOUND);
             return;
         }

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=1520831&r1=1520830&r2=1520831&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
Sun Sep  8 02:55:23 2013
@@ -34,7 +34,7 @@ import org.apache.roller.weblogger.util.
 /**
  * Cache for planet content.
  */
-public class PlanetCache {
+public final class PlanetCache {
     
     private static Log log = LogFactory.getLog(PlanetCache.class);
     
@@ -52,8 +52,7 @@ public class PlanetCache {
     
     // reference to our singleton instance
     private static PlanetCache singletonInstance = new PlanetCache();
-    
-    
+
     private PlanetCache() {
         
         cacheEnabled = WebloggerConfig.getBooleanProperty(CACHE_ID+".enabled");
@@ -74,7 +73,7 @@ public class PlanetCache {
         
         log.info("Planet cache = "+cacheProps);
         
-        if(cacheEnabled) {
+        if (cacheEnabled) {
             contentCache = CacheManager.constructCache(null, cacheProps);
         } else {
             log.warn("Caching has been DISABLED");
@@ -98,8 +97,9 @@ public class PlanetCache {
     
     public Object get(String key) {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return null;
+        }
         
         Object entry = contentCache.get(key);
         
@@ -115,8 +115,9 @@ public class PlanetCache {
     
     public void put(String key, Object value) {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return;
+        }
         
         contentCache.put(key, value);
         log.debug("PUT "+key);
@@ -125,8 +126,9 @@ public class PlanetCache {
     
     public void remove(String key) {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return;
+        }
         
         contentCache.remove(key);
         log.debug("REMOVE "+key);
@@ -135,8 +137,9 @@ public class PlanetCache {
     
     public void clear() {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return;
+        }
         
         contentCache.clear();
         this.lastUpdateTime = null;

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogFeedCache.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogFeedCache.java?rev=1520831&r1=1520830&r2=1520831&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogFeedCache.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogFeedCache.java
Sun Sep  8 02:55:23 2013
@@ -38,7 +38,7 @@ import org.apache.roller.weblogger.util.
 /**
  * Cache for weblog feed content.
  */
-public class WeblogFeedCache {
+public final class WeblogFeedCache {
     
     private static Log log = LogFactory.getLog(WeblogFeedCache.class);
     
@@ -89,8 +89,9 @@ public class WeblogFeedCache {
     
     public Object get(String key, long lastModified) {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return null;
+        }
         
         Object entry = null;
         
@@ -115,8 +116,9 @@ public class WeblogFeedCache {
     
     public void put(String key, Object value) {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return;
+        }
         
         contentCache.put(key, new LazyExpiringCacheEntry(value));
         log.debug("PUT "+key);
@@ -125,8 +127,9 @@ public class WeblogFeedCache {
     
     public void remove(String key) {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return;
+        }
         
         contentCache.remove(key);
         log.debug("REMOVE "+key);
@@ -135,8 +138,9 @@ public class WeblogFeedCache {
     
     public void clear() {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return;
+        }
         
         contentCache.clear();
         log.debug("CLEAR");

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache.java?rev=1520831&r1=1520830&r2=1520831&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/rendering/util/cache/WeblogPageCache.java
Sun Sep  8 02:55:23 2013
@@ -39,7 +39,7 @@ import org.apache.roller.weblogger.util.
 /**
  * Cache for weblog page content.
  */
-public class WeblogPageCache {
+public final class WeblogPageCache {
     
     private static Log log = LogFactory.getLog(WeblogPageCache.class);
     
@@ -75,7 +75,7 @@ public class WeblogPageCache {
         
         log.info(cacheProps);
         
-        if(cacheEnabled) {
+        if (cacheEnabled) {
             contentCache = CacheManager.constructCache(null, cacheProps);
         } else {
             log.warn("Caching has been DISABLED");
@@ -90,8 +90,9 @@ public class WeblogPageCache {
     
     public Object get(String key, long lastModified) {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return null;
+        }
         
         Object entry = null;
         
@@ -116,8 +117,9 @@ public class WeblogPageCache {
     
     public void put(String key, Object value) {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return;
+        }
         
         contentCache.put(key, new LazyExpiringCacheEntry(value));
         log.debug("PUT "+key);
@@ -126,8 +128,9 @@ public class WeblogPageCache {
     
     public void remove(String key) {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return;
+        }
         
         contentCache.remove(key);
         log.debug("REMOVE "+key);
@@ -136,8 +139,9 @@ public class WeblogPageCache {
     
     public void clear() {
         
-        if(!cacheEnabled)
+        if (!cacheEnabled) {
             return;
+        }
         
         contentCache.clear();
         log.debug("CLEAR");
@@ -241,7 +245,7 @@ public class WeblogPageCache {
     
     private String paramsToString(Map map) {
         
-        if(map == null) {
+        if (map == null) {
             return null;
         }
         
@@ -250,7 +254,7 @@ public class WeblogPageCache {
         String key = null;
         String[] value = null;
         Iterator keys = map.keySet().iterator();
-        while(keys.hasNext()) {
+        while (keys.hasNext()) {
             key = (String) keys.next();
             value = (String[]) map.get(key);
             

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=1520831&r1=1520830&r2=1520831&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
Sun Sep  8 02:55:23 2013
@@ -77,8 +77,9 @@ public class WebappResourceLoader extend
 	 */
 	public void init(ExtendedProperties configuration) {
 
-		if (log.isDebugEnabled())
+		if (log.isDebugEnabled()) {
 			log.debug("WebappResourceLoader: initialization starting.");
+        }
 
 		// get configured paths
 		paths = configuration.getStringArray("path");
@@ -91,24 +92,27 @@ public class WebappResourceLoader extend
 				if (!paths[i].endsWith("/")) {
 					paths[i] += '/';
 				}
-				if (log.isDebugEnabled())
-					log.debug("WebappResourceLoader: added template path - '"
-							+ paths[i] + "'");
+				if (log.isDebugEnabled()) {
+                    log.debug("WebappResourceLoader: added template path - '"
+                            + paths[i] + "'");
+                }
 			}
 		}
 
 		// get the ServletContext
 		servletContext = RollerContext.getServletContext();
 
-		if (log.isDebugEnabled())
+		if (log.isDebugEnabled()) {
 			log.debug("Servlet Context = "
 					+ servletContext.getRealPath("/WEB-INF/velocity/"));
+        }
 
 		// init the template paths map
 		templatePaths = new HashMap<String, String>();
 
-		if (log.isDebugEnabled())
-			log.debug("WebappResourceLoader: initialization complete.");
+		if (log.isDebugEnabled()) {
+            log.debug("WebappResourceLoader: initialization complete.");
+        }
 	}
 
 	/**

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Pings.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Pings.java?rev=1520831&r1=1520830&r2=1520831&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Pings.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/Pings.java
Sun Sep  8 02:55:23 2013
@@ -82,10 +82,12 @@ public class Pings extends UIAction {
         PingTargetManager pingTargetMgr = WebloggerFactory.getWeblogger().getPingTargetManager();
         
         // load selected ping target, if possible
-        if(getPingTargetId() != null) try {
-            setPingTarget(pingTargetMgr.getPingTarget(getPingTargetId()));
-        } catch (WebloggerException ex) {
-            log.error("Error looking up ping target - "+getPingTargetId(), ex);
+        if(getPingTargetId() != null) {
+            try {
+                setPingTarget(pingTargetMgr.getPingTarget(getPingTargetId()));
+            } catch (WebloggerException ex) {
+                log.error("Error looking up ping target - "+getPingTargetId(), ex);
+            }
         }
         
         try {
@@ -122,15 +124,17 @@ public class Pings extends UIAction {
      */
     public String enable() {
         
-        if(getPingTarget() != null) try {
-            AutoPingManager autoPingMgr = WebloggerFactory.getWeblogger().getAutopingManager();
-            AutoPing autoPing = new AutoPing(null, getPingTarget(), getActionWeblog());
-            autoPingMgr.saveAutoPing(autoPing);
-            WebloggerFactory.getWeblogger().flush();
-        } catch(Exception ex) {
-            log.error("Error saving auto ping for target - "+getPingTargetId(), ex);
-            // TODO: i18n
-            addError("Error enabling auto ping");
+        if(getPingTarget() != null) {
+            try {
+                AutoPingManager autoPingMgr = WebloggerFactory.getWeblogger().getAutopingManager();
+                AutoPing autoPing = new AutoPing(null, getPingTarget(), getActionWeblog());
+                autoPingMgr.saveAutoPing(autoPing);
+                WebloggerFactory.getWeblogger().flush();
+            } catch(Exception ex) {
+                log.error("Error saving auto ping for target - "+getPingTargetId(), ex);
+                // TODO: i18n
+                addError("Error enabling auto ping");
+            }
         }
         
         return execute();
@@ -142,14 +146,16 @@ public class Pings extends UIAction {
      */
     public String disable() {
         
-        if(getPingTarget() != null) try {
-            AutoPingManager autoPingMgr = WebloggerFactory.getWeblogger().getAutopingManager();
-            autoPingMgr.removeAutoPing(getPingTarget(), getActionWeblog());
-            WebloggerFactory.getWeblogger().flush();
-        } catch (Exception ex) {
-            log.error("Error removing auto ping for target - "+getPingTargetId(), ex);
-            // TODO: i18n
-            addError("Error disabling auto ping");
+        if(getPingTarget() != null) {
+            try {
+                AutoPingManager autoPingMgr = WebloggerFactory.getWeblogger().getAutopingManager();
+                autoPingMgr.removeAutoPing(getPingTarget(), getActionWeblog());
+                WebloggerFactory.getWeblogger().flush();
+            } catch (Exception ex) {
+                log.error("Error removing auto ping for target - "+getPingTargetId(), ex);
+                // TODO: i18n
+                addError("Error disabling auto ping");
+            }
         }
         
         return execute();
@@ -161,32 +167,34 @@ public class Pings extends UIAction {
      */
     public String pingNow() {
         
-        if(getPingTarget() != null) try {
-            if (PingConfig.getSuspendPingProcessing()) {
-                log.debug("Ping processing is disabled.");
-                addError("ping.pingProcessingIsSuspended");
-            } else {
-                WeblogUpdatePinger.PingResult pingResult = WeblogUpdatePinger.sendPing(getPingTarget(),
getActionWeblog());
-                if (pingResult.isError()) {
-                    log.debug("Ping Result: " + pingResult);
-                    if (pingResult.getMessage() != null && pingResult.getMessage().trim().length()
> 0) {
-                        addError("ping.transmittedButError");
-                        addError(pingResult.getMessage());
+        if(getPingTarget() != null) {
+            try {
+                if (PingConfig.getSuspendPingProcessing()) {
+                    log.debug("Ping processing is disabled.");
+                    addError("ping.pingProcessingIsSuspended");
+                } else {
+                    WeblogUpdatePinger.PingResult pingResult = WeblogUpdatePinger.sendPing(getPingTarget(),
getActionWeblog());
+                    if (pingResult.isError()) {
+                        log.debug("Ping Result: " + pingResult);
+                        if (pingResult.getMessage() != null && pingResult.getMessage().trim().length()
> 0) {
+                            addError("ping.transmittedButError");
+                            addError(pingResult.getMessage());
+                        } else {
+                            addError("ping.transmissionFailed");
+                        }
                     } else {
-                        addError("ping.transmissionFailed");
+                        addMessage("ping.successful");
                     }
-                } else {
-                    addMessage("ping.successful");
                 }
+            } catch (IOException ex) {
+                log.debug(ex);
+                addError("ping.transmissionFailed");
+                addSpecificMessages(ex);
+            } catch (XmlRpcException ex) {
+                log.debug(ex);
+                addError("ping.transmissionFailed");
+                addSpecificMessages(ex);
             }
-        } catch (IOException ex) {
-            log.debug(ex);
-            addError("ping.transmissionFailed");
-            addSpecificMessages(ex);
-        } catch (XmlRpcException ex) {
-            log.debug(ex);
-            addError("ping.transmissionFailed");
-            addSpecificMessages(ex);
         }
         
         return execute();
@@ -230,21 +238,21 @@ public class Pings extends UIAction {
         // Somewhat awkward, but the two loops save building a separate combined list.
         // Add disabled common ones with FALSE
         for (Iterator i = getCommonPingTargets().iterator(); i.hasNext();) {
-            PingTarget pingTarget = (PingTarget) i.next();
-            if (isEnabled.get(pingTarget.getId()) == null) {
-                isEnabled.put(pingTarget.getId(), Boolean.FALSE);
+            PingTarget inPingTarget = (PingTarget) i.next();
+            if (isEnabled.get(inPingTarget.getId()) == null) {
+                isEnabled.put(inPingTarget.getId(), Boolean.FALSE);
             }
         }
         
         // Add disabled custom ones with FALSE
         for (Iterator i = getCustomPingTargets().iterator(); i.hasNext();) {
-            PingTarget pingTarget = (PingTarget) i.next();
-            if (isEnabled.get(pingTarget.getId()) == null) {
-                isEnabled.put(pingTarget.getId(), Boolean.FALSE);
+            PingTarget inPingTarget = (PingTarget) i.next();
+            if (isEnabled.get(inPingTarget.getId()) == null) {
+                isEnabled.put(inPingTarget.getId(), Boolean.FALSE);
             }
         }
         
-        if(isEnabled.size() > 0) {
+        if (isEnabled.size() > 0) {
             setPingStatus(isEnabled);
         }
     }

Modified: roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java
URL: http://svn.apache.org/viewvc/roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java?rev=1520831&r1=1520830&r2=1520831&view=diff
==============================================================================
--- roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java
(original)
+++ roller/trunk/app/src/main/java/org/apache/roller/weblogger/ui/struts2/editor/StylesheetEdit.java
Sun Sep  8 02:55:23 2013
@@ -47,6 +47,8 @@ public class StylesheetEdit extends UIAc
 	private static final long serialVersionUID = 4657591015852311907L;
 
 	private static Log log = LogFactory.getLog(StylesheetEdit.class);
+    private static final String MOBILE_THEME_TYPE = "mobile";
+    private static final String STANDARD_THEME_TYPE = "standard";
 
 	// the template we are working on
 	private WeblogTemplate template = null;
@@ -105,14 +107,14 @@ public class StylesheetEdit extends UIAc
 
 					// create template codes for available template code Types
 					WeblogThemeTemplateCode standardTemplateCode = new WeblogThemeTemplateCode(
-							stylesheetTmpl.getId(), "standard");
+							stylesheetTmpl.getId(), STANDARD_THEME_TYPE);
 					standardTemplateCode.setTemplate(stylesheetTmpl
 							.getContents());
 					standardTemplateCode.setTemplateLanguage(stylesheetTmpl
 							.getTemplateLanguage());
 
 					WeblogThemeTemplateCode mobileTemplateCode = new WeblogThemeTemplateCode(
-							stylesheetTmpl.getId(), "mobile");
+							stylesheetTmpl.getId(), MOBILE_THEME_TYPE);
 					mobileTemplateCode
 							.setTemplate(stylesheetTmpl.getContents());
 					mobileTemplateCode.setTemplateLanguage(stylesheetTmpl
@@ -167,20 +169,21 @@ public class StylesheetEdit extends UIAc
 
 		try {
 
-			if (getTemplate().getTemplateCode("standard") != null) {
-				setContentsStandard(getTemplate().getTemplateCode("standard")
+			if (getTemplate().getTemplateCode(STANDARD_THEME_TYPE) != null) {
+				setContentsStandard(getTemplate().getTemplateCode(STANDARD_THEME_TYPE)
 						.getTemplate());
 			} else {
 				setContentsStandard(getTemplate().getContents());
 			}
-			if (getTemplate().getTemplateCode("mobile") != null) {
-				setContentsMobile(getTemplate().getTemplateCode("mobile")
+			if (getTemplate().getTemplateCode(MOBILE_THEME_TYPE) != null) {
+				setContentsMobile(getTemplate().getTemplateCode(MOBILE_THEME_TYPE)
 						.getTemplate());
 			}
 
-			if (log.isDebugEnabled())
-				log.debug("Standard: " + getContentsStandard() + " Mobile: "
-						+ getContentsMobile());
+			if (log.isDebugEnabled()) {
+                log.debug("Standard: " + getContentsStandard() + " Mobile: "
+                        + getContentsMobile());
+            }
 
 		} catch (WebloggerException e) {
 			log.error("Error loading Weblog template codes for stylesheet", e);
@@ -200,63 +203,64 @@ public class StylesheetEdit extends UIAc
 			return ERROR;
 		}
 
-		if (!hasActionErrors())
-			try {
-
-				WeblogTemplate stylesheet = getTemplate();
-
-				stylesheet.setLastModified(new Date());
-
-				if (stylesheet.getTemplateCode("standard") != null) {
-					// if we have a template, then set it
-					WeblogThemeTemplateCode tc = stylesheet
-							.getTemplateCode("standard");
-					tc.setTemplate(getContentsStandard());
-					WebloggerFactory.getWeblogger().getWeblogManager()
-							.saveTemplateCode(tc);
-				} else {
-					// otherwise create it, then set it
-					WeblogThemeTemplateCode tc = new WeblogThemeTemplateCode(
-							stylesheet.getId(), "standard");
-					tc.setTemplate(stylesheet.getContents());
-					WebloggerFactory.getWeblogger().getWeblogManager()
-							.saveTemplateCode(tc);
-				}
-
-				if (stylesheet.getTemplateCode("mobile") != null) {
-					WeblogThemeTemplateCode tc = stylesheet
-							.getTemplateCode("mobile");
-					tc.setTemplate(getContentsMobile());
-				} else {
-					WeblogThemeTemplateCode tc = new WeblogThemeTemplateCode(
-							stylesheet.getId(), "mobile");
-					tc.setTemplate(""); // empty, we've got no default mobile
-										// template
-					WebloggerFactory.getWeblogger().getWeblogManager()
-							.saveTemplateCode(tc);
-				}
-
-				// TODO do we still want to set the contents here?
-				stylesheet.setContents(getContentsStandard());
-
-				// save template and flush
-				WebloggerFactory.getWeblogger().getWeblogManager()
-						.savePage(stylesheet);
-
-				WebloggerFactory.getWeblogger().flush();
+		if (!hasActionErrors()) {
+            try {
 
-				// notify caches
-				CacheManager.invalidate(stylesheet);
+                WeblogTemplate stylesheet = getTemplate();
 
-				// success message
-				addMessage("stylesheetEdit.save.success", stylesheet.getName());
+                stylesheet.setLastModified(new Date());
 
-			} catch (WebloggerException ex) {
-				log.error("Error updating stylesheet template for weblog - "
-						+ getActionWeblog().getHandle(), ex);
-				// TODO: i18n
-				addError("Error saving template");
-			}
+                if (stylesheet.getTemplateCode(STANDARD_THEME_TYPE) != null) {
+                    // if we have a template, then set it
+                    WeblogThemeTemplateCode tc = stylesheet
+                            .getTemplateCode(STANDARD_THEME_TYPE);
+                    tc.setTemplate(getContentsStandard());
+                    WebloggerFactory.getWeblogger().getWeblogManager()
+                            .saveTemplateCode(tc);
+                } else {
+                    // otherwise create it, then set it
+                    WeblogThemeTemplateCode tc = new WeblogThemeTemplateCode(
+                            stylesheet.getId(), STANDARD_THEME_TYPE);
+                    tc.setTemplate(stylesheet.getContents());
+                    WebloggerFactory.getWeblogger().getWeblogManager()
+                            .saveTemplateCode(tc);
+                }
+
+                if (stylesheet.getTemplateCode(MOBILE_THEME_TYPE) != null) {
+                    WeblogThemeTemplateCode tc = stylesheet
+                            .getTemplateCode(MOBILE_THEME_TYPE);
+                    tc.setTemplate(getContentsMobile());
+                } else {
+                    WeblogThemeTemplateCode tc = new WeblogThemeTemplateCode(
+                            stylesheet.getId(), MOBILE_THEME_TYPE);
+                    // empty, we've got no default mobile template
+                    tc.setTemplate("");
+                    WebloggerFactory.getWeblogger().getWeblogManager()
+                            .saveTemplateCode(tc);
+                }
+
+                // TODO do we still want to set the contents here?
+                stylesheet.setContents(getContentsStandard());
+
+                // save template and flush
+                WebloggerFactory.getWeblogger().getWeblogManager()
+                        .savePage(stylesheet);
+
+                WebloggerFactory.getWeblogger().flush();
+
+                // notify caches
+                CacheManager.invalidate(stylesheet);
+
+                // success message
+                addMessage("stylesheetEdit.save.success", stylesheet.getName());
+
+            } catch (WebloggerException ex) {
+                log.error("Error updating stylesheet template for weblog - "
+                        + getActionWeblog().getHandle(), ex);
+                // TODO: i18n
+                addError("Error saving template");
+            }
+        }
 
 		return INPUT;
 	}
@@ -279,59 +283,60 @@ public class StylesheetEdit extends UIAc
 			addError("stylesheetEdit.error.customTheme");
 		}
 
-		if (!hasActionErrors())
-			try {
+		if (!hasActionErrors()) {
+            try {
 
-				WeblogTemplate stylesheet = getTemplate();
+                WeblogTemplate stylesheet = getTemplate();
 
-				// lookup the theme used by this weblog
-				ThemeManager tmgr = WebloggerFactory.getWeblogger()
-						.getThemeManager();
-				Theme theme = tmgr.getTheme(getActionWeblog().getEditorTheme());
-
-				stylesheet.setLastModified(new Date());
-
-				if (stylesheet.getTemplateCode("standard") != null) {
-					TemplateCode templateCode = theme.getStylesheet()
-							.getTemplateCode("standard");
-					// if we have a template, then set it
-					WeblogThemeTemplateCode existingTemplateCode = stylesheet
-							.getTemplateCode("standard");
-					existingTemplateCode
-							.setTemplate(templateCode.getTemplate());
-					WebloggerFactory.getWeblogger().getWeblogManager()
-							.saveTemplateCode(existingTemplateCode);
-
-					// TODO do we still want to set the contents here?
-					stylesheet.setContents(templateCode.getTemplate());
-				}
-				if (stylesheet.getTemplateCode("mobile") != null) {
-					TemplateCode templateCode = theme.getStylesheet()
-							.getTemplateCode("mobile");
-					WeblogThemeTemplateCode existingTemplateCode = stylesheet
-							.getTemplateCode("mobile");
-					existingTemplateCode
-							.setTemplate(templateCode.getTemplate());
-				}
-
-				// save template and flush
-				WebloggerFactory.getWeblogger().getWeblogManager()
-						.savePage(stylesheet);
-				WebloggerFactory.getWeblogger().flush();
-
-				// notify caches
-				CacheManager.invalidate(stylesheet);
-
-				// success message
-				addMessage("stylesheetEdit.revert.success",
-						stylesheet.getName());
-
-			} catch (WebloggerException ex) {
-				log.error("Error updating stylesheet template for weblog - "
-						+ getActionWeblog().getHandle(), ex);
-				// TODO: i18n
-				addError("Error saving template");
-			}
+                // lookup the theme used by this weblog
+                ThemeManager tmgr = WebloggerFactory.getWeblogger()
+                        .getThemeManager();
+                Theme theme = tmgr.getTheme(getActionWeblog().getEditorTheme());
+
+                stylesheet.setLastModified(new Date());
+
+                if (stylesheet.getTemplateCode(STANDARD_THEME_TYPE) != null) {
+                    TemplateCode templateCode = theme.getStylesheet()
+                            .getTemplateCode(STANDARD_THEME_TYPE);
+                    // if we have a template, then set it
+                    WeblogThemeTemplateCode existingTemplateCode = stylesheet
+                            .getTemplateCode(STANDARD_THEME_TYPE);
+                    existingTemplateCode
+                            .setTemplate(templateCode.getTemplate());
+                    WebloggerFactory.getWeblogger().getWeblogManager()
+                            .saveTemplateCode(existingTemplateCode);
+
+                    // TODO do we still want to set the contents here?
+                    stylesheet.setContents(templateCode.getTemplate());
+                }
+                if (stylesheet.getTemplateCode(MOBILE_THEME_TYPE) != null) {
+                    TemplateCode templateCode = theme.getStylesheet()
+                            .getTemplateCode(MOBILE_THEME_TYPE);
+                    WeblogThemeTemplateCode existingTemplateCode = stylesheet
+                            .getTemplateCode(MOBILE_THEME_TYPE);
+                    existingTemplateCode
+                            .setTemplate(templateCode.getTemplate());
+                }
+
+                // save template and flush
+                WebloggerFactory.getWeblogger().getWeblogManager()
+                        .savePage(stylesheet);
+                WebloggerFactory.getWeblogger().flush();
+
+                // notify caches
+                CacheManager.invalidate(stylesheet);
+
+                // success message
+                addMessage("stylesheetEdit.revert.success",
+                        stylesheet.getName());
+
+            } catch (WebloggerException ex) {
+                log.error("Error updating stylesheet template for weblog - "
+                        + getActionWeblog().getHandle(), ex);
+                // TODO: i18n
+                addError("Error saving template");
+            }
+        }
 
 		return execute();
 	}
@@ -354,42 +359,43 @@ public class StylesheetEdit extends UIAc
 			addError("stylesheetEdit.error.customTheme");
 		}
 
-		if (!hasActionErrors())
-			try {
+		if (!hasActionErrors()) {
+            try {
 
-				WeblogTemplate stylesheet = getTemplate();
+                WeblogTemplate stylesheet = getTemplate();
 
-				// Delete template and flush
-				WeblogManager mgr = WebloggerFactory.getWeblogger()
-						.getWeblogManager();
+                // Delete template and flush
+                WeblogManager mgr = WebloggerFactory.getWeblogger()
+                        .getWeblogManager();
 
-				// Remove template and page codes
-				mgr.removePage(stylesheet);
+                // Remove template and page codes
+                mgr.removePage(stylesheet);
 
-				Weblog weblog = getActionWeblog();
+                Weblog weblog = getActionWeblog();
 
-				// Clear for next custom theme
-				weblog.setCustomStylesheetPath(null);
+                // Clear for next custom theme
+                weblog.setCustomStylesheetPath(null);
 
-				// save updated weblog and flush
-				mgr.saveWeblog(weblog);
+                // save updated weblog and flush
+                mgr.saveWeblog(weblog);
 
-				// notify caches
-				CacheManager.invalidate(stylesheet);
+                // notify caches
+                CacheManager.invalidate(stylesheet);
 
-				// Flush for operation
-				WebloggerFactory.getWeblogger().flush();
+                // Flush for operation
+                WebloggerFactory.getWeblogger().flush();
 
-				// success message
-				addMessage("stylesheetEdit.default.success",
-						stylesheet.getName());
+                // success message
+                addMessage("stylesheetEdit.default.success",
+                        stylesheet.getName());
 
-			} catch (Exception e) {
-				log.error("Error deleting stylesheet template for weblog - "
-						+ getActionWeblog().getHandle(), e);
+            } catch (Exception e) {
+                log.error("Error deleting stylesheet template for weblog - "
+                        + getActionWeblog().getHandle(), e);
 
-				return ERROR;
-			}
+                return ERROR;
+            }
+        }
 
 		return "delete";
 



Mime
View raw message