Example usage for com.liferay.portal.kernel.util WebKeys PLUGIN_THEMES

List of usage examples for com.liferay.portal.kernel.util WebKeys PLUGIN_THEMES

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util WebKeys PLUGIN_THEMES.

Prototype

String PLUGIN_THEMES

To view the source code for com.liferay.portal.kernel.util WebKeys PLUGIN_THEMES.

Click Source Link

Usage

From source file:com.liferay.marketplace.app.manager.web.internal.portlet.MarketplaceAppManagerPortlet.java

License:Open Source License

public void updatePluginSettings(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String[] contextNames = StringUtil.split(ParamUtil.getString(actionRequest, "contextNames"));

    boolean active = ParamUtil.getBoolean(actionRequest, "active");

    for (String contextName : contextNames) {
        ServletContext servletContext = ServletContextPool.get(contextName);

        List<LayoutTemplate> layoutTemplates = (List<LayoutTemplate>) servletContext
                .getAttribute(WebKeys.PLUGIN_LAYOUT_TEMPLATES);

        if (layoutTemplates != null) {
            for (LayoutTemplate layoutTemplate : layoutTemplates) {
                PluginSetting pluginSetting = _pluginSettingLocalService.getPluginSetting(
                        themeDisplay.getCompanyId(), layoutTemplate.getLayoutTemplateId(),
                        Plugin.TYPE_LAYOUT_TEMPLATE);

                _pluginSettingService.updatePluginSetting(themeDisplay.getCompanyId(),
                        layoutTemplate.getLayoutTemplateId(), Plugin.TYPE_LAYOUT_TEMPLATE,
                        pluginSetting.getRoles(), active);
            }/*from   w  ww .j  a v  a 2 s.  c  o  m*/
        }

        List<Portlet> portlets = (List<Portlet>) servletContext.getAttribute(WebKeys.PLUGIN_PORTLETS);

        if (portlets != null) {
            for (Portlet portlet : portlets) {
                _portletService.updatePortlet(themeDisplay.getCompanyId(), portlet.getPortletId(),
                        StringPool.BLANK, active);
            }
        }

        List<Theme> themes = (List<Theme>) servletContext.getAttribute(WebKeys.PLUGIN_THEMES);

        if (themes != null) {
            for (Theme theme : themes) {
                PluginSetting pluginSetting = _pluginSettingLocalService
                        .getPluginSetting(themeDisplay.getCompanyId(), theme.getThemeId(), Plugin.TYPE_THEME);

                _pluginSettingService.updatePluginSetting(themeDisplay.getCompanyId(), theme.getThemeId(),
                        Plugin.TYPE_THEME, pluginSetting.getRoles(), active);
            }
        }
    }
}

From source file:com.liferay.marketplace.appmanager.portlet.AppManagerPortlet.java

License:Open Source License

public void updatePluginSettings(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

    ThemeDisplay themeDisplay = (ThemeDisplay) actionRequest.getAttribute(WebKeys.THEME_DISPLAY);

    String[] contextNames = StringUtil.split(ParamUtil.getString(actionRequest, "contextNames"));

    boolean active = ParamUtil.getBoolean(actionRequest, "active");

    for (String contextName : contextNames) {
        ServletContext servletContext = ServletContextPool.get(contextName);

        List<LayoutTemplate> layoutTemplates = (List<LayoutTemplate>) servletContext
                .getAttribute(WebKeys.PLUGIN_LAYOUT_TEMPLATES);

        if (layoutTemplates != null) {
            for (LayoutTemplate layoutTemplate : layoutTemplates) {
                PluginSetting pluginSetting = PluginSettingLocalServiceUtil.getPluginSetting(
                        themeDisplay.getCompanyId(), layoutTemplate.getLayoutTemplateId(),
                        Plugin.TYPE_LAYOUT_TEMPLATE);

                PluginSettingServiceUtil.updatePluginSetting(themeDisplay.getCompanyId(),
                        layoutTemplate.getLayoutTemplateId(), Plugin.TYPE_LAYOUT_TEMPLATE,
                        pluginSetting.getRoles(), active);
            }/*  w w  w . j  a v a 2s.  c  om*/
        }

        List<Portlet> portlets = (List<Portlet>) servletContext.getAttribute(WebKeys.PLUGIN_PORTLETS);

        if (portlets != null) {
            for (Portlet portlet : portlets) {
                PortletServiceUtil.updatePortlet(themeDisplay.getCompanyId(), portlet.getPortletId(),
                        StringPool.BLANK, active);
            }
        }

        List<Theme> themes = (List<Theme>) servletContext.getAttribute(WebKeys.PLUGIN_THEMES);

        if (themes != null) {
            for (Theme theme : themes) {
                PluginSetting pluginSetting = PluginSettingLocalServiceUtil
                        .getPluginSetting(themeDisplay.getCompanyId(), theme.getThemeId(), Plugin.TYPE_THEME);

                PluginSettingServiceUtil.updatePluginSetting(themeDisplay.getCompanyId(), theme.getThemeId(),
                        Plugin.TYPE_THEME, pluginSetting.getRoles(), active);
            }
        }
    }
}