Author: cschneider Date: Thu Jan 24 09:13:38 2013 New Revision: 1437916 URL: http://svn.apache.org/viewvc?rev=1437916&view=rev Log: SYNCOPE-231 Impement db export for cxf
Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java?rev=1437916&r1=1437915&r2=1437916&view=diff ============================================================================== --- syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java (original) +++ syncope/trunk/core/src/main/java/org/apache/syncope/core/rest/controller/ConfigurationController.java Thu Jan 24 09:13:38 2013 @@ -19,6 +19,7 @@ package org.apache.syncope.core.rest.controller; import java.io.IOException; +import java.io.OutputStream; import java.util.ArrayList; import java.util.HashSet; import java.util.List; @@ -209,9 +210,17 @@ public class ConfigurationController ext public void dbExport(final HttpServletResponse response) { response.setContentType(MediaType.TEXT_XML_VALUE); response.setHeader("Content-Disposition", "attachment; filename=content.xml"); + try { + dbExportInternal(response.getOutputStream()); + } catch (IOException e) { + LOG.error("Getting servlet output stream", e); + } + } + @Transactional(readOnly = true) + public void dbExportInternal(OutputStream os) { try { - importExport.export(response.getOutputStream()); + importExport.export(os); auditManager.audit(Category.configuration, ConfigurationSubCategory.dbExport, Result.success, "Successfully exported database content"); Modified: syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java URL: http://svn.apache.org/viewvc/syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java?rev=1437916&r1=1437915&r2=1437916&view=diff ============================================================================== --- syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java (original) +++ syncope/trunk/core/src/main/java/org/apache/syncope/core/services/ConfigurationServiceImpl.java Thu Jan 24 09:13:38 2013 @@ -56,17 +56,9 @@ public class ConfigurationServiceImpl im @Override public Response dbExport() { - configurationController.dbExport(new DummyHTTPServletResponse()); - // TODO catch output-stream and forward it to response return Response.ok(new StreamingOutput() { - - @Override - public void write(final OutputStream output) throws IOException { -// FileInputStream is = new FileInputStream("/etc/hosts"); -// while (is.available() > 0) { -// output.write(is.read()); -// } -// is.close(); + public void write(final OutputStream os) throws IOException { + configurationController.dbExportInternal(os); } }).build(); }