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

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

Introduction

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

Prototype

String ADD_SUBCATEGORY

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

Click Source Link

Usage

From source file:com.liferay.message.boards.internal.service.permission.MBCategoryPermission.java

License:Open Source License

private boolean _contains(PermissionChecker permissionChecker, long groupId, long categoryId, String actionId)
        throws PortalException {

    if (_mbBanLocalService.hasBan(groupId, permissionChecker.getUserId())) {
        return false;
    }/* w w  w  .  j a v a 2  s. co m*/

    if ((categoryId == MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID)
            || (categoryId == MBCategoryConstants.DISCUSSION_CATEGORY_ID)) {

        return MBPermission.contains(permissionChecker, groupId, actionId);
    }

    MBCategory category = _mbCategoryLocalService.getCategory(categoryId);

    if (actionId.equals(ActionKeys.ADD_CATEGORY)) {
        actionId = ActionKeys.ADD_SUBCATEGORY;
    }

    String portletId = PortletProviderUtil.getPortletId(MBCategory.class.getName(),
            PortletProvider.Action.EDIT);

    Boolean hasPermission = _stagingPermission.hasPermission(permissionChecker, category.getGroupId(),
            MBCategory.class.getName(), category.getCategoryId(), portletId, actionId);

    if (hasPermission != null) {
        return hasPermission.booleanValue();
    }

    if (actionId.equals(ActionKeys.VIEW) && PropsValues.PERMISSIONS_VIEW_DYNAMIC_INHERITANCE) {

        try {
            while (categoryId != MBCategoryConstants.DEFAULT_PARENT_CATEGORY_ID) {

                category = _mbCategoryLocalService.getCategory(categoryId);

                if (!_hasPermission(permissionChecker, category, actionId)) {

                    return false;
                }

                categoryId = category.getParentCategoryId();
            }
        } catch (NoSuchCategoryException nsce) {
            if (!category.isInTrash()) {
                throw nsce;
            }
        }

        return MBPermission.contains(permissionChecker, category.getGroupId(), actionId);
    }

    return _hasPermission(permissionChecker, category, actionId);
}