Author: mbrohl
Date: Sun Dec 10 11:08:58 2017
New Revision: 1817694

URL: http://svn.apache.org/viewvc?rev=1817694&view=rev
Log:
Improved: Fixing defects reported by FindBugs, package 
org.apache.ofbiz.content.cms.
(OFBIZ-9824)

The patch was modified to optimize the logging.

Thanks Dennis Balkir for reporting and providing the patch.

Modified:
    
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java
    
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java

Modified: 
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java?rev=1817694&r1=1817693&r2=1817694&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/CmsEvents.java
 Sun Dec 10 11:08:58 2017
@@ -117,9 +117,9 @@ public class CmsEvents {
             } catch (GenericEntityException e) {
                 Debug.logError(e, module);
             } catch (IOException e) {
-                throw new GeneralRuntimeException(String.format("Error in the 
response writer/output stream while rendering content [%s]", contentId), e);
+                throw new GeneralRuntimeException("Error in the response 
writer/output stream while rendering content.", e);
             } catch (GeneralException e) {
-                throw new GeneralRuntimeException(String.format("Error 
rendering content [%s]", contentId), e);
+                throw new GeneralRuntimeException("Error rendering content", 
e);
             } 
         } else {
         // If an override view is present then use that in place of 
request.getPathInfo()
@@ -326,7 +326,7 @@ public class CmsEvents {
                     if (content != null && 
UtilValidate.isNotEmpty(content.getString("contentName"))) {
                         contentName = content.getString("contentName");
                     } else {
-                        request.setAttribute("_ERROR_MESSAGE_", "Content: " + 
contentName + " [" + contentId + "] is not a publish point for the current 
website: [" + webSiteId + "]");
+                        request.setAttribute("_ERROR_MESSAGE_", "Content: [" + 
contentId + "] is not a publish point for the current website: [" + webSiteId + 
"]");
                         return "error";
                     }
                     siteName = 
EntityQuery.use(delegator).from("WebSite").where("webSiteId", 
webSiteId).cache().queryOne().getString("siteName");

Modified: 
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java
URL: 
http://svn.apache.org/viewvc/ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java?rev=1817694&r1=1817693&r2=1817694&view=diff
==============================================================================
--- 
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java
 (original)
+++ 
ofbiz/ofbiz-framework/trunk/applications/content/src/main/java/org/apache/ofbiz/content/cms/ContentJsonEvents.java
 Sun Dec 10 11:08:58 2017
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import java.util.concurrent.Callable;
 
@@ -80,7 +81,7 @@ public class ContentJsonEvents {
                     return 0;
                 }
 
-                return title1.toLowerCase().compareTo(title2.toLowerCase());
+                return 
title1.toLowerCase(Locale.getDefault()).compareTo(title2.toLowerCase(Locale.getDefault()));
             }
 
         });
@@ -188,7 +189,7 @@ public class ContentJsonEvents {
 
         Map<String, Object> node = UtilMisc.toMap("data", (Object) data, 
"attr", (Object) attr);
 
-        List<GenericValue> assocChildren  = 
content.getRelated("FromContentAssoc", null, null, true);
+        List<GenericValue> assocChildren  = content != null ? 
content.getRelated("FromContentAssoc", null, null, true) : null;
         assocChildren = EntityUtil.filterByDate(assocChildren);
         if (!CollectionUtils.isEmpty(assocChildren)) {
             node.put("state", "closed");


Reply via email to