001
014
015 package com.liferay.portlet.journal.action;
016
017 import com.liferay.portal.kernel.upload.UploadServletRequest;
018 import com.liferay.portal.kernel.util.ContentTypes;
019 import com.liferay.portal.kernel.util.ParamUtil;
020 import com.liferay.portal.util.PortalUtil;
021 import com.liferay.portlet.journal.util.JournalUtil;
022 import com.liferay.util.servlet.ServletResponseUtil;
023
024 import javax.servlet.http.HttpServletRequest;
025 import javax.servlet.http.HttpServletResponse;
026
027 import org.apache.struts.action.Action;
028 import org.apache.struts.action.ActionForm;
029 import org.apache.struts.action.ActionForward;
030 import org.apache.struts.action.ActionMapping;
031
032
035 public class GetArticleContentAction extends Action {
036
037 public ActionForward execute(
038 ActionMapping mapping, ActionForm form, HttpServletRequest request,
039 HttpServletResponse response)
040 throws Exception {
041
042 try {
043 UploadServletRequest uploadRequest =
044 PortalUtil.getUploadServletRequest(request);
045
046 String xml = ParamUtil.getString(uploadRequest, "xml");
047
048 xml = JournalUtil.formatXML(xml);
049
050 String fileName = "article.xml";
051 byte[] bytes = xml.getBytes();
052
053 ServletResponseUtil.sendFile(
054 request, response, fileName, bytes, ContentTypes.TEXT_XML_UTF8);
055
056 return null;
057 }
058 catch (Exception e) {
059 PortalUtil.sendError(e, request, response);
060
061 return null;
062 }
063 }
064
065 }