1
19
20 package com.liferay.portlet.journal.action;
21
22 import com.liferay.portal.kernel.util.ContentTypes;
23 import com.liferay.portal.kernel.util.ParamUtil;
24 import com.liferay.portal.util.PortalUtil;
25 import com.liferay.portlet.journal.model.JournalStructure;
26 import com.liferay.portlet.journal.service.JournalStructureLocalServiceUtil;
27 import com.liferay.util.servlet.ServletResponseUtil;
28
29 import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletResponse;
31
32 import org.apache.struts.action.Action;
33 import org.apache.struts.action.ActionForm;
34 import org.apache.struts.action.ActionForward;
35 import org.apache.struts.action.ActionMapping;
36
37
44 public class GetStructureAction extends Action {
45
46 public ActionForward execute(
47 ActionMapping mapping, ActionForm form, HttpServletRequest request,
48 HttpServletResponse response)
49 throws Exception {
50
51 try {
52 long groupId = ParamUtil.getLong(request, "groupId");
53 String structureId = ParamUtil.getString(request, "structureId");
54
55 JournalStructure structure =
56 JournalStructureLocalServiceUtil.getStructure(
57 groupId, structureId);
58
59 String fileName = null;
60 byte[] bytes = structure.getXsd().getBytes();
61
62 ServletResponseUtil.sendFile(
63 response, fileName, bytes, ContentTypes.TEXT_XML_UTF8);
64
65 return null;
66 }
67 catch (Exception e) {
68 PortalUtil.sendError(e, request, response);
69
70 return null;
71 }
72 }
73
74 }