struts-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lukaszlen...@apache.org
Subject [struts] 01/01: WW-5099 Upgrades JFreeChart to version 1.5.1
Date Sun, 03 Jan 2021 09:15:20 GMT
This is an automated email from the ASF dual-hosted git repository.

lukaszlenart pushed a commit to branch WW-5099-upgrade-jfreechart
in repository https://gitbox.apache.org/repos/asf/struts.git

commit 22ee49151b68b201e67f0ea7192251b43fc18089
Author: Lukasz Lenart <lukaszlenart@apache.org>
AuthorDate: Sun Jan 3 10:15:09 2021 +0100

    WW-5099 Upgrades JFreeChart to version 1.5.1
---
 plugins/jfreechart/pom.xml                         |  4 ++--
 .../org/apache/struts2/dispatcher/ChartResult.java | 22 ++++++++++++----------
 2 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/plugins/jfreechart/pom.xml b/plugins/jfreechart/pom.xml
index f2d4d21..0ee1990 100644
--- a/plugins/jfreechart/pom.xml
+++ b/plugins/jfreechart/pom.xml
@@ -35,7 +35,7 @@
         <dependency>
             <groupId>org.jfree</groupId>
             <artifactId>jcommon</artifactId>
-            <version>1.0.23</version>
+            <version>1.0.24</version>
             <scope>provided</scope>
             <exclusions>
                 <exclusion>
@@ -47,7 +47,7 @@
         <dependency>
             <groupId>org.jfree</groupId>
             <artifactId>jfreechart</artifactId>
-            <version>1.0.19</version>
+            <version>1.5.1</version>
             <scope>provided</scope>
             <exclusions>
                 <exclusion>
diff --git a/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java
b/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java
index eabd988..c7c16a3 100644
--- a/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java
+++ b/plugins/jfreechart/src/main/java/org/apache/struts2/dispatcher/ChartResult.java
@@ -18,12 +18,13 @@
  */
 package org.apache.struts2.dispatcher;
 
+import com.opensymphony.xwork2.config.ConfigurationException;
 import org.apache.struts2.ServletActionContext;
 import com.opensymphony.xwork2.ActionInvocation;
 import org.apache.logging.log4j.Logger;
 import org.apache.logging.log4j.LogManager;
 import org.apache.struts2.result.StrutsResultSupport;
-import org.jfree.chart.ChartUtilities;
+import org.jfree.chart.ChartUtils;
 import org.jfree.chart.JFreeChart;
 
 import java.io.OutputStream;
@@ -105,14 +106,16 @@ public class ChartResult extends StrutsResultSupport {
     private final static Logger LOG = LogManager.getLogger(ChartResult.class);
 
     private static final long serialVersionUID = -6484761870055986612L;
+
     private static final String DEFAULT_TYPE = "png";
     private static final String DEFAULT_VALUE = "chart";
 
     private JFreeChart chart; // the JFreeChart to render
     private boolean chartSet;
-    String height, width;
-    String type = DEFAULT_TYPE; // supported are jpg, jpeg or png, defaults to png
-    String value = DEFAULT_VALUE; // defaults to 'chart'
+    private String height;
+    private String width;
+    private String type = DEFAULT_TYPE; // supported are jpg, jpeg or png, defaults to png
+    private String value = DEFAULT_VALUE; // defaults to 'chart'
 
     // CONSTRUCTORS ----------------------------
 
@@ -200,11 +203,11 @@ public class ChartResult extends StrutsResultSupport {
             // check the type to see what kind of output we have to produce
             if ("png".equalsIgnoreCase(type)) {
                 response.setContentType("image/png");
-                ChartUtilities.writeChartAsPNG(os, chart, getIntValueFromString(width), getIntValueFromString(height));
+                ChartUtils.writeChartAsPNG(os, chart, getIntValueFromString(width), getIntValueFromString(height));
             }
             else if ("jpg".equalsIgnoreCase(type) || "jpeg".equalsIgnoreCase(type)) {
                 response.setContentType("image/jpg");
-                ChartUtilities.writeChartAsJPEG(os, chart, getIntValueFromString(width),
getIntValueFromString(height));
+                ChartUtils.writeChartAsJPEG(os, chart, getIntValueFromString(width), getIntValueFromString(height));
             }
             else
                 throw new IllegalArgumentException(type + " is not a supported render type
(only JPG and PNG are).");
@@ -217,9 +220,8 @@ public class ChartResult extends StrutsResultSupport {
      * Sets up result properties, parsing etc.
      *
      * @param invocation Current invocation.
-     * @throws Exception on initialization error.
      */
-    private void initializeProperties(ActionInvocation invocation) throws Exception {
+    private void initializeProperties(ActionInvocation invocation) {
 
         if (height != null) {
             height = conditionalParse(height, invocation);
@@ -238,12 +240,12 @@ public class ChartResult extends StrutsResultSupport {
         }
     }
 
-    private Integer getIntValueFromString(String value) {
+    private int getIntValueFromString(String value) {
         try {
             return Integer.parseInt(value);
         } catch (Exception e) {
             LOG.error("Specified value for width or height is not of type Integer...", e);
-            return null;
+            throw new ConfigurationException("Wrong value \"" + value + "\", expected Integer!",
e);
         }
     }
 


Mime
View raw message