001
014
015 package com.liferay.portlet.dynamicdatamapping.action;
016
017 import com.liferay.portal.kernel.util.ParamUtil;
018 import com.liferay.portal.util.PortalUtil;
019 import com.liferay.portal.util.WebKeys;
020 import com.liferay.portlet.dynamicdatamapping.model.DDMStructure;
021 import com.liferay.portlet.dynamicdatamapping.model.DDMTemplate;
022 import com.liferay.portlet.dynamicdatamapping.service.DDMStructureServiceUtil;
023 import com.liferay.portlet.dynamicdatamapping.service.DDMTemplateLocalServiceUtil;
024
025 import javax.portlet.PortletRequest;
026
027 import javax.servlet.http.HttpServletRequest;
028
029
034 public class ActionUtil {
035
036 public static void getStructure(HttpServletRequest request)
037 throws Exception {
038
039 long structureId = ParamUtil.getLong(request, "structureId");
040
041 DDMStructure structure = null;
042
043 if (structureId > 0) {
044 structure = DDMStructureServiceUtil.getStructure(structureId);
045 }
046
047 request.setAttribute(WebKeys.DYNAMIC_DATA_MAPPING_STRUCTURE, structure);
048 }
049
050 public static void getStructure(PortletRequest portletRequest)
051 throws Exception {
052
053 HttpServletRequest request = PortalUtil.getHttpServletRequest(
054 portletRequest);
055
056 getStructure(request);
057 }
058
059 public static void getTemplate(HttpServletRequest request)
060 throws Exception {
061
062 long templateId = ParamUtil.getLong(request, "templateId");
063
064 DDMTemplate template = null;
065
066 if (templateId > 0) {
067 template = DDMTemplateLocalServiceUtil.getDDMTemplate(templateId);
068 }
069
070 request.setAttribute(WebKeys.DYNAMIC_DATA_MAPPING_TEMPLATE, template);
071 }
072
073 public static void getTemplate(PortletRequest portletRequest)
074 throws Exception {
075
076 HttpServletRequest request = PortalUtil.getHttpServletRequest(
077 portletRequest);
078
079 getTemplate(request);
080 }
081
082 }