dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #16400
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 6234: Web api, setting correct name for charts
------------------------------------------------------------
revno: 6234
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2012-03-09 17:45:37 +0100
message:
Web api, setting correct name for charts
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2012-03-02 12:39:20 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2012-03-09 16:45:37 +0000
@@ -39,6 +39,7 @@
import org.hisp.dhis.indicator.IndicatorService;
import org.hisp.dhis.organisationunit.OrganisationUnit;
import org.hisp.dhis.organisationunit.OrganisationUnitService;
+import org.hisp.dhis.system.util.CodecUtils;
import org.hisp.dhis.api.utils.ContextUtils;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
@@ -136,10 +137,15 @@
@RequestParam( value = "height", defaultValue = "500", required = false ) int height,
HttpServletResponse response ) throws IOException, I18nManagerException
{
- JFreeChart chart = chartService.getJFreeChart( uid, i18nManager.getI18nFormat() );
+ JFreeChart jFreeChart = chartService.getJFreeChart( uid, i18nManager.getI18nFormat() );
- response.setContentType( ContextUtils.CONTENT_TYPE_PNG );
- ChartUtilities.writeChartAsPNG( response.getOutputStream(), chart, width, height );
+ Chart chart = chartService.getChart( uid );
+
+ String filename = CodecUtils.filenameEncode( chart.getName() ) + ".png";
+
+ ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, true, filename, false );
+
+ ChartUtilities.writeChartAsPNG( response.getOutputStream(), jFreeChart, width, height );
}
@RequestMapping( value = {"/data", "/data.png"}, method = RequestMethod.GET )
@@ -165,7 +171,8 @@
chart = chartService.getJFreeOrganisationUnitChart( indicator, unit, !skipTitle, i18nManager.getI18nFormat() );
}
- response.setContentType( ContextUtils.CONTENT_TYPE_PNG );
+ ContextUtils.configureResponse( response, ContextUtils.CONTENT_TYPE_PNG, true, "chart.png", false );
+
ChartUtilities.writeChartAsPNG( response.getOutputStream(), chart, width, height );
}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java 2012-03-07 14:05:05 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/OrganisationUnitLevelController.java 2012-03-09 16:45:37 +0000
@@ -27,8 +27,12 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import java.io.InputStream;
+import java.util.ArrayList;
+
+import javax.servlet.http.HttpServletRequest;
+
import org.hisp.dhis.api.utils.IdentifiableObjectParams;
-import org.hisp.dhis.api.utils.ObjectPersister;
import org.hisp.dhis.api.utils.WebLinkPopulator;
import org.hisp.dhis.organisationunit.OrganisationUnitLevel;
import org.hisp.dhis.organisationunit.OrganisationUnitLevels;
@@ -44,10 +48,6 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseStatus;
-import javax.servlet.http.HttpServletRequest;
-import java.io.InputStream;
-import java.util.ArrayList;
-
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
*/
@@ -60,9 +60,6 @@
@Autowired
private OrganisationUnitService organisationUnitService;
- @Autowired
- private ObjectPersister objectPersister;
-
//-------------------------------------------------------------------------------------------------------
// GET
//-------------------------------------------------------------------------------------------------------
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java 2012-03-05 09:03:35 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulator.java 2012-03-09 16:45:37 +0000
@@ -1141,7 +1141,8 @@
try
{
port = Integer.parseInt( xForwardedPort );
- } catch ( NumberFormatException e )
+ }
+ catch ( NumberFormatException e )
{
port = request.getServerPort();
}