svn commit: r1818845 - in /ofbiz/ofbiz-plugins/trunk: bi/src/main/java/org/apache/ofbiz/bi/util/ birt/src/main/java/org/apache/ofbiz/birt/ birt/src/main/java/org/apache/ofbiz/birt/container/

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1818845 - in /ofbiz/ofbiz-plugins/trunk: bi/src/main/java/org/apache/ofbiz/bi/util/ birt/src/main/java/org/apache/ofbiz/birt/ birt/src/main/java/org/apache/ofbiz/birt/container/

mbrohl
Author: mbrohl
Date: Wed Dec 20 19:45:02 2017
New Revision: 1818845

URL: http://svn.apache.org/viewvc?rev=1818845&view=rev
Log:
Improved: Fixing defects reported by code analysis tools, package
org.apache.ofbiz -bi.util, -birt and -birt.container.
(OFBIZ-10102)

Thanks Julian Leichert for reporting and providing the patch.

Modified:
    ofbiz/ofbiz-plugins/trunk/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java
    ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/BirtFactory.java
    ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java
    ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java

Modified: ofbiz/ofbiz-plugins/trunk/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java?rev=1818845&r1=1818844&r2=1818845&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java (original)
+++ ofbiz/ofbiz-plugins/trunk/bi/src/main/java/org/apache/ofbiz/bi/util/DimensionServices.java Wed Dec 20 19:45:02 2017
@@ -70,7 +70,7 @@ public class DimensionServices {
         Locale locale = (Locale) context.get("locale");
 
         try {
-            Map<String, Object> andCondition = new HashMap<String, Object>();
+            Map<String, Object> andCondition = new HashMap<>();
             for (String naturalKeyField: naturalKeyFields) {
                 andCondition.put(naturalKeyField, dimensionValue.get(naturalKeyField));
             }
@@ -149,14 +149,14 @@ public class DimensionServices {
             dateValue.set("description", dayDescriptionFormat.format(currentDate));
             int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
             dateValue.set("dayName", dayNameFormat.format(currentDate));
-            dateValue.set("dayOfMonth", new Long(calendar.get(Calendar.DAY_OF_MONTH)));
-            dateValue.set("dayOfYear", new Long(calendar.get(Calendar.DAY_OF_YEAR)));
+            dateValue.set("dayOfMonth", Long.valueOf(calendar.get(Calendar.DAY_OF_MONTH)));
+            dateValue.set("dayOfYear", Long.valueOf(calendar.get(Calendar.DAY_OF_YEAR)));
             dateValue.set("monthName", monthNameFormat.format(currentDate));
 
-            dateValue.set("monthOfYear", new Long(calendar.get(Calendar.MONTH) + 1));
-            dateValue.set("yearName", new Long(calendar.get(Calendar.YEAR)));
-            dateValue.set("weekOfMonth", new Long(calendar.get(Calendar.WEEK_OF_MONTH)));
-            dateValue.set("weekOfYear", new Long(calendar.get(Calendar.WEEK_OF_YEAR)));
+            dateValue.set("monthOfYear", Long.valueOf(calendar.get(Calendar.MONTH) + 1));
+            dateValue.set("yearName", Long.valueOf(calendar.get(Calendar.YEAR)));
+            dateValue.set("weekOfMonth", Long.valueOf(calendar.get(Calendar.WEEK_OF_MONTH)));
+            dateValue.set("weekOfYear", Long.valueOf(calendar.get(Calendar.WEEK_OF_YEAR)));
             dateValue.set("weekdayType", (dayOfWeek == 1 || dayOfWeek == 7? "Weekend": "Weekday"));
             dateValue.set("yearMonthDay", yearMonthDayFormat.format(currentDate));
             dateValue.set("yearAndMonth", yearMonthFormat.format(currentDate));

Modified: ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/BirtFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/BirtFactory.java?rev=1818845&r1=1818844&r2=1818845&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/BirtFactory.java (original)
+++ ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/BirtFactory.java Wed Dec 20 19:45:02 2017
@@ -39,8 +39,8 @@ public class BirtFactory {
 
     public final static String module = BirtFactory.class.getName();
 
-    protected static IReportEngine engine;
-    
+    private static IReportEngine engine;
+
     /**
      * set report engine
      * @param engine

Modified: ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java?rev=1818845&r1=1818844&r2=1818845&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java (original)
+++ ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/BirtWorker.java Wed Dec 20 19:45:02 2017
@@ -19,9 +19,7 @@
 package org.apache.ofbiz.birt;
 
 import java.io.File;
-import java.io.IOException;
 import java.io.OutputStream;
-import java.io.StringWriter;
 import java.sql.SQLException;
 import java.util.HashMap;
 import java.util.List;
@@ -77,7 +75,7 @@ public final class BirtWorker {
 
     private BirtWorker() {}
 
-    public static final Map<Integer, Level> levelIntMap = new HashMap<>();
+    private static final Map<Integer, Level> levelIntMap = new HashMap<>();
     static {
         levelIntMap.put(Debug.ERROR, Level.SEVERE);
         levelIntMap.put(Debug.TIMING, Level.FINE);
@@ -108,7 +106,7 @@ public final class BirtWorker {
         if (contentType == null) {
             contentType = "text/html";
         } else {
-            contentType = contentType.toLowerCase();
+            contentType = contentType.toLowerCase(Locale.getDefault());
         }
         if (birtImageDirectory == null) {
             birtImageDirectory = "/";
@@ -209,7 +207,6 @@ public final class BirtWorker {
         Locale locale = (Locale) context.get("locale");
         String description = (String) context.get("description");
         String reportName = (String) context.get("reportName");
-        String writeFilters = (String) context.get("writeFilters");
         GenericValue userLogin = (GenericValue) context.get("userLogin");
         String entityViewName = (String) context.get("entityViewName");
         String serviceName = (String) context.get("serviceName");
@@ -241,7 +238,7 @@ public final class BirtWorker {
             if (!templatePathLocationDir.exists()) {
                 boolean created = templatePathLocationDir.mkdirs();
                 if (!created) {
-                    new GeneralException(UtilProperties.getMessage(resourceError, "BirtErrorCannotLocateReportFolder", locale));
+                    throw new GeneralException(UtilProperties.getMessage(resourceError, "BirtErrorCannotLocateReportFolder", locale));
                 }
             }
         int i = 0;
@@ -261,7 +258,7 @@ public final class BirtWorker {
         //resolve the initial form structure from master content
         Map<String, Object> resultElectronicText = dispatcher.runSync("getElectronicText", UtilMisc.toMap("contentId", masterContentId, "locale", locale, "userLogin", userLogin));
         if (ServiceUtil.isError(resultElectronicText)) {
-            new GeneralException(ServiceUtil.getErrorMessage(resultElectronicText));
+            throw new GeneralException(ServiceUtil.getErrorMessage(resultElectronicText));
         }
         String reportForm = (String) resultElectronicText.get("textData");
         if (!reportForm.startsWith("<?xml")) {

Modified: ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java
URL: http://svn.apache.org/viewvc/ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java?rev=1818845&r1=1818844&r2=1818845&view=diff
==============================================================================
--- ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java (original)
+++ ofbiz/ofbiz-plugins/trunk/birt/src/main/java/org/apache/ofbiz/birt/container/BirtContainer.java Wed Dec 20 19:45:02 2017
@@ -38,7 +38,7 @@ import org.apache.ofbiz.birt.BirtWorker;
 public class BirtContainer implements Container {
 
     public static final String module = BirtContainer.class.getName();
-    
+
     protected String configFile;
 
     private String name;
@@ -60,11 +60,6 @@ public class BirtContainer implements Co
         if (getName() == null) {
             throw new ContainerException("Unknown container config name");
         }
-        // get the container config
-        ContainerConfig.Configuration cc = ContainerConfig.getConfiguration(getName(), configFile);
-        if (cc == null) {
-            throw new ContainerException("No " + getName() + " configuration found in container config!");
-        }
 
         // create engine config
         EngineConfig config = new EngineConfig();
@@ -95,7 +90,7 @@ public class BirtContainer implements Co
         Debug.logInfo("Create report engine", module);
         IReportEngine engine = factory.createReportEngine(config);
         BirtFactory.setReportEngine(engine);
-        
+
         // print supported formats
         String[] supportedFormats = engine.getSupportedFormats();
         String formatList = null;