}
Map<String, Object> params = getParams(request);
JCRSessionWrapper session = JCRSessionFactory.getInstance().getCurrentUserSession(workspace);
JCRNodeWrapper exportRoot = null;
if (request.getParameter("root") != null) {
exportRoot = session.getNode(request.getParameter("root"));
}
if ("all".equals(exportFormat)) {
if (!getCurrentUser().isRoot()) {
throw new JahiaUnauthorizedException("Only root user can perform export of all content");
}
response.setContentType("application/zip");
//make sure this file is not cached by the client (or a proxy middleman)
WebUtils.setNoCacheHeaders(response);
params.put(ImportExportService.INCLUDE_ALL_FILES, Boolean.TRUE);
params.put(ImportExportService.INCLUDE_TEMPLATES, Boolean.TRUE);
params.put(ImportExportService.INCLUDE_SITE_INFOS, Boolean.TRUE);
params.put(ImportExportService.INCLUDE_DEFINITIONS, Boolean.TRUE);
params.put(ImportExportService.VIEW_WORKFLOW, Boolean.TRUE);
params.put(ImportExportService.XSL_PATH, cleanupXsl);
OutputStream outputStream = response.getOutputStream();
importExportService.exportAll(outputStream, params);
outputStream.close();
} else if ("site".equals(exportFormat)) {
if (!getCurrentUser().isRoot()) {
throw new JahiaUnauthorizedException("Only root user can perform export of a site");
}
List<JahiaSite> sites = new ArrayList<JahiaSite>();
String[] sitekeys = request.getParameterValues("sitebox");
if (sitekeys != null) {
for (String sitekey : sitekeys) {
JahiaSite site = ServicesRegistry.getInstance().getJahiaSitesService().getSiteByKey(sitekey);
sites.add(site);
}
}
if (sites.isEmpty()) {
JahiaAdministration.doRedirect(request, response, request.getSession(),
JahiaAdministration.JSP_PATH + "no_sites_selected.jsp");
} else {
response.setContentType("application/zip");
//make sure this file is not cached by the client (or a proxy middleman)
WebUtils.setNoCacheHeaders(response);
params.put(ImportExportService.INCLUDE_ALL_FILES, Boolean.TRUE);
params.put(ImportExportService.INCLUDE_TEMPLATES, Boolean.TRUE);
params.put(ImportExportService.INCLUDE_SITE_INFOS, Boolean.TRUE);
params.put(ImportExportService.INCLUDE_DEFINITIONS, Boolean.TRUE);
params.put(ImportExportService.VIEW_WORKFLOW, Boolean.TRUE);
params.put(ImportExportService.XSL_PATH, cleanupXsl);
OutputStream outputStream = response.getOutputStream();
importExportService.exportSites(outputStream, params, sites);
outputStream.close();
}
} else if ("xml".equals(exportFormat)) {
JCRNodeWrapper node = session.getNode(nodePath);
response.setContentType("text/xml");
//make sure this file is not cached by the client (or a proxy middleman)
WebUtils.setNoCacheHeaders(response);
if ("template".equals(request.getParameter(CLEANUP))) {
params.put(ImportExportService.XSL_PATH, templatesCleanupXsl);
} else if ("simple".equals(request.getParameter(CLEANUP))) {
params.put(ImportExportService.XSL_PATH, cleanupXsl);
}
OutputStream outputStream = response.getOutputStream();
importExportService.exportNode(node, exportRoot, outputStream, params);
} else if ("zip".equals(exportFormat)) {
JCRNodeWrapper node = session.getNode(nodePath);
response.setContentType("application/zip");
//make sure this file is not cached by the client (or a proxy middleman)
WebUtils.setNoCacheHeaders(response);
if ("template".equals(request.getParameter(CLEANUP))) {