Example usage for com.liferay.portal.kernel.security.permission ActionKeys CONFIGURATION

List of usage examples for com.liferay.portal.kernel.security.permission ActionKeys CONFIGURATION

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.security.permission ActionKeys CONFIGURATION.

Prototype

String CONFIGURATION

To view the source code for com.liferay.portal.kernel.security.permission ActionKeys CONFIGURATION.

Click Source Link

Usage

From source file:com.liferay.dynamic.data.lists.form.web.internal.display.context.DDLFormDisplayContext.java

License:Open Source License

public boolean isShowConfigurationIcon() throws PortalException {
    if (_showConfigurationIcon != null) {
        return _showConfigurationIcon;
    }// w  w w.j a  v  a  2s  .  c om

    if (isPreview() || (isSharedURL() && isFormShared())) {
        _showConfigurationIcon = false;

        return _showConfigurationIcon;
    }

    ThemeDisplay themeDisplay = getThemeDisplay();

    _showConfigurationIcon = PortletPermissionUtil.contains(themeDisplay.getPermissionChecker(),
            themeDisplay.getLayout(), getPortletId(), ActionKeys.CONFIGURATION);

    return _showConfigurationIcon;
}

From source file:com.liferay.dynamic.data.lists.web.internal.display.context.DDLDisplayContext.java

License:Open Source License

public boolean isShowConfigurationIcon() throws PortalException {
    if (_showConfigurationIcon != null) {
        return _showConfigurationIcon;
    }/*from   w  ww.ja  va 2  s. c o  m*/

    _showConfigurationIcon = PortletPermissionUtil.contains(getPermissionChecker(), getLayout(), getPortletId(),
            ActionKeys.CONFIGURATION);

    return _showConfigurationIcon;
}

From source file:com.liferay.exportimport.internal.staging.permission.StagingPermissionImpl.java

License:Open Source License

protected Boolean doHasPermission(PermissionChecker permissionChecker, Group group, String className,
        long classPK, String portletId, String actionId) throws Exception {

    if (!PropsValues.STAGING_LIVE_GROUP_LOCKING_ENABLED) {
        return null;
    }// w ww.j a  v  a2  s  . co  m

    if (!actionId.equals(ActionKeys.ACCESS) && !actionId.equals(ActionKeys.ACCESS_IN_CONTROL_PANEL)
            && !actionId.equals(ActionKeys.ADD_TO_PAGE) && !actionId.equals(ActionKeys.ASSIGN_MEMBERS)
            && !actionId.equals(ActionKeys.CONFIGURATION) && !actionId.equals(ActionKeys.CUSTOMIZE)
            && !actionId.equals(ActionKeys.DELETE) && !actionId.equals(ActionKeys.VIEW)
            && group.hasLocalOrRemoteStagingGroup()
            && (Validator.isNull(portletId) || group.isStagedPortlet(portletId))) {

        return false;
    } else {
        return null;
    }
}

From source file:com.liferay.exportimport.web.internal.portlet.action.ActionUtil.java

License:Open Source License

public static Portlet getPortlet(PortletRequest portletRequest) throws Exception {

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

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    String portletId = ParamUtil.getString(portletRequest, "portletResource");

    Layout layout = PortletConfigurationLayoutUtil.getLayout(themeDisplay);

    if (!PortletPermissionUtil.contains(permissionChecker, themeDisplay.getScopeGroupId(), layout, portletId,
            ActionKeys.CONFIGURATION)) {

        throw new PrincipalException.MustHavePermission(permissionChecker, Portlet.class.getName(), portletId,
                ActionKeys.CONFIGURATION);
    }//from   w  w w .  j ava2s .  co  m

    return PortletLocalServiceUtil.getPortletById(themeDisplay.getCompanyId(), portletId);
}

From source file:com.liferay.journal.content.web.internal.display.context.JournalContentDisplayContext.java

License:Open Source License

public boolean isShowSelectArticleIcon() throws PortalException {
    if (_showSelectArticleIcon != null) {
        return _showSelectArticleIcon;
    }// w ww . ja va2s  . c  o m

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

    PortletDisplay portletDisplay = themeDisplay.getPortletDisplay();

    _showSelectArticleIcon = PortletPermissionUtil.contains(themeDisplay.getPermissionChecker(),
            themeDisplay.getLayout(), portletDisplay.getId(), ActionKeys.CONFIGURATION);

    return _showSelectArticleIcon;
}

From source file:com.liferay.layout.admin.web.internal.control.menu.ToggleControlsProductNavigationControlMenuEntry.java

License:Open Source License

protected boolean hasPortletConfigurationPermission(ThemeDisplay themeDisplay) throws PortalException {

    return PortletPermissionUtil.hasConfigurationPermission(themeDisplay.getPermissionChecker(),
            themeDisplay.getSiteGroupId(), themeDisplay.getLayout(), ActionKeys.CONFIGURATION);
}

From source file:com.liferay.portlet.configuration.css.web.internal.portlet.PortletConfigurationCSSPortlet.java

License:Open Source License

public void getLookAndFeel(ResourceRequest resourceRequest, ResourceResponse resourceResponse)
        throws PortletException {

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

    try {//ww  w . j a v  a 2 s.  c o  m
        Layout layout = themeDisplay.getLayout();

        PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

        String portletId = ParamUtil.getString(resourceRequest, "portletId");

        if (!PortletPermissionUtil.contains(permissionChecker, layout, portletId, ActionKeys.CONFIGURATION)) {

            return;
        }

        PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getStrictLayoutPortletSetup(layout,
                portletId);

        JSONObject portletSetupJSONObject = PortletSetupUtil.cssToJSONObject(portletSetup);

        JSONObject defaultPortletTitlesJSONObject = JSONFactoryUtil.createJSONObject();

        for (Locale locale : LanguageUtil.getAvailableLocales(themeDisplay.getSiteGroupId())) {

            String rootPortletId = PortletConstants.getRootPortletId(portletId);
            String languageId = LocaleUtil.toLanguageId(locale);

            defaultPortletTitlesJSONObject.put(languageId, _portal.getPortletTitle(rootPortletId, languageId));
        }

        portletSetupJSONObject.put("defaultPortletTitles", defaultPortletTitlesJSONObject);

        writeJSON(resourceRequest, resourceResponse, portletSetupJSONObject.toString());
    } catch (Exception e) {
        throw new PortletException(e);
    }
}

From source file:com.liferay.portlet.configuration.css.web.internal.portlet.PortletConfigurationCSSPortlet.java

License:Open Source License

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

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

    Layout layout = themeDisplay.getLayout();

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    String portletId = ParamUtil.getString(actionRequest, "portletId");

    if (!PortletPermissionUtil.contains(permissionChecker, layout, portletId, ActionKeys.CONFIGURATION)) {

        return;/*from  w  w w  .  ja  v a 2s .c  om*/
    }

    PortletPreferences portletSetup = PortletPreferencesFactoryUtil.getStrictLayoutPortletSetup(layout,
            portletId);

    String css = ParamUtil.getString(actionRequest, "css");

    if (_log.isDebugEnabled()) {
        _log.debug("Updating css " + css);
    }

    JSONObject jsonObject = JSONFactoryUtil.createJSONObject(css);

    JSONObject portletDataJSONObject = jsonObject.getJSONObject("portletData");

    jsonObject.remove("portletData");

    css = jsonObject.toString();

    String linkToLayoutUuid = GetterUtil.getString(portletDataJSONObject.getString("portletLinksTarget"));
    String portletDecoratorId = portletDataJSONObject.getString("portletDecoratorId");
    JSONObject titlesJSONObject = portletDataJSONObject.getJSONObject("titles");
    boolean useCustomTitle = portletDataJSONObject.getBoolean("useCustomTitle");

    Set<Locale> locales = LanguageUtil.getAvailableLocales(themeDisplay.getSiteGroupId());

    for (Locale locale : locales) {
        String languageId = LocaleUtil.toLanguageId(locale);

        String title = null;

        if (titlesJSONObject.has(languageId)) {
            title = GetterUtil.getString(titlesJSONObject.getString(languageId));
        }

        String rootPortletId = PortletConstants.getRootPortletId(portletId);

        String defaultPortletTitle = _portal.getPortletTitle(rootPortletId, languageId);

        if ((title != null) && !Objects.equals(defaultPortletTitle, title)) {

            portletSetup.setValue("portletSetupTitle_" + languageId, title);
        } else {
            portletSetup.reset("portletSetupTitle_" + languageId);
        }
    }

    portletSetup.setValue("portletSetupUseCustomTitle", String.valueOf(useCustomTitle));

    if (Validator.isNotNull(linkToLayoutUuid)) {
        portletSetup.setValue("portletSetupLinkToLayoutUuid", linkToLayoutUuid);
    } else {
        portletSetup.reset("portletSetupLinkToLayoutUuid");
    }

    if (Validator.isNotNull(portletDecoratorId)) {
        portletSetup.setValue("portletSetupPortletDecoratorId", portletDecoratorId);
    } else {
        portletSetup.reset("portletSetupPortletDecoratorId");
    }

    portletSetup.setValue("portletSetupCss", css);

    portletSetup.store();
}

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  ava  2s  .c  om*/
        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;
}