1
22
23 package com.liferay.portlet.communities.action;
24
25 import com.liferay.portal.kernel.util.ParamUtil;
26 import com.liferay.portal.service.LayoutServiceUtil;
27 import com.liferay.portal.struts.ActionConstants;
28 import com.liferay.portal.struts.PortletAction;
29 import com.liferay.portlet.ActionResponseImpl;
30 import com.liferay.util.servlet.ServletResponseUtil;
31
32 import javax.portlet.ActionRequest;
33 import javax.portlet.ActionResponse;
34 import javax.portlet.PortletConfig;
35
36 import javax.servlet.http.HttpServletResponse;
37
38 import org.apache.commons.logging.Log;
39 import org.apache.commons.logging.LogFactory;
40 import org.apache.struts.action.ActionForm;
41 import org.apache.struts.action.ActionMapping;
42
43
50 public class ExportPagesAction extends PortletAction {
51
52 public void processAction(
53 ActionMapping mapping, ActionForm form, PortletConfig config,
54 ActionRequest req, ActionResponse res)
55 throws Exception {
56
57 try {
58 long groupId = ParamUtil.getLong(req, "groupId");
59 boolean privateLayout = ParamUtil.getBoolean(req, "privateLayout");
60 String fileName = ParamUtil.getString(req, "exportFileName");
61
62 byte[] byteArray = LayoutServiceUtil.exportLayouts(
63 groupId, privateLayout, req.getParameterMap());
64
65 HttpServletResponse httpRes =
66 ((ActionResponseImpl)res).getHttpServletResponse();
67
68 ServletResponseUtil.sendFile(httpRes, fileName, byteArray);
69
70 setForward(req, ActionConstants.COMMON_NULL);
71 }
72 catch (Exception e) {
73 _log.error(e, e);
74 }
75 }
76
77 private static Log _log = LogFactory.getLog(ExportPagesAction.class);
78
79 }