← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10099: FRED-API: minor objectMapper fix

 

------------------------------------------------------------
revno: 10099
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2013-03-09 11:34:50 +0300
message:
  FRED-API: minor objectMapper fix
modified:
  dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.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-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java'
--- dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java	2013-03-09 06:35:22 +0000
+++ dhis-2/dhis-web/dhis-web-api-fred/src/main/java/org/hisp/dhis/web/webapi/v1/controller/FacilityController.java	2013-03-09 08:34:50 +0000
@@ -28,6 +28,7 @@
  */
 
 import org.apache.commons.lang3.StringEscapeUtils;
+import org.codehaus.jackson.map.ObjectMapper;
 import org.hisp.dhis.api.controller.organisationunit.OrganisationUnitLevelController;
 import org.hisp.dhis.common.DeleteNotAllowedException;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
@@ -114,6 +115,9 @@
     @Autowired
     private Validator validator;
 
+    @Autowired
+    private ObjectMapper objectMapper;
+
     @InitBinder
     protected void initBinder( WebDataBinder binder )
     {
@@ -507,7 +511,7 @@
             facility = conversionService.convert( organisationUnit, Facility.class );
             List<OrganisationUnitLevel> organisationUnitLevels = organisationUnitService.getOrganisationUnitLevels();
             addHierarchyPropertyToFacility( organisationUnitLevels, organisationUnit, facility );
-            json = new ObjectMapperFactoryBean().getObject().writeValueAsString( facility );
+            json = objectMapper.writeValueAsString( facility );
 
             return new ResponseEntity<String>( json, headers, HttpStatus.CREATED );
         }
@@ -566,7 +570,7 @@
                 Facility old_facility = conversionService.convert( organisationUnit, Facility.class );
                 List<OrganisationUnitLevel> organisationUnitLevels = organisationUnitService.getOrganisationUnitLevels();
                 addHierarchyPropertyToFacility( organisationUnitLevels, organisationUnitUpdate, old_facility );
-                String body = new ObjectMapperFactoryBean().getObject().writeValueAsString( old_facility );
+                String body = objectMapper.writeValueAsString( old_facility );
 
                 String ETag = generateETagHeaderValue( body.getBytes() );