dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #30841
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15683: Minor fixes, send correct format for put/post in abstractcrudcontroller, support @RequestBody in ...
------------------------------------------------------------
revno: 15683
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-06-15 11:24:05 +0200
message:
Minor fixes, send correct format for put/post in abstractcrudcontroller, support @RequestBody in RenderServiceMessageConverter.
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/RenderServiceMessageConverter.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/AbstractCrudController.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2014-06-15 09:10:42 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/AbstractCrudController.java 2014-06-15 09:24:05 +0000
@@ -278,7 +278,7 @@
T parsed = renderService.fromXml( request.getInputStream(), getEntityClass() );
ImportTypeSummary summary = importService.importObject( currentUserService.getCurrentUser().getUid(), parsed, ImportStrategy.CREATE );
- renderService.toJson( response.getOutputStream(), summary );
+ renderService.toXml( response.getOutputStream(), summary );
}
@RequestMapping( method = RequestMethod.POST, consumes = "application/json" )
@@ -320,7 +320,7 @@
((BaseIdentifiableObject) parsed).setUid( uid );
ImportTypeSummary summary = importService.importObject( currentUserService.getCurrentUser().getUid(), parsed, ImportStrategy.UPDATE );
- renderService.toJson( response.getOutputStream(), summary );
+ renderService.toXml( response.getOutputStream(), summary );
}
@RequestMapping( value = "/{uid}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE )
=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/RenderServiceMessageConverter.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/RenderServiceMessageConverter.java 2014-06-02 07:45:44 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/RenderServiceMessageConverter.java 2014-06-15 09:24:05 +0000
@@ -89,12 +89,23 @@
@Override
protected boolean canRead( MediaType mediaType )
{
- return false;
+ return true;
}
@Override
protected Object readInternal( Class<?> clazz, HttpInputMessage inputMessage ) throws IOException, HttpMessageNotReadableException
{
+ MediaType mediaType = inputMessage.getHeaders().getContentType();
+
+ if ( mediaType.getSubtype().equals( "json" ) )
+ {
+ return renderService.fromJson( inputMessage.getBody(), clazz );
+ }
+ else if ( mediaType.getSubtype().equals( "xml" ) )
+ {
+ return renderService.fromXml( inputMessage.getBody(), clazz );
+ }
+
return null;
}