1
14
15 package com.liferay.portlet.journal.action;
16
17 import com.liferay.portal.kernel.language.LanguageUtil;
18 import com.liferay.portal.kernel.util.ContentTypes;
19 import com.liferay.portal.kernel.util.ParamUtil;
20 import com.liferay.portal.kernel.workflow.StatusConstants;
21 import com.liferay.portal.util.PortalUtil;
22 import com.liferay.portlet.journal.model.JournalArticle;
23 import com.liferay.portlet.journal.service.JournalArticleLocalServiceUtil;
24 import com.liferay.util.servlet.ServletResponseUtil;
25
26 import javax.servlet.http.HttpServletRequest;
27 import javax.servlet.http.HttpServletResponse;
28
29 import org.apache.struts.action.Action;
30 import org.apache.struts.action.ActionForm;
31 import org.apache.struts.action.ActionForward;
32 import org.apache.struts.action.ActionMapping;
33
34
41 public class GetLatestArticleContentAction extends Action {
42
43 public ActionForward execute(
44 ActionMapping mapping, ActionForm form, HttpServletRequest request,
45 HttpServletResponse response)
46 throws Exception {
47
48 try {
49 long groupId = ParamUtil.getLong(request, "groupId");
50 String articleId = ParamUtil.getString(request, "articleId");
51
52 String languageId = LanguageUtil.getLanguageId(request);
53
54 JournalArticle article =
55 JournalArticleLocalServiceUtil.getLatestArticle(
56 groupId, articleId, StatusConstants.APPROVED);
57
58 String fileName = "content.xml";
59 byte[] bytes = article.getContentByLocale(languageId).getBytes();
60
61 ServletResponseUtil.sendFile(
62 response, fileName, bytes, ContentTypes.TEXT_XML_UTF8);
63
64 return null;
65 }
66 catch (Exception e) {
67 PortalUtil.sendError(e, request, response);
68
69 return null;
70 }
71 }
72
73 }