001
014
015 package com.liferay.portal.mobile.device.rulegroup.action.impl;
016
017 import com.liferay.portal.kernel.mobile.device.rulegroup.action.ActionHandler;
018 import com.liferay.portal.kernel.util.GetterUtil;
019 import com.liferay.portal.kernel.util.UnicodeProperties;
020 import com.liferay.portal.model.Layout;
021 import com.liferay.portal.model.LayoutTypePortlet;
022 import com.liferay.portal.theme.ThemeDisplay;
023 import com.liferay.portal.util.WebKeys;
024 import com.liferay.portlet.mobiledevicerules.model.MDRAction;
025
026 import java.util.ArrayList;
027 import java.util.Collection;
028 import java.util.Collections;
029
030 import javax.servlet.http.HttpServletRequest;
031 import javax.servlet.http.HttpServletResponse;
032
033
036 public class LayoutTemplateModificationActionHandler implements ActionHandler {
037
038 public static String getHandlerType() {
039 return LayoutTemplateModificationActionHandler.class.getName();
040 }
041
042 @Override
043 public void applyAction(
044 MDRAction mdrAction, HttpServletRequest request,
045 HttpServletResponse response) {
046
047 UnicodeProperties mdrActionTypeSettingsProperties =
048 mdrAction.getTypeSettingsProperties();
049
050 String layoutTemplateId = GetterUtil.getString(
051 mdrActionTypeSettingsProperties.getProperty("layoutTemplateId"));
052
053 ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
054 WebKeys.THEME_DISPLAY);
055
056 Layout layout = themeDisplay.getLayout();
057
058 if (layout.isTypePortlet()) {
059 LayoutTypePortlet layoutTypePortlet =
060 (LayoutTypePortlet)layout.getLayoutType();
061
062 layoutTypePortlet.setLayoutTemplateId(0, layoutTemplateId, false);
063 }
064 }
065
066 @Override
067 public Collection<String> getPropertyNames() {
068 return _propertyNames;
069 }
070
071 @Override
072 public String getType() {
073 return getHandlerType();
074 }
075
076 private static Collection<String> _propertyNames;
077
078 static {
079 _propertyNames = new ArrayList<String>(1);
080
081 _propertyNames.add("layoutTemplateId");
082
083 _propertyNames = Collections.unmodifiableCollection(_propertyNames);
084 }
085
086 }