=== 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-12-19 11:18:40 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.java 2014-12-19 11:37:11 +0000 @@ -57,47 +57,23 @@ return new Schemas( schemaService.getSortedSchemas() ); } - @RequestMapping( value = "/{type:.*}" ) + @RequestMapping( value = "/{type}" ) public @ResponseBody Schema getSchema( @PathVariable String type ) { - Schema schema = schemaService.getSchemaBySingularName( type ); + Schema schema = getSchemaFromType( type ); if ( schema != null ) { return schema; } - try - { - schema = schemaService.getSchema( Class.forName( type ) ); - - if ( schema != null ) - { - return schema; - } - } - catch ( ClassNotFoundException ignored ) - { - } - throw new HttpClientErrorException( HttpStatus.NOT_FOUND, "Type " + type + " does not exist." ); } - @RequestMapping( value = "/{type:.*}/{property}" ) + @RequestMapping( value = "/{type}/{property}" ) public @ResponseBody Property getSchemaProperty( @PathVariable String type, @PathVariable String property ) { - Schema schema = schemaService.getSchemaBySingularName( type ); - - if ( schema == null ) - { - try - { - schema = schemaService.getSchema( Class.forName( type ) ); - } - catch ( ClassNotFoundException ignored ) - { - } - } + Schema schema = getSchemaFromType( type ); if ( schema == null ) { @@ -111,4 +87,22 @@ throw new HttpClientErrorException( HttpStatus.NOT_FOUND, "Property " + property + " does not exist on type " + type + "." ); } + + private Schema getSchemaFromType( String type ) + { + Schema schema = schemaService.getSchemaBySingularName( type ); + + if ( schema == null ) + { + try + { + schema = schemaService.getSchema( Class.forName( type ) ); + } + catch ( ClassNotFoundException ignored ) + { + } + } + + return schema; + } }