=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java 2014-02-22 16:27:24 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/metadata/MetaData.java 2014-03-13 15:56:48 +0000 @@ -32,6 +32,7 @@ import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import com.google.common.collect.Lists; import org.hisp.dhis.attribute.Attribute; import org.hisp.dhis.chart.Chart; import org.hisp.dhis.common.DimensionalObject; @@ -54,6 +55,7 @@ import org.hisp.dhis.dataset.DataSet; import org.hisp.dhis.dataset.Section; import org.hisp.dhis.document.Document; +import org.hisp.dhis.dxf2.schema.Schema; import org.hisp.dhis.filter.MetaDataFilter; import org.hisp.dhis.indicator.Indicator; import org.hisp.dhis.indicator.IndicatorGroup; @@ -97,6 +99,8 @@ { private Date created; + private List schemas = Lists.newArrayList(); + private List attributeTypes = new ArrayList(); private List documents = new ArrayList(); @@ -148,7 +152,7 @@ private List indicatorGroupSets = new ArrayList(); private List indicatorTypes = new ArrayList(); - + private List items = new ArrayList(); private List organisationUnits = new ArrayList(); @@ -216,6 +220,19 @@ } @JsonProperty + @JacksonXmlElementWrapper( localName = "schemas", namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty( localName = "schema", namespace = DxfNamespaces.DXF_2_0 ) + public List getSchemas() + { + return schemas; + } + + public void setSchemas( List schemas ) + { + this.schemas = schemas; + } + + @JsonProperty @JacksonXmlElementWrapper(localName = "attributeTypes", namespace = DxfNamespaces.DXF_2_0) @JacksonXmlProperty(localName = "attributeType", namespace = DxfNamespaces.DXF_2_0) public List getAttributeTypes() === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultPropertyScannerService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultPropertyScannerService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultPropertyScannerService.java 2014-03-13 15:56:48 +0000 @@ -0,0 +1,74 @@ +package org.hisp.dhis.dxf2.schema; + +/* + * Copyright (c) 2004-2013, 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 com.google.common.collect.Lists; +import org.hisp.dhis.system.util.ReflectionUtils; + +import java.util.List; +import java.util.Map; + +/** + * Default PropertyScannerService implementation that uses Reflection and Jackson annotations + * for reading in properties. + * + * @author Morten Olav Hansen + */ +public class DefaultPropertyScannerService implements PropertyScannerService +{ + @Override + public List getProperties( Class klass ) + { + return scanClass( klass ); + } + + private List scanClass( Class klass ) + { + List properties = Lists.newArrayList(); + + Map classMap = ReflectionUtils.getJacksonClassMap( klass ); + + // for now, just use the reflection utils directly + for ( ReflectionUtils.PropertyDescriptor descriptor : classMap.values() ) + { + Property property = new Property( descriptor.getMethod() ); + properties.add( property ); + + property.setKlass( descriptor.getClazz() ); + property.setCollection( descriptor.isCollection() ); + property.setIdentifiableObject( descriptor.isIdentifiableObject() ); + property.setName( descriptor.getName() ); + property.setXmlName( descriptor.getXmlName() ); + property.setXmlCollectionName( descriptor.getXmlCollectionName() ); + property.setDescription( descriptor.getDescription() ); + } + + return properties; + } +} === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultSchemaService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultSchemaService.java 2014-03-13 15:05:38 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/DefaultSchemaService.java 2014-03-13 15:56:48 +0000 @@ -43,6 +43,11 @@ { private Map, Schema> classSchemaMap = Maps.newHashMap(); + private Map singularSchemaMap = Maps.newHashMap(); + + @Autowired + private PropertyScannerService propertyScannerService; + @Autowired private List descriptors = Lists.newArrayList(); @@ -52,7 +57,10 @@ for ( SchemaDescriptor descriptor : descriptors ) { Schema schema = descriptor.getSchema(); + schema.setProperties( propertyScannerService.getProperties( schema.getKlass() ) ); + classSchemaMap.put( schema.getKlass(), schema ); + singularSchemaMap.put( schema.getSingular(), schema ); } } @@ -63,6 +71,12 @@ } @Override + public Schema getSchemaBySingularName( String name ) + { + return singularSchemaMap.get( name ); + } + + @Override public List getSchemas() { return Lists.newArrayList( classSchemaMap.values() ); === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/Property.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/Property.java 2014-03-13 14:30:24 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/Property.java 2014-03-13 15:56:48 +0000 @@ -29,12 +29,16 @@ */ import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; +import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement; +import org.hisp.dhis.common.DxfNamespaces; import java.lang.reflect.Method; /** * @author Morten Olav Hansen */ +@JacksonXmlRootElement( localName = "property", namespace = DxfNamespaces.DXF_2_0 ) public class Property { private String name; @@ -47,7 +51,7 @@ private String xmlCollectionName; - private Class clazz; + private Class klass; private Method method; @@ -55,12 +59,13 @@ private boolean identifiableObject; - private Property( Method method ) + public Property( Method method ) { this.method = method; } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getName() { return name; @@ -72,6 +77,7 @@ } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getDescription() { return description; @@ -83,6 +89,7 @@ } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getXmlName() { return xmlName; @@ -94,6 +101,7 @@ } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public boolean isXmlAttribute() { return xmlAttribute; @@ -105,6 +113,7 @@ } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getXmlCollectionName() { return xmlCollectionName; @@ -116,14 +125,15 @@ } @JsonProperty - public Class getClazz() + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) + public Class getKlass() { - return clazz; + return klass; } - public void setClazz( Class clazz ) + public void setKlass( Class klass ) { - this.clazz = clazz; + this.klass = klass; } public Method getMethod() @@ -137,6 +147,7 @@ } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public boolean isCollection() { return collection; @@ -148,6 +159,7 @@ } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public boolean isIdentifiableObject() { return identifiableObject; @@ -158,15 +170,16 @@ this.identifiableObject = identifiableObject; } - @Override public String toString() + @Override + public String toString() { - return "PropertyDescriptor{" + + return "Property{" + "name='" + name + '\'' + ", description='" + description + '\'' + ", xmlName='" + xmlName + '\'' + ", xmlAttribute=" + xmlAttribute + ", xmlCollectionName='" + xmlCollectionName + '\'' + - ", clazz=" + clazz + + ", klass=" + klass + ", method=" + method + ", collection=" + collection + ", identifiableObject=" + identifiableObject + === added file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/PropertyScannerService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/PropertyScannerService.java 1970-01-01 00:00:00 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/PropertyScannerService.java 2014-03-13 15:56:48 +0000 @@ -0,0 +1,39 @@ +package org.hisp.dhis.dxf2.schema; + +/* + * Copyright (c) 2004-2013, 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 java.util.List; + +/** + * @author Morten Olav Hansen + */ +public interface PropertyScannerService +{ + List getProperties( Class klass ); +} === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/Schema.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/Schema.java 2014-03-13 14:30:24 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/Schema.java 2014-03-13 15:56:48 +0000 @@ -72,7 +72,7 @@ } @JsonProperty - @JacksonXmlProperty( isAttribute = true, namespace = DxfNamespaces.DXF_2_0 ) + @JacksonXmlProperty( isAttribute = true ) public Class getKlass() { return klass; @@ -84,6 +84,7 @@ } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getSingular() { return singular; @@ -95,6 +96,7 @@ } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public String getPlural() { return plural; @@ -106,6 +108,7 @@ } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public boolean isImportable() { return importable; @@ -117,6 +120,7 @@ } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public boolean isExportable() { return exportable; @@ -128,6 +132,7 @@ } @JsonProperty + @JacksonXmlProperty( namespace = DxfNamespaces.DXF_2_0 ) public boolean isDeletable() { return deletable; @@ -150,4 +155,18 @@ { this.properties = properties; } + + @Override + public String toString() + { + return "Schema{" + + "klass=" + klass + + ", singular='" + singular + '\'' + + ", plural='" + plural + '\'' + + ", importable=" + importable + + ", exportable=" + exportable + + ", deletable=" + deletable + + ", properties=" + properties + + '}'; + } } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/SchemaService.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/SchemaService.java 2014-03-13 15:05:38 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/SchemaService.java 2014-03-13 15:56:48 +0000 @@ -37,5 +37,7 @@ { Schema getSchema( Class klass ); + Schema getSchemaBySingularName( String name ); + List getSchemas(); } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/descriptors/DataElementSchemaDescriptor.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/descriptors/DataElementSchemaDescriptor.java 2014-03-13 15:05:38 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/descriptors/DataElementSchemaDescriptor.java 2014-03-13 15:56:48 +0000 @@ -42,8 +42,6 @@ @Override public Schema getSchema() { - Schema schema = new Schema( DataElement.class, "dataElement", "dataElements", true, true, true ); - - return schema; + return new Schema( DataElement.class, "dataElement", "dataElements", true, true, true ); } } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/descriptors/IndicatorSchemaDescriptor.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/descriptors/IndicatorSchemaDescriptor.java 2014-03-13 15:05:38 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/schema/descriptors/IndicatorSchemaDescriptor.java 2014-03-13 15:56:48 +0000 @@ -42,8 +42,6 @@ @Override public Schema getSchema() { - Schema schema = new Schema( Indicator.class, "indicator", "indicators", true, true, true ); - - return schema; + return new Schema( Indicator.class, "indicator", "indicators", true, true, true ); } } === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java 2014-01-02 13:13:21 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/utils/JacksonUtils.java 2014-03-13 15:56:48 +0000 @@ -47,6 +47,8 @@ import org.hisp.dhis.common.view.UuidView; import org.hisp.dhis.common.view.WithoutOrganisationUnitsView; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; === modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml' --- dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml 2014-03-13 15:05:38 +0000 +++ dhis-2/dhis-services/dhis-service-dxf2/src/main/resources/META-INF/dhis/beans.xml 2014-03-13 15:56:48 +0000 @@ -8,6 +8,8 @@ + + === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SchemaController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SchemaController.java 2014-03-13 13:23:00 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/api/controller/SchemaController.java 2014-03-13 15:56:48 +0000 @@ -28,128 +28,62 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import com.fasterxml.jackson.dataformat.xml.ser.ToXmlGenerator; -import com.google.common.collect.Maps; -import org.hisp.dhis.common.DxfNamespaces; -import org.hisp.dhis.common.IdentifiableObject; -import org.hisp.dhis.dxf2.metadata.ExchangeClasses; +import org.hisp.dhis.dxf2.metadata.MetaData; +import org.hisp.dhis.dxf2.schema.Schema; +import org.hisp.dhis.dxf2.schema.SchemaService; import org.hisp.dhis.dxf2.utils.JacksonUtils; -import org.hisp.dhis.system.util.ReflectionUtils; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import javax.servlet.http.HttpServletResponse; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; import java.io.IOException; -import java.util.Map; +import java.util.List; /** * @author Morten Olav Hansen */ @Controller -@RequestMapping( value = "", method = RequestMethod.GET ) +@RequestMapping( value = "/schemas", method = RequestMethod.GET ) public class SchemaController { - @RequestMapping( value = { "/schemas", "/schemas.json" }, method = RequestMethod.GET ) - public void getTypesJson( HttpServletResponse response ) throws IOException - { - response.setContentType( MediaType.APPLICATION_JSON_VALUE ); - Map> output = Maps.newHashMap(); - - for ( Class key : ExchangeClasses.getAllExportMap().keySet() ) - { - Map classMap = ReflectionUtils.getJacksonClassMap( key ); - output.put( ExchangeClasses.getAllExportMap().get( key ), classMap ); - } - - JacksonUtils.toJson( response.getOutputStream(), output ); - } - - @RequestMapping( value = { "/schemas.xml" }, method = RequestMethod.GET ) - public void getTypesXml( HttpServletResponse response ) throws IOException - { - response.setContentType( MediaType.APPLICATION_XML_VALUE ); - Map> output = Maps.newHashMap(); - - for ( Class key : ExchangeClasses.getAllExportMap().keySet() ) - { - Map classMap = ReflectionUtils.getJacksonClassMap( key ); - output.put( ExchangeClasses.getAllExportMap().get( key ), classMap ); - } - - try - { - ToXmlGenerator generator = (ToXmlGenerator) JacksonUtils.getXmlMapper().getJsonFactory().createJsonGenerator( response.getOutputStream() ); - XMLStreamWriter staxWriter = generator.getStaxWriter(); - - staxWriter.writeStartElement( "", "schemas", DxfNamespaces.DXF_2_0 ); - - for ( String key : output.keySet() ) - { - Map map = output.get( key ); - writeClassMap( staxWriter, key, map ); - } - - staxWriter.writeEndElement(); - staxWriter.close(); - } - catch ( XMLStreamException ex ) - { - ex.printStackTrace(); - } - } - - private void writeClassMap( XMLStreamWriter staxWriter, String type, Map classMap ) - { - try - { - staxWriter.writeStartElement( "", "schema", DxfNamespaces.DXF_2_0 ); - staxWriter.writeAttribute( "type", type ); - - for ( String field : classMap.keySet() ) - { - staxWriter.writeStartElement( "", field, DxfNamespaces.DXF_2_0 ); - ReflectionUtils.PropertyDescriptor descriptor = classMap.get( field ); - writeDescriptor( staxWriter, descriptor ); - staxWriter.writeEndElement(); - } - - staxWriter.writeEndElement(); - } - catch ( XMLStreamException ignored ) - { - } - } - - private void writeDescriptor( XMLStreamWriter staxWriter, ReflectionUtils.PropertyDescriptor descriptor ) - { - writeSimpleElement( staxWriter, "name", descriptor.getName() ); - writeSimpleElement( staxWriter, "xmlName", descriptor.getXmlName() ); - writeSimpleElement( staxWriter, "xmlAttribute", descriptor.isXmlAttribute() ); - writeSimpleElement( staxWriter, "clazz", descriptor.getClazz() ); - writeSimpleElement( staxWriter, "collection", descriptor.isCollection() ); - writeSimpleElement( staxWriter, "identifiableObject", descriptor.isIdentifiableObject() ); - writeSimpleElement( staxWriter, "description", descriptor.getDescription() ); - } - - private void writeSimpleElement( XMLStreamWriter staxWriter, String fieldName, Object text ) - { - if ( text == null ) - { - return; - } - - try - { - staxWriter.writeStartElement( "", fieldName, DxfNamespaces.DXF_2_0 ); - staxWriter.writeCharacters( text.toString() ); - staxWriter.writeEndElement(); - } - catch ( XMLStreamException ignored ) - { - } + @Autowired + private SchemaService schemaService; + + @RequestMapping( value = "", method = RequestMethod.GET, produces = { "*/*" } ) + public void getSchemasJson( HttpServletResponse response ) throws IOException + { + List schemas = schemaService.getSchemas(); + MetaData metaData = new MetaData(); + metaData.setSchemas( schemas ); + + JacksonUtils.toJson( response.getOutputStream(), schemas ); + } + + @RequestMapping( value = "/{type}", method = RequestMethod.GET, produces = { "*/*" } ) + public void getSchemaJson( @PathVariable String type, HttpServletResponse response ) throws IOException + { + Schema schema = schemaService.getSchemaBySingularName( type ); + JacksonUtils.toJson( response.getOutputStream(), schema ); + } + + @RequestMapping( value = "", method = RequestMethod.GET, produces = { MediaType.APPLICATION_XML_VALUE } ) + public void getSchemasXml( HttpServletResponse response ) throws IOException + { + List schemas = schemaService.getSchemas(); + MetaData metaData = new MetaData(); + metaData.setSchemas( schemas ); + + JacksonUtils.toXml( response.getOutputStream(), metaData ); + } + + @RequestMapping( value = "/{type}", method = RequestMethod.GET, produces = { MediaType.APPLICATION_XML_VALUE } ) + public void getSchemaXml( @PathVariable String type, HttpServletResponse response ) throws IOException + { + Schema schema = schemaService.getSchemaBySingularName( type ); + JacksonUtils.toXml( response.getOutputStream(), schema ); } }