
com.liferay.mobile.device.rules.rule.group.action.LayoutTemplateModificationActionHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com.liferay.mobile.device.rules.service Show documentation
Show all versions of com.liferay.mobile.device.rules.service Show documentation
Liferay Mobile Device Rules Service
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.mobile.device.rules.rule.group.action;
import com.liferay.mobile.device.rules.action.ActionHandler;
import com.liferay.mobile.device.rules.model.MDRAction;
import com.liferay.portal.kernel.model.Layout;
import com.liferay.portal.kernel.model.LayoutTypePortlet;
import com.liferay.portal.kernel.theme.ThemeDisplay;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.UnicodeProperties;
import com.liferay.portal.kernel.util.WebKeys;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.osgi.service.component.annotations.Component;
/**
* @author Edward Han
*/
@Component(immediate = true, service = ActionHandler.class)
public class LayoutTemplateModificationActionHandler implements ActionHandler {
public static String getHandlerType() {
return LayoutTemplateModificationActionHandler.class.getName();
}
@Override
public void applyAction(
MDRAction mdrAction, HttpServletRequest request,
HttpServletResponse response) {
UnicodeProperties mdrActionTypeSettingsProperties =
mdrAction.getTypeSettingsProperties();
String layoutTemplateId = GetterUtil.getString(
mdrActionTypeSettingsProperties.getProperty("layoutTemplateId"));
ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(
WebKeys.THEME_DISPLAY);
Layout layout = themeDisplay.getLayout();
if (layout.isTypePortlet()) {
LayoutTypePortlet layoutTypePortlet =
(LayoutTypePortlet)layout.getLayoutType();
layoutTypePortlet.setLayoutTemplateId(0, layoutTemplateId, false);
}
}
@Override
public Collection getPropertyNames() {
return _propertyNames;
}
@Override
public String getType() {
return getHandlerType();
}
private static final Collection _propertyNames =
Collections.unmodifiableCollection(Arrays.asList("layoutTemplateId"));
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy