dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #40826
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20780: use RenderService in SynchronizationController
------------------------------------------------------------
revno: 20780
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-10-20 10:59:54 +0700
message:
use RenderService in SynchronizationController
modified:
dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/controller/SynchronizationController.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/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()
{