dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15072
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5297: merged with dhis-dxf2, added resource for resouces, also fixed json rendering
Merge authors:
Morten Olav Hansen (mortenoh)
------------------------------------------------------------
revno: 5297 [merge]
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-06 10:57:26 +0100
message:
merged with dhis-dxf2, added resource for resouces, also fixed json rendering
added:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/MediaTypeListJsonSerializer.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/MediaTypeXmlAdapter.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/RequestMethodListJsonSerializer.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/RequestMethodXmlAdapter.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndexController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Resource.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Resources.java
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/utils/WebLinkPopulatorListener.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ExtendedMappingJacksonView.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/MapGenerationView.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ViewUtils.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XsltHtmlView.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
=== added directory 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter'
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/MediaTypeListJsonSerializer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/MediaTypeListJsonSerializer.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/MediaTypeListJsonSerializer.java 2011-12-06 08:39:29 +0000
@@ -0,0 +1,57 @@
+package org.hisp.dhis.api.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.springframework.http.MediaType;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class MediaTypeListJsonSerializer extends JsonSerializer<List<MediaType>>
+{
+ @Override
+ public void serialize( List<MediaType> mediaTypes, JsonGenerator jgen, SerializerProvider serializerProvider )
+ throws IOException, JsonProcessingException
+ {
+ jgen.writeStartArray();
+
+ for ( MediaType mediaType : mediaTypes )
+ {
+ jgen.writeString( mediaType.toString() );
+ }
+
+ jgen.writeEndArray();
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/MediaTypeXmlAdapter.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/MediaTypeXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/MediaTypeXmlAdapter.java 2011-12-06 08:39:29 +0000
@@ -0,0 +1,50 @@
+package org.hisp.dhis.api.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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.springframework.http.MediaType;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class MediaTypeXmlAdapter extends XmlAdapter<String, MediaType>
+{
+ @Override
+ public MediaType unmarshal( String v ) throws Exception
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public String marshal( MediaType v ) throws Exception
+ {
+ return v.toString();
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/RequestMethodListJsonSerializer.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/RequestMethodListJsonSerializer.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/RequestMethodListJsonSerializer.java 2011-12-06 08:39:29 +0000
@@ -0,0 +1,57 @@
+package org.hisp.dhis.api.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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.codehaus.jackson.JsonGenerator;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.map.JsonSerializer;
+import org.codehaus.jackson.map.SerializerProvider;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import java.io.IOException;
+import java.util.List;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class RequestMethodListJsonSerializer extends JsonSerializer<List<RequestMethod>>
+{
+ @Override
+ public void serialize( List<RequestMethod> requestMethods, JsonGenerator jgen, SerializerProvider serializerProvider )
+ throws IOException, JsonProcessingException
+ {
+ jgen.writeStartArray();
+
+ for ( RequestMethod requestMethod : requestMethods )
+ {
+ jgen.writeString( requestMethod.toString() );
+ }
+
+ jgen.writeEndArray();
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/RequestMethodXmlAdapter.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/RequestMethodXmlAdapter.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/adapter/RequestMethodXmlAdapter.java 2011-12-06 08:39:29 +0000
@@ -0,0 +1,50 @@
+package org.hisp.dhis.api.adapter;
+
+/*
+ * Copyright (c) 2004-2011, 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.springframework.web.bind.annotation.RequestMethod;
+
+import javax.xml.bind.annotation.adapters.XmlAdapter;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+public class RequestMethodXmlAdapter extends XmlAdapter<String, RequestMethod>
+{
+ @Override
+ public RequestMethod unmarshal( String v ) throws Exception
+ {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public String marshal( RequestMethod v ) throws Exception
+ {
+ return v.toString();
+ }
+}
=== 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 2011-12-06 05:19:57 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ChartController.java 2011-12-06 06:13:22 +0000
@@ -27,6 +27,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
import org.hisp.dhis.chart.Chart;
import org.hisp.dhis.chart.ChartService;
import org.hisp.dhis.chart.Charts;
@@ -59,21 +61,33 @@
private ChartService chartService;
@RequestMapping( method = RequestMethod.GET )
- public String getCharts( Model model, HttpServletRequest request )
+ public String getCharts( IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
Charts charts = new Charts();
charts.setCharts( new ArrayList<Chart>( chartService.getAllCharts() ) );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( charts );
+ }
+
model.addAttribute( "model", charts );
return "charts";
}
@RequestMapping( value = "/{uid}", method = RequestMethod.GET )
- public String getChart( @PathVariable( "uid" ) String uid, Model model, HttpServletRequest request )
+ public String getChart( @PathVariable( "uid" ) String uid, IdentifiableObjectParams params, Model model, HttpServletRequest request )
{
Chart chart = chartService.getChart( uid );
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( chart );
+ }
+
model.addAttribute( "model", chart );
return "chart";
@@ -104,7 +118,7 @@
@RequestMapping( value = "/{uid}.png", method = RequestMethod.GET )
public void getChartPNG( @PathVariable( "uid" ) String uid, @RequestParam( value = "width", defaultValue = "700", required = false ) int width,
- @RequestParam( value = "height", defaultValue = "500", required = false ) Integer height,
+ @RequestParam( value = "height", defaultValue = "500", required = false ) int height,
HttpServletResponse response ) throws IOException
{
I18nFormat i18nFormat = new MockI18nFormat();
@@ -117,7 +131,7 @@
@RequestMapping( value = "/{uid}.jpg", method = RequestMethod.GET )
public void getChartJPG( @PathVariable( "uid" ) String uid, @RequestParam( value = "width", defaultValue = "700", required = false ) int width,
- @RequestParam( value = "height", defaultValue = "500", required = false ) Integer height,
+ @RequestParam( value = "height", defaultValue = "500", required = false ) int height,
HttpServletResponse response ) throws IOException
{
I18nFormat i18nFormat = new MockI18nFormat();
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndexController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndexController.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/IndexController.java 2011-12-06 08:39:29 +0000
@@ -0,0 +1,52 @@
+package org.hisp.dhis.api.controller;
+
+/*
+ * Copyright (c) 2004-2011, 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.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Controller
+public class IndexController
+{
+ @RequestMapping( value = "/api", method = RequestMethod.GET )
+ public String getIndex( Model model )
+ {
+ return "redirect:/api/resources";
+ }
+
+ @RequestMapping( value = "/", method = RequestMethod.GET )
+ public String getIndexWithSlash( Model model )
+ {
+ return "redirect:/api/resources";
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceController.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/ResourceController.java 2011-12-06 08:39:29 +0000
@@ -0,0 +1,62 @@
+package org.hisp.dhis.api.controller;
+
+/*
+ * Copyright (c) 2004-2011, 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.api.utils.IdentifiableObjectParams;
+import org.hisp.dhis.api.utils.WebLinkPopulatorListener;
+import org.hisp.dhis.api.view.Resources;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.servlet.http.HttpServletRequest;
+
+/**
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@Controller
+@RequestMapping( value = "/resources" )
+public class ResourceController
+{
+ @RequestMapping( method = RequestMethod.GET )
+ public String getResources( IdentifiableObjectParams params, Model model, HttpServletRequest request )
+ {
+ Resources resources = new Resources();
+
+ if ( params.hasLinks() )
+ {
+ WebLinkPopulatorListener listener = new WebLinkPopulatorListener( request );
+ listener.beforeMarshal( resources );
+ }
+
+ model.addAttribute( "model", resources );
+
+ return "resources";
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulatorListener.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulatorListener.java 2011-12-06 05:26:02 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/utils/WebLinkPopulatorListener.java 2011-12-06 09:57:26 +0000
@@ -27,6 +27,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.view.Resource;
+import org.hisp.dhis.api.view.Resources;
import org.hisp.dhis.attribute.Attribute;
import org.hisp.dhis.attribute.Attributes;
import org.hisp.dhis.chart.Chart;
@@ -65,6 +67,8 @@
static
{
+ resourcePaths.put( Resources.class, "resources" );
+
resourcePaths.put( Attributes.class, "attributes" );
resourcePaths.put( Attribute.class, "attributes" );
@@ -124,7 +128,11 @@
@Override
public void beforeMarshal( Object source )
{
- if ( source instanceof Charts )
+ if ( source instanceof Resources )
+ {
+ populateResources( (Resources) source );
+ }
+ else if ( source instanceof Charts )
{
populateCharts( (Charts) source, true );
}
@@ -254,6 +262,16 @@
}
}
+ private void populateResources( Resources resources )
+ {
+ resources.setLink( getBasePath( Resources.class ) );
+
+ for ( Resource resource : resources.getResources() )
+ {
+ resource.setLink( getBasePath( resource.getClazz() ) );
+ }
+ }
+
private void populateAttributes( Attributes attributes, boolean root )
{
attributes.setLink( getBasePath( Attributes.class ) );
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ExtendedMappingJacksonView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ExtendedMappingJacksonView.java 2011-12-03 14:35:34 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ExtendedMappingJacksonView.java 2011-12-06 08:39:29 +0000
@@ -46,8 +46,6 @@
*/
public class ExtendedMappingJacksonView extends MappingJacksonJsonView
{
- private boolean includeRootElement = false;
-
private boolean withPadding = false;
private String callbackParameter = "callback";
@@ -69,11 +67,6 @@
}
}
- public void setIncludeRootElement( boolean includeRootElement )
- {
- this.includeRootElement = includeRootElement;
- }
-
public void setCallbackParameter( String callbackParameter )
{
this.callbackParameter = callbackParameter;
@@ -87,7 +80,9 @@
@Override
protected void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response ) throws Exception
{
- Object value = filterModel( model );
+ model = ViewUtils.filterModel( model );
+ Object value = model.get( "model" );
+
ObjectMapper objectMapper = new ObjectMapper();
AnnotationIntrospector jacksonAnnotationIntrospector = new JacksonAnnotationIntrospector();
@@ -99,16 +94,6 @@
JsonFactory jf = objectMapper.getJsonFactory();
JsonGenerator jg = jf.createJsonGenerator( response.getOutputStream(), JsonEncoding.UTF8 );
- if ( !includeRootElement && value instanceof Map )
- {
- Map map = (Map) value;
-
- if ( map.size() == 1 )
- {
- value = map.values().toArray()[0];
- }
- }
-
if ( withPadding )
{
String callback = request.getParameter( callbackParameter );
@@ -118,7 +103,7 @@
callback = paddingFunction;
}
- JSONPObject valueWithPadding = new JSONPObject( callback, value );
+ JSONPObject valueWithPadding = valueWithPadding = new JSONPObject( callback, value );
jg.writeObject( valueWithPadding );
}
else
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/MapGenerationView.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/MapGenerationView.java 2011-12-05 12:21:38 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/MapGenerationView.java 2011-12-06 08:39:29 +0000
@@ -1,11 +1,31 @@
package org.hisp.dhis.api.view;
-import java.awt.image.BufferedImage;
-import java.util.Map;
-
-import javax.imageio.ImageIO;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+/*
+ * Copyright (c) 2004-2011, 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.mapgeneration.MapGenerationService;
import org.hisp.dhis.mapping.MapView;
@@ -13,13 +33,18 @@
import org.springframework.http.MediaType;
import org.springframework.web.servlet.view.AbstractView;
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.util.Map;
+
public class MapGenerationView
extends AbstractView
{
-
@Autowired
MapGenerationService mapGenerationService;
-
+
public MapGenerationView()
{
super();
@@ -27,8 +52,7 @@
}
@Override
- protected void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request,
- HttpServletResponse response )
+ protected void renderMergedOutputModel( Map<String, Object> model, HttpServletRequest request, HttpServletResponse response )
throws Exception
{
MapView mapView = (MapView) model.get( "model" );
@@ -36,8 +60,5 @@
response.setContentType( MediaType.IMAGE_PNG.toString() );
ImageIO.write( image, "PNG", response.getOutputStream() );
-
-
}
-
}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Resource.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Resource.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Resource.java 2011-12-06 08:39:29 +0000
@@ -0,0 +1,126 @@
+package org.hisp.dhis.api.view;
+
+/*
+ * Copyright (c) 2004-2011, 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.codehaus.jackson.annotate.JsonProperty;
+import org.codehaus.jackson.map.annotate.JsonSerialize;
+import org.hisp.dhis.api.adapter.MediaTypeListJsonSerializer;
+import org.hisp.dhis.api.adapter.MediaTypeXmlAdapter;
+import org.hisp.dhis.api.adapter.RequestMethodListJsonSerializer;
+import org.hisp.dhis.api.adapter.RequestMethodXmlAdapter;
+import org.hisp.dhis.common.BaseLinkableObject;
+import org.hisp.dhis.common.Dxf2Namespace;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.xml.bind.annotation.*;
+import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * At some point this class will be extended to show all available options
+ * for a current user for this resource. For now it is only used for index page.
+ *
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@XmlRootElement( name = "resource", namespace = Dxf2Namespace.NAMESPACE )
+@XmlAccessorType( value = XmlAccessType.NONE )
+public class Resource extends BaseLinkableObject
+{
+ private String name;
+
+ private Class clazz;
+
+ private List<RequestMethod> methods = new ArrayList<RequestMethod>();
+
+ private List<MediaType> mediaTypes = new ArrayList<MediaType>();
+
+ public Resource()
+ {
+
+ }
+
+ public Resource( String name, Class clazz, List<RequestMethod> methods, List<MediaType> mediaTypes )
+ {
+ this.name = name;
+ this.clazz = clazz;
+ this.methods = methods;
+ this.mediaTypes = mediaTypes;
+ }
+
+ @XmlAttribute
+ @JsonProperty
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName( String name )
+ {
+ this.name = name;
+ }
+
+ @XmlElementWrapper( name = "methods" )
+ @XmlElement( name = "method" )
+ @XmlJavaTypeAdapter( RequestMethodXmlAdapter.class )
+ @JsonSerialize( using = RequestMethodListJsonSerializer.class )
+ public List<RequestMethod> getMethods()
+ {
+ return methods;
+ }
+
+ public void setMethods( List<RequestMethod> methods )
+ {
+ this.methods = methods;
+ }
+
+ @XmlElementWrapper( name = "mediaTypes" )
+ @XmlElement( name = "mediaType" )
+ @XmlJavaTypeAdapter( MediaTypeXmlAdapter.class )
+ @JsonSerialize( using = MediaTypeListJsonSerializer.class )
+ public List<MediaType> getMediaTypes()
+ {
+ return mediaTypes;
+ }
+
+ public void setMediaTypes( List<MediaType> mediaTypes )
+ {
+ this.mediaTypes = mediaTypes;
+ }
+
+ public Class getClazz()
+ {
+ return clazz;
+ }
+
+ public void setClazz( Class clazz )
+ {
+ this.clazz = clazz;
+ }
+}
=== added file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Resources.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Resources.java 1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/Resources.java 2011-12-06 08:39:29 +0000
@@ -0,0 +1,125 @@
+package org.hisp.dhis.api.view;
+
+/*
+ * Copyright (c) 2004-2011, 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.codehaus.jackson.annotate.JsonProperty;
+import org.hisp.dhis.attribute.Attributes;
+import org.hisp.dhis.chart.Charts;
+import org.hisp.dhis.common.BaseLinkableObject;
+import org.hisp.dhis.common.Dxf2Namespace;
+import org.hisp.dhis.dataelement.*;
+import org.hisp.dhis.dataset.CompleteDataSetRegistrations;
+import org.hisp.dhis.dataset.DataSets;
+import org.hisp.dhis.indicator.IndicatorGroupSets;
+import org.hisp.dhis.indicator.IndicatorGroups;
+import org.hisp.dhis.indicator.IndicatorTypes;
+import org.hisp.dhis.indicator.Indicators;
+import org.hisp.dhis.mapping.Maps;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroupSets;
+import org.hisp.dhis.organisationunit.OrganisationUnitGroups;
+import org.hisp.dhis.organisationunit.OrganisationUnits;
+import org.hisp.dhis.user.Users;
+import org.springframework.http.MediaType;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * At some point this class will be extended to show all available options
+ * for a current user for this resource. For now it is only used for index page.
+ *
+ * @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
+ */
+@XmlRootElement( name = "resources", namespace = Dxf2Namespace.NAMESPACE )
+@XmlAccessorType( value = XmlAccessType.NONE )
+public class Resources extends BaseLinkableObject
+{
+ private List<Resource> resources = new ArrayList<Resource>();
+
+ public Resources()
+ {
+ generateResources();
+ }
+
+ @XmlElement( name = "resource" )
+ @JsonProperty( value = "resources" )
+ public List<Resource> getResources()
+ {
+ return resources;
+ }
+
+ public void setResources( List<Resource> resources )
+ {
+ this.resources = resources;
+ }
+
+ //-----------------------------------------------
+ // Helpers
+ //-----------------------------------------------
+ private void generateResources()
+ {
+ RequestMethod[] defaultRequestMethods = new RequestMethod[]{
+ RequestMethod.GET, RequestMethod.POST, RequestMethod.PUT, RequestMethod.DELETE
+ };
+
+ MediaType[] defaultMediaTypes = new MediaType[]{
+ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_HTML,
+ new MediaType( "application", "javascript" ), new MediaType( "application", "pdf" )
+ };
+
+ List<RequestMethod> requestMethods = Arrays.asList( defaultRequestMethods );
+ List<MediaType> mediaTypes = Arrays.asList( defaultMediaTypes );
+
+ resources.add( new Resource( "Attributes", Attributes.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "Charts", Charts.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "Maps", Maps.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "CompleteDataSetRegistrations", CompleteDataSetRegistrations.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "Indicators", Indicators.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "IndicatorGroups", IndicatorGroups.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "IndicatorGroupSets", IndicatorGroupSets.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "IndicatorTypes", IndicatorTypes.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "DataElements", DataElements.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "DataElementGroups", DataElementGroups.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "DataElementGroupSets", DataElementGroupSets.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "DataElementCategories", DataElementCategories.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "DataElementCategoryCombos", DataElementCategoryCombos.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "DataElementCategoryOptions", DataElementCategoryOptions.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "DataElementCategoryOptionCombos", DataElementCategoryOptionCombos.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "OrganisationUnits", OrganisationUnits.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "OrganisationUnitGroups", OrganisationUnitGroups.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "OrganisationUnitGroupSets", OrganisationUnitGroupSets.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "DataSets", DataSets.class, requestMethods, mediaTypes ) );
+ resources.add( new Resource( "Users", Users.class, requestMethods, mediaTypes ) );
+ }
+}
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ViewUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ViewUtils.java 2011-12-03 14:35:34 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/ViewUtils.java 2011-12-06 08:39:29 +0000
@@ -27,6 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.hisp.dhis.api.utils.IdentifiableObjectParams;
import org.springframework.validation.BindingResult;
import java.util.HashMap;
@@ -43,7 +44,7 @@
for ( Map.Entry<String, Object> entry : model.entrySet() )
{
- if ( !(entry.getValue() instanceof BindingResult) )
+ if ( !(entry.getValue() instanceof BindingResult) && !(entry.getValue() instanceof IdentifiableObjectParams) )
{
result.put( entry.getKey(), entry.getValue() );
}
=== modified 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 2011-12-05 12:21:38 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/view/XsltHtmlView.java 2011-12-06 08:39:29 +0000
@@ -27,8 +27,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import java.io.OutputStream;
-import java.util.Map;
+import org.springframework.web.servlet.view.AbstractUrlBasedView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -37,8 +36,8 @@
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamResult;
-
-import org.springframework.web.servlet.view.AbstractUrlBasedView;
+import java.io.OutputStream;
+import java.util.Map;
/**
* @author Morten Olav Hansen <mortenoh@xxxxxxxxx>
@@ -66,13 +65,10 @@
// TODO throw exception
}
-
Marshaller marshaller = Jaxb2Utils.createMarshaller( domainModel, request );
Source xmlSource = new JAXBSource( marshaller, domainModel );
-
-
Transformer transformer = TransformCacheImpl.instance().getHtmlTransformer();
OutputStream output = response.getOutputStream();
@@ -88,7 +84,5 @@
}
transformer.transform( xmlSource, new StreamResult( output ) );
-
}
-
}