001
014
015 package com.liferay.portlet.layoutsetprototypes.action;
016
017 import com.liferay.portal.NoSuchLayoutSetPrototypeException;
018 import com.liferay.portal.kernel.util.ParamUtil;
019 import com.liferay.portal.kernel.util.Validator;
020 import com.liferay.portal.model.Group;
021 import com.liferay.portal.model.LayoutSetPrototype;
022 import com.liferay.portal.service.LayoutSetPrototypeLocalServiceUtil;
023 import com.liferay.portal.service.LayoutSetPrototypeServiceUtil;
024 import com.liferay.portal.theme.ThemeDisplay;
025 import com.liferay.portal.util.PortalUtil;
026 import com.liferay.portal.util.WebKeys;
027
028 import javax.portlet.PortletRequest;
029
030 import javax.servlet.http.HttpServletRequest;
031
032
036 public class ActionUtil {
037
038 public static void getLayoutSetPrototype(HttpServletRequest request)
039 throws Exception {
040
041 LayoutSetPrototype layoutSetPrototype = null;
042
043 try {
044 long layoutSetPrototypeId = ParamUtil.getLong(
045 request, "layoutSetPrototypeId");
046
047 if (Validator.isNotNull(layoutSetPrototypeId)) {
048 layoutSetPrototype =
049 LayoutSetPrototypeServiceUtil.getLayoutSetPrototype(
050 layoutSetPrototypeId);
051 }
052 else {
053 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
054 WebKeys.THEME_DISPLAY);
055
056 Group group = themeDisplay.getScopeGroup();
057
058 if (group.isLayoutSetPrototype()) {
059 layoutSetPrototype =
060 LayoutSetPrototypeLocalServiceUtil.
061 getLayoutSetPrototype(group.getClassPK());
062 }
063 }
064 }
065 catch (NoSuchLayoutSetPrototypeException nslspe) {
066 }
067
068 request.setAttribute(WebKeys.LAYOUT_PROTOTYPE, layoutSetPrototype);
069 }
070
071 public static void getLayoutSetPrototype(PortletRequest portletRequest)
072 throws Exception {
073
074 HttpServletRequest request = PortalUtil.getHttpServletRequest(
075 portletRequest);
076
077 getLayoutSetPrototype(request);
078 }
079
080 }