1
22
23 package com.liferay.portlet.journal.action;
24
25 import com.liferay.portal.kernel.util.ContentTypes;
26 import com.liferay.portal.kernel.util.ParamUtil;
27 import com.liferay.portal.struts.ActionConstants;
28 import com.liferay.portlet.journal.model.JournalStructure;
29 import com.liferay.portlet.journal.service.JournalStructureLocalServiceUtil;
30 import com.liferay.util.servlet.ServletResponseUtil;
31
32 import javax.servlet.http.HttpServletRequest;
33 import javax.servlet.http.HttpServletResponse;
34 import javax.servlet.jsp.PageContext;
35
36 import org.apache.struts.action.Action;
37 import org.apache.struts.action.ActionForm;
38 import org.apache.struts.action.ActionForward;
39 import org.apache.struts.action.ActionMapping;
40
41
48 public class GetStructureAction extends Action {
49
50 public ActionForward execute(
51 ActionMapping mapping, ActionForm form, HttpServletRequest req,
52 HttpServletResponse res)
53 throws Exception {
54
55 try {
56 long groupId = ParamUtil.getLong(req, "groupId");
57 String structureId = ParamUtil.getString(req, "structureId");
58
59 JournalStructure structure =
60 JournalStructureLocalServiceUtil.getStructure(
61 groupId, structureId);
62
63 String fileName = null;
64 byte[] byteArray = structure.getXsd().getBytes();
65
66 ServletResponseUtil.sendFile(
67 res, fileName, byteArray, ContentTypes.TEXT_XML_UTF8);
68
69 return null;
70 }
71 catch (Exception e) {
72 req.setAttribute(PageContext.EXCEPTION, e);
73
74 return mapping.findForward(ActionConstants.COMMON_ERROR);
75 }
76 }
77
78 }