001
014
015 package com.liferay.portlet.journal.action;
016
017 import com.liferay.portal.kernel.servlet.ServletResponseUtil;
018 import com.liferay.portal.kernel.upload.UploadServletRequest;
019 import com.liferay.portal.kernel.util.ContentTypes;
020 import com.liferay.portal.kernel.util.ParamUtil;
021 import com.liferay.portal.util.PortalUtil;
022 import com.liferay.portlet.dynamicdatamapping.util.DDMXMLUtil;
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 @Override
038 public ActionForward execute(
039 ActionMapping actionMapping, ActionForm actionForm,
040 HttpServletRequest request, HttpServletResponse response)
041 throws Exception {
042
043 try {
044 UploadServletRequest uploadServletRequest =
045 PortalUtil.getUploadServletRequest(request);
046
047 String xml = ParamUtil.getString(uploadServletRequest, "xml");
048
049 xml = DDMXMLUtil.formatXML(xml);
050
051 String fileName = "article.xml";
052 byte[] bytes = xml.getBytes();
053
054 ServletResponseUtil.sendFile(
055 request, response, fileName, bytes, ContentTypes.TEXT_XML_UTF8);
056
057 return null;
058 }
059 catch (Exception e) {
060 PortalUtil.sendError(e, request, response);
061
062 return null;
063 }
064 }
065
066 }