Example usage for com.liferay.portal.kernel.model Plugin TYPE_PORTLET

List of usage examples for com.liferay.portal.kernel.model Plugin TYPE_PORTLET

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.model Plugin TYPE_PORTLET.

Prototype

String TYPE_PORTLET

To view the source code for com.liferay.portal.kernel.model Plugin TYPE_PORTLET.

Click Source Link

Usage

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

License:Open Source License

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

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

    String pluginId = ParamUtil.getString(actionRequest, "pluginId");
    String pluginType = ParamUtil.getString(actionRequest, "pluginType");

    String[] roles = StringUtil.split(ParamUtil.getString(actionRequest, "roles"), CharPool.NEW_LINE);

    Arrays.sort(roles);/*from  w  w w  . j av  a 2  s. c  o m*/

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

    if (pluginType.equals(Plugin.TYPE_PORTLET)) {
        _portletService.updatePortlet(themeDisplay.getCompanyId(), pluginId, StringPool.BLANK, active);
    } else {
        if (roles.length == 0) {
            PluginSetting pluginSetting = _pluginSettingLocalService
                    .getPluginSetting(themeDisplay.getCompanyId(), pluginId, pluginType);

            roles = StringUtil.split(pluginSetting.getRoles());
        }

        _pluginSettingService.updatePluginSetting(themeDisplay.getCompanyId(), pluginId, pluginType,
                StringUtil.merge(roles), active);
    }
}

From source file:com.liferay.plugins.admin.web.internal.portlet.action.EditPluginActionCommand.java

License:Open Source License

protected void updatePluginSetting(ActionRequest actionRequest) throws Exception {

    long companyId = _portal.getCompanyId(actionRequest);
    String pluginId = ParamUtil.getString(actionRequest, "pluginId");
    String pluginType = ParamUtil.getString(actionRequest, "pluginType");

    String[] rolesArray = StringUtil.split(ParamUtil.getString(actionRequest, "roles"), '\n');

    Arrays.sort(rolesArray);//from  ww w .  j a  v  a 2 s  .  com

    String roles = StringUtil.merge(rolesArray);

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

    if (pluginType.equals(Plugin.TYPE_PORTLET)) {
        String portletId = pluginId;

        _portletService.updatePortlet(companyId, portletId, StringPool.BLANK, active);
    } else {
        _pluginSettingService.updatePluginSetting(companyId, pluginId, pluginType, roles, active);
    }
}