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