001
014
015 package com.liferay.portlet.journal.action;
016
017 import com.liferay.portal.kernel.util.ContentTypes;
018 import com.liferay.portal.kernel.util.ParamUtil;
019 import com.liferay.portal.util.PortalUtil;
020 import com.liferay.portlet.journal.model.JournalStructure;
021 import com.liferay.portlet.journal.service.JournalStructureLocalServiceUtil;
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
036 public class GetStructureAction extends Action {
037
038 public ActionForward execute(
039 ActionMapping mapping, ActionForm form, HttpServletRequest request,
040 HttpServletResponse response)
041 throws Exception {
042
043 try {
044 long groupId = ParamUtil.getLong(request, "groupId");
045 String structureId = ParamUtil.getString(request, "structureId");
046
047 JournalStructure structure =
048 JournalStructureLocalServiceUtil.getStructure(
049 groupId, structureId);
050
051 String fileName = null;
052 byte[] bytes = structure.getXsd().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 }