Example usage for com.liferay.portal.kernel.service.permission PortletPermissionUtil check

List of usage examples for com.liferay.portal.kernel.service.permission PortletPermissionUtil check

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.service.permission PortletPermissionUtil check.

Prototype

public static void check(PermissionChecker permissionChecker, long plid, String portletId, String actionId)
            throws PortalException 

Source Link

Usage

From source file:com.liferay.quick.note.web.internal.portlet.action.SaveMVCActionCommand.java

License:Open Source License

@Override
public boolean processAction(ActionRequest actionRequest, ActionResponse actionResponse)
        throws PortletException {

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

    try {/*w w w  .  j a  v  a  2s.co m*/
        PortletPermissionUtil.check(themeDisplay.getPermissionChecker(), themeDisplay.getLayout(),
                themeDisplay.getPpid(), ActionKeys.CONFIGURATION);

        PortletPreferences portletPreferences = PortletPreferencesFactoryUtil
                .getStrictPortletSetup(themeDisplay.getLayout(), themeDisplay.getPpid());

        if (portletPreferences instanceof StrictPortletPreferencesImpl) {
            throw new PortletPreferencesException.MustBeStrict(themeDisplay.getPpid());
        }

        String color = ParamUtil.getString(actionRequest, "color");
        String data = ParamUtil.getString(actionRequest, "data");

        if (Validator.isNotNull(color)) {
            portletPreferences.setValue("color", color);
        }

        if (Validator.isNotNull(data)) {
            portletPreferences.setValue("data", data);
        }

        portletPreferences.store();
    } catch (Exception e) {
        throw new PortletException(e);
    }

    return true;
}