=== modified file 'dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SynchronizationController.java' --- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SynchronizationController.java 2015-10-06 17:44:37 +0000 +++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SynchronizationController.java 2015-10-20 03:59:54 +0000 @@ -28,14 +28,8 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -import static org.hisp.dhis.webapi.utils.ContextUtils.CONTENT_TYPE_JSON; - -import java.io.IOException; - -import javax.servlet.http.HttpServletResponse; - -import org.hisp.dhis.dxf2.common.JacksonUtils; import org.hisp.dhis.dxf2.importsummary.ImportSummary; +import org.hisp.dhis.dxf2.render.RenderService; import org.hisp.dhis.dxf2.synch.AvailabilityStatus; import org.hisp.dhis.dxf2.synch.SynchronizationManager; import org.hisp.dhis.setting.Setting; @@ -48,6 +42,11 @@ import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.client.RestTemplate; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +import static org.hisp.dhis.webapi.utils.ContextUtils.CONTENT_TYPE_JSON; + /** * @author Lars Helge Overland */ @@ -56,13 +55,16 @@ public class SynchronizationController { public static final String RESOURCE_PATH = "/synchronization"; - + @Autowired private SynchronizationManager synchronizationManager; - + @Autowired private RestTemplate restTemplate; + @Autowired + private RenderService renderService; + @PreAuthorize( "hasRole('ALL') or hasRole('F_EXPORT_DATA')" ) @RequestMapping( value = "/dataPush", method = RequestMethod.POST ) public void execute( HttpServletResponse response ) @@ -71,18 +73,18 @@ ImportSummary summary = synchronizationManager.executeDataPush(); response.setContentType( CONTENT_TYPE_JSON ); - JacksonUtils.toJson( response.getOutputStream(), summary ); + renderService.toJson( response.getOutputStream(), summary ); } - + @PreAuthorize( "hasRole('ALL')" ) @RequestMapping( value = "/metadataPull", method = RequestMethod.POST ) public void importMetaData( @RequestParam String url, HttpServletResponse response ) throws IOException { org.hisp.dhis.dxf2.metadata.ImportSummary summary = synchronizationManager.executeMetadataPull( url ); - + response.setContentType( CONTENT_TYPE_JSON ); - JacksonUtils.toJson( response.getOutputStream(), summary ); + renderService.toJson( response.getOutputStream(), summary ); } @RequestMapping( value = "/availability", method = RequestMethod.GET, produces = "application/json" ) @@ -90,7 +92,7 @@ { return synchronizationManager.isRemoteServerAvailable(); } - + @RequestMapping( value = "/metadataRepo", method = RequestMethod.GET, produces = "application/json" ) public @ResponseBody String getMetadataRepoIndex() {