Example usage for com.liferay.portal.kernel.theme ThemeDisplay getPermissionChecker

List of usage examples for com.liferay.portal.kernel.theme ThemeDisplay getPermissionChecker

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.theme ThemeDisplay getPermissionChecker.

Prototype

@JSON(include = false)
public PermissionChecker getPermissionChecker() 

Source Link

Document

Returns the permission checker, which is used to ensure users making resource requests have the necessary access permissions.

Usage

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.ThreadPermissionsPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    User user = themeDisplay.getUser();/*from  w w  w.  ja  va2s .  c  o  m*/

    if (user.isDefaultUser()) {
        return false;
    }

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    try {
        MBMessage message = ActionUtil.getMessage(portletRequest);

        MBThread thread = message.getThread();

        if (thread.isLocked()) {
            return false;
        }

        if (!MBMessagePermission.contains(permissionChecker, message, ActionKeys.PERMISSIONS)) {

            return false;
        }
    } catch (Exception e) {
        return false;
    }

    return true;
}

From source file:com.liferay.message.boards.web.internal.portlet.configuration.icon.ThreadSubscriptionPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    try {/*from   w ww.j av  a2 s.  c  om*/
        MBGroupServiceSettings mbGroupServiceSettings = MBGroupServiceSettings
                .getInstance(themeDisplay.getScopeGroupId());

        if (!mbGroupServiceSettings.isEmailMessageAddedEnabled()
                && !mbGroupServiceSettings.isEmailMessageUpdatedEnabled()) {

            return false;
        }

        MBMessage message = ActionUtil.getMessage(portletRequest);

        return MBMessagePermission.contains(themeDisplay.getPermissionChecker(), message, ActionKeys.SUBSCRIBE);
    } catch (Exception e) {
    }

    return false;
}

From source file:com.liferay.message.boards.web.internal.upload.TempImageMBUploadFileEntryHandler.java

License:Open Source License

@Override
public FileEntry upload(UploadPortletRequest uploadPortletRequest) throws IOException, PortalException {

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

    long categoryId = ParamUtil.getLong(uploadPortletRequest, "categoryId");

    MBCategoryPermission.check(themeDisplay.getPermissionChecker(), themeDisplay.getScopeGroupId(), categoryId,
            ActionKeys.ADD_FILE);/*from  ww w  .j  av  a 2 s .c o  m*/

    String fileName = uploadPortletRequest.getFileName(_PARAMETER_NAME);
    String contentType = uploadPortletRequest.getContentType(_PARAMETER_NAME);

    try (InputStream inputStream = uploadPortletRequest.getFileAsStream(_PARAMETER_NAME)) {

        String tempFileName = TempFileEntryUtil.getTempFileName(fileName);

        return TempFileEntryUtil.addTempFileEntry(themeDisplay.getScopeGroupId(), themeDisplay.getUserId(),
                _TEMP_FOLDER_NAME, tempFileName, inputStream, contentType);
    }
}

From source file:com.liferay.monitoring.web.internal.portlet.action.EditSessionMVCActionCommand.java

License:Open Source License

@Override
public void doProcessAction(ActionRequest actionRequest, ActionResponse actionResponse) throws Exception {

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

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    if (!permissionChecker.isCompanyAdmin()) {
        SessionErrors.add(actionRequest, PrincipalException.MustBeCompanyAdmin.class.getName());

        actionResponse.setRenderParameter("mvcPath", "/error.jsp");

        return;//w ww . ja v  a2  s  .  co m
    }

    invalidateSession(actionRequest);

    sendRedirect(actionRequest, actionResponse);
}

From source file:com.liferay.password.policies.admin.web.internal.display.context.PasswordPolicyDisplayContext.java

License:Open Source License

public boolean hasAssignMembersPermission() {
    long passwordPolicyId = ParamUtil.getLong(_request, "passwordPolicyId");

    PasswordPolicy passwordPolicy = PasswordPolicyLocalServiceUtil.fetchPasswordPolicy(passwordPolicyId);

    if (passwordPolicy == null) {
        return false;
    }/*  w  w w  .  j  av a 2s .  c  om*/

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

    return PasswordPolicyPermissionUtil.contains(themeDisplay.getPermissionChecker(),
            passwordPolicy.getPasswordPolicyId(), ActionKeys.ASSIGN_MEMBERS);
}

From source file:com.liferay.password.policies.admin.web.internal.portlet.configuration.icon.AssignMembersPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    try {/*from w  w  w .  j  a v  a2  s  .c o m*/
        ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

        if (PasswordPolicyPermissionUtil.contains(themeDisplay.getPermissionChecker(),
                _getPasswordPolicyId(portletRequest), ActionKeys.ASSIGN_MEMBERS)) {

            return true;
        }
    } catch (Exception e) {
    }

    return false;
}

From source file:com.liferay.password.policies.admin.web.internal.portlet.configuration.icon.DeletePasswordPolicyPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    try {//  w  ww.j  ava  2s .c  o m
        ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

        long passwordPolicyId = _getPasswordPolicyId(portletRequest);

        PasswordPolicy passwordPolicy = _passwordPolicyLocalService.fetchPasswordPolicy(passwordPolicyId);

        if (!passwordPolicy.getDefaultPolicy() && PasswordPolicyPermissionUtil
                .contains(themeDisplay.getPermissionChecker(), passwordPolicyId, ActionKeys.UPDATE)) {

            return true;
        }
    } catch (Exception e) {
    }

    return false;
}

From source file:com.liferay.password.policies.admin.web.internal.portlet.configuration.icon.EditPasswordPolicyPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    try {//from   w  w w .jav a  2 s .c om
        ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

        if (PasswordPolicyPermissionUtil.contains(themeDisplay.getPermissionChecker(),
                _getPasswordPolicyId(portletRequest), ActionKeys.UPDATE)) {

            return true;
        }
    } catch (Exception e) {
    }

    return false;
}

From source file:com.liferay.password.policies.admin.web.internal.portlet.configuration.icon.PermissionsPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    try {/*from w  w w . j  a  v  a 2 s  .  c o  m*/
        ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

        if (PasswordPolicyPermissionUtil.contains(themeDisplay.getPermissionChecker(),
                _getPasswordPolicyId(portletRequest), ActionKeys.PERMISSIONS)) {

            return true;
        }
    } catch (Exception e) {
    }

    return false;
}

From source file:com.liferay.polls.web.internal.portlet.action.configuration.icon.PermissionsPortletConfigurationIcon.java

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    ThemeDisplay themeDisplay = (ThemeDisplay) portletRequest.getAttribute(WebKeys.THEME_DISPLAY);

    User user = themeDisplay.getUser();//www  .j  a v a2s.c o m

    if (user.isDefaultUser()) {
        return false;
    }

    PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();

    return PollsResourcePermissionChecker.contains(permissionChecker, themeDisplay.getScopeGroupId(),
            ActionKeys.PERMISSIONS);
}