dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #34604
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17737: revert option for getting schema by class name, mapping swallow ups extension, so can't get json/...
------------------------------------------------------------
revno: 17737
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-12-19 12:37:11 +0100
message:
revert option for getting schema by class name, mapping swallow ups extension, so can't get json/xml explicit without using accept header
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SchemaController.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
=== 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;
+ }
}