=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java' --- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java 2014-10-01 11:50:02 +0000 +++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/Property.java 2014-10-12 08:32:32 +0000 @@ -35,8 +35,6 @@ import org.hisp.dhis.common.DxfNamespaces; import org.hisp.dhis.common.IdentifiableObject; import org.hisp.dhis.common.NameableObject; -import org.hisp.dhis.node.annotation.NodeRoot; -import org.hisp.dhis.node.annotation.NodeSimple; import org.springframework.core.Ordered; import java.lang.reflect.Method; @@ -45,19 +43,16 @@ * @author Morten Olav Hansen */ @JacksonXmlRootElement( localName = "property", namespace = DxfNamespaces.DXF_2_0 ) -@NodeRoot( isWritable = false, isPersisted = false ) public class Property implements Ordered { /** * Class for property. */ - @NodeSimple private Class klass; /** * If this property is a collection, this is the class of the items inside the collection. */ - @NodeSimple private Class itemKlass; /** @@ -74,32 +69,27 @@ * Name for this property, if this class is a collection, it is the name of the items -inside- the collection * and not the collection wrapper itself. */ - @NodeSimple private String name; /** * Name for actual field, used to persistence operations and getting setter/getter. */ - @NodeSimple private String fieldName; /** * Is this property persisted somewhere. This property will be used to create criteria queries * on demand (default: false) */ - @NodeSimple private boolean persisted; /** * Name of collection wrapper. */ - @NodeSimple private String collectionName; /** * If this Property is a collection, should it be wrapped with collectionName? */ - @NodeSimple private boolean collectionWrapping; /** @@ -107,19 +97,16 @@ * * @see org.hisp.dhis.common.annotation.Description */ - @NodeSimple private String description; /** * Namespace used for this property. */ - @NodeSimple private String namespace; /** * Usually only used for XML. Is this property considered an attribute. */ - @NodeSimple private boolean attribute; /** @@ -128,7 +115,6 @@ * of the collection, e.g. List would set simple to be true, but List would set it * to false. */ - @NodeSimple private boolean simple; /** @@ -136,14 +122,12 @@ * * @see java.util.Collection */ - @NodeSimple private boolean collection; /** * If this property is a complex object or a collection, is this property considered * the owner of that relationship (important for imports etc). */ - @NodeSimple private boolean owner; /** @@ -151,7 +135,6 @@ * * @see org.hisp.dhis.common.IdentifiableObject */ - @NodeSimple private boolean identifiableObject; /** @@ -159,13 +142,16 @@ * * @see org.hisp.dhis.common.NameableObject */ - @NodeSimple private boolean nameableObject; - @NodeSimple + /** + * Can this property be read. + */ private boolean readable; - @NodeSimple + /** + * Can this property be written to. + */ private boolean writable; public Property() === modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java 2014-08-13 13:25:19 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java 2014-10-12 08:32:32 +0000 @@ -33,17 +33,19 @@ import org.hisp.dhis.schema.SchemaService; import org.hisp.dhis.schema.Schemas; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; 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 org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.client.HttpClientErrorException; /** * @author Morten Olav Hansen */ @Controller -@RequestMapping( value = "/schemas", method = RequestMethod.GET ) +@RequestMapping(value = "/schemas", method = RequestMethod.GET) public class SchemaController { @Autowired @@ -55,10 +57,17 @@ return new Schemas( schemaService.getSortedSchemas() ); } - @RequestMapping( value = "/{type}" ) + @RequestMapping(value = "/{type}") public @ResponseBody Schema getSchema( @PathVariable String type ) { - return schemaService.getSchemaBySingularName( type ); + Schema schema = schemaService.getSchemaBySingularName( type ); + + if ( schema != null ) + { + return schema; + } + + throw new HttpClientErrorException( HttpStatus.NOT_FOUND, "Type " + type + " does not exist." ); } @RequestMapping( value = "/{type}/{property}" ) @@ -71,6 +80,6 @@ return schema.getPropertyMap().get( property ); } - return null; + throw new HttpClientErrorException( HttpStatus.NOT_FOUND, "Property " + property + " does not exist on type " + type + "." ); } }