dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30260
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15358: made json default rendering for html/text header, removed xslt view rendering
------------------------------------------------------------
revno: 15358
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-05-22 14:18:21 +0200
message:
made json default rendering for html/text header, removed xslt view rendering
removed:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XsltHtmlView.java
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/JacksonJsonView.java
dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/servlet.xml
dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl
--
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/view/JacksonJsonView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/JacksonJsonView.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/JacksonJsonView.java 2014-05-22 12:18:21 +0000
@@ -70,6 +70,11 @@
setContentType( CONTENT_TYPE_APPLICATION_JSON );
}
+ public JacksonJsonView( String contentType )
+ {
+ setContentType( contentType );
+ }
+
public JacksonJsonView( boolean withPadding, boolean withCompression )
{
this.withPadding = withPadding;
=== removed file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XsltHtmlView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XsltHtmlView.java 2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XsltHtmlView.java 1970-01-01 00:00:00 +0000
@@ -1,87 +0,0 @@
-package org.hisp.dhis.api.view;
-
-/*
- * Copyright (c) 2004-2014, University of Oslo
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * Redistributions of source code must retain the above copyright notice, this
- * list of conditions and the following disclaimer.
- *
- * Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * Neither the name of the HISP project nor the names of its contributors may
- * be used to endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
- * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
- * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-import org.hisp.dhis.dxf2.utils.JacksonUtils;
-import org.springframework.util.Assert;
-import org.springframework.web.servlet.view.AbstractUrlBasedView;
-
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.util.Map;
-
-/**
- * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
- */
-public class XsltHtmlView
- extends AbstractUrlBasedView
-{
- public static final String HTML_CONTENT_TYPE = "text/html";
-
- public XsltHtmlView()
- {
- setContentType( HTML_CONTENT_TYPE );
- }
-
- @Override
- @SuppressWarnings( "unchecked" )
- protected void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response )
- throws Exception
- {
- Object object = model.get( "model" );
- Class<?> viewClass = JacksonUtils.getViewClass( model.get( "viewClass" ) );
- response.setContentType( getContentType() );
-
- Assert.notNull( object );
-
- InputStream input = new ByteArrayInputStream( JacksonUtils.toXmlWithViewAsString( object, viewClass ).getBytes("UTF-8") );
- Source xmlSource = new StreamSource( input );
-
- Transformer transformer = TransformCacheImpl.instance().getHtmlTransformer();
-
- // pass on any parameters set in xslt-params
- Map<String, String> params = (Map<String, String>) model.get( "xslt-params" );
-
- if ( params != null )
- {
- for ( Map.Entry<String, String> entry : params.entrySet() )
- {
- transformer.setParameter( entry.getKey(), entry.getValue() );
- }
- }
-
- transformer.transform( xmlSource, new StreamResult( response.getOutputStream() ) );
- }
-}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/servlet.xml'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/servlet.xml 2014-04-23 10:19:42 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/META-INF/dhis/servlet.xml 2014-05-22 12:18:21 +0000
@@ -40,7 +40,6 @@
<entry key="pdf" value="application/pdf" />
<entry key="xls" value="application/vnd.ms-excel" />
<entry key="csv" value="application/csv" />
- <entry key="html" value="text/html" />
</map>
</constructor-arg>
</bean>
@@ -70,6 +69,10 @@
</bean>
<bean class="org.hisp.dhis.api.view.JacksonJsonView">
+ <constructor-arg name="contentType" value="text/html" />
+ </bean>
+
+ <bean class="org.hisp.dhis.api.view.JacksonJsonView">
<constructor-arg name="withPadding" value="false" />
<constructor-arg name="withCompression" value="false" />
</bean>
@@ -97,15 +100,6 @@
</list>
</property>
- <property name="viewResolvers">
- <list>
- <bean name="xsltHtmlViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
- <property name="prefix" value="/templates/html/" />
- <property name="suffix" value=".xsl" />
- <property name="viewClass" value="org.hisp.dhis.api.view.XsltHtmlView" />
- </bean>
- </list>
- </property>
</bean>
</beans>
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl'
--- dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl 2013-09-14 11:26:52 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/resources/templates/html/model2html.xsl 2014-05-22 12:18:21 +0000
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
- xmlns="http://www.w3.org/1999/xhtml"
- xmlns:d="http://dhis2.org/schema/dxf/2.0"
- exclude-result-prefixes="d"
- >
+ xmlns="http://www.w3.org/1999/xhtml"
+ xmlns:d="http://dhis2.org/schema/dxf/2.0"
+ exclude-result-prefixes="d"
+ >
<xsl:output method="html" />
@@ -61,9 +61,6 @@
<xsl:include href="event.xsl" />
<xsl:include href="dashboard.xsl" />
- <!--@author Ovidiu Rosu <rosu.ovi@xxxxxxxxx>-->
- <xsl:include href="filter.xsl" />
-
<!-- Config elements -->
<xsl:include href="config/sms.xsl" />