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

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

Introduction

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

Prototype

String DELETE

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

Click Source Link

Usage

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

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    try {/* w  w  w  .  j a v a 2 s .c  o m*/
        MBCategory category = ActionUtil.getCategory(portletRequest);

        if (category == null) {
            return false;
        }

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

        if (MBCategoryPermission.contains(themeDisplay.getPermissionChecker(), category, ActionKeys.DELETE)) {

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

    return false;
}

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

License:Open Source License

@Override
public boolean isShow(PortletRequest portletRequest) {
    try {/*from w w  w  .j  a va  2  s  . c om*/
        MBMessage message = ActionUtil.getMessage(portletRequest);

        MBThread thread = message.getThread();

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

        if (MBMessagePermission.contains(themeDisplay.getPermissionChecker(), message, ActionKeys.DELETE)
                && !thread.isLocked()) {

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

    return false;
}

From source file:com.liferay.message.boards.web.internal.search.EntriesChecker.java

License:Open Source License

@Override
public String getRowCheckBox(HttpServletRequest request, boolean checked, boolean disabled, String primaryKey) {

    MBThread thread = null;/*from  ww w.ja  v  a2  s . com*/

    long entryId = GetterUtil.getLong(primaryKey);

    MBCategory category = MBCategoryLocalServiceUtil.fetchMBCategory(entryId);

    if (category == null) {
        thread = MBThreadLocalServiceUtil.fetchThread(entryId);
    }

    if ((category == null) && (thread == null)) {
        return StringPool.BLANK;
    }

    boolean showInput = false;

    String name = null;

    if (category != null) {
        name = MBCategory.class.getSimpleName();

        try {
            if (MBCategoryPermission.contains(_permissionChecker, category, ActionKeys.DELETE)) {

                showInput = true;
            }
        } catch (Exception e) {
        }
    } else {
        name = MBThread.class.getSimpleName();

        try {
            if (MBCategoryPermission.contains(_permissionChecker, thread.getGroupId(), thread.getCategoryId(),
                    ActionKeys.LOCK_THREAD)
                    || MBMessagePermission.contains(_permissionChecker, thread.getRootMessageId(),
                            ActionKeys.DELETE)) {

                showInput = true;
            }
        } catch (Exception e) {
        }
    }

    if (!showInput) {
        return StringPool.BLANK;
    }

    String checkBoxRowIds = getEntryRowIds();

    return getRowCheckBox(request, checked, disabled,
            _liferayPortletResponse.getNamespace() + RowChecker.ROW_IDS + name, primaryKey, checkBoxRowIds,
            "'#" + getAllRowIds() + "'", StringPool.BLANK);
}

From source file:com.liferay.microblogs.internal.security.permission.resource.MicroblogsEntryModelResourcePermission.java

License:Open Source License

@Override
public boolean contains(PermissionChecker permissionChecker, MicroblogsEntry microblogsEntry, String actionId) {

    if (actionId.equals(ActionKeys.DELETE) || actionId.equals(ActionKeys.UPDATE)) {

        if (permissionChecker.hasOwnerPermission(microblogsEntry.getCompanyId(),
                MicroblogsEntry.class.getName(), microblogsEntry.getMicroblogsEntryId(),
                microblogsEntry.getUserId(), actionId)) {

            return true;
        }// w  ww . j a  va 2  s.  com

        return false;
    }

    if (permissionChecker.hasOwnerPermission(microblogsEntry.getCompanyId(), MicroblogsEntry.class.getName(),
            microblogsEntry.getMicroblogsEntryId(), microblogsEntry.getUserId(), actionId)) {

        return true;
    }

    if (microblogsEntry.getSocialRelationType() == 0) {
        return true;
    }

    if ((microblogsEntry.getUserId() != permissionChecker.getUserId())
            && _socialRelationLocalService.hasRelation(permissionChecker.getUserId(),
                    microblogsEntry.getUserId(), microblogsEntry.getSocialRelationType())) {

        return true;
    }

    return false;
}

From source file:com.liferay.mobile.device.rules.service.impl.MDRRuleGroupInstanceServiceImpl.java

License:Open Source License

@Override
public void deleteRuleGroupInstance(long ruleGroupInstanceId) throws PortalException {

    MDRRuleGroupInstance ruleGroupInstance = mdrRuleGroupInstancePersistence
            .findByPrimaryKey(ruleGroupInstanceId);

    _mdrRuleGroupInstanceModelResourcePermission.check(getPermissionChecker(), ruleGroupInstance,
            ActionKeys.DELETE);

    mdrRuleGroupInstanceLocalService.deleteRuleGroupInstance(ruleGroupInstance);
}

From source file:com.liferay.mobile.device.rules.service.impl.MDRRuleGroupServiceImpl.java

License:Open Source License

@Override
public void deleteRuleGroup(long ruleGroupId) throws PortalException {
    MDRRuleGroup ruleGroup = mdrRuleGroupPersistence.findByPrimaryKey(ruleGroupId);

    _mdrRuleGroupModelResourcePermission.check(getPermissionChecker(), ruleGroup, ActionKeys.DELETE);

    mdrRuleGroupLocalService.deleteRuleGroup(ruleGroup);
}

From source file:com.liferay.mobile.device.rules.web.internal.search.RuleGroupChecker.java

License:Open Source License

@Override
public boolean isDisabled(Object obj) {
    MDRRuleGroup ruleGroup = (MDRRuleGroup) obj;

    PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

    try {/* ww  w.  j  a  v a2  s.  c om*/
        if (!MDRRuleGroupPermission.contains(permissionChecker, ruleGroup, ActionKeys.DELETE)) {

            return true;
        }
    } catch (PortalException pe) {
        if (_log.isWarnEnabled()) {
            _log.warn(pe, pe);
        }
    }

    return super.isDisabled(obj);
}

From source file:com.liferay.password.policies.admin.web.internal.search.PasswordPolicyChecker.java

License:Open Source License

@Override
public boolean isDisabled(Object obj) {
    PasswordPolicy passwordPolicy = (PasswordPolicy) obj;

    PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

    if (passwordPolicy.getDefaultPolicy() || !PasswordPolicyPermissionUtil.contains(permissionChecker,
            passwordPolicy.getPasswordPolicyId(), ActionKeys.DELETE)) {

        return true;
    }/* w  ww .  j a v a2  s  . com*/

    return super.isDisabled(obj);
}

From source file:com.liferay.roles.admin.web.internal.portlet.configuration.icon.DeleteRolePortletConfigurationIcon.java

License:Open Source License

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

        long roleId = _getRoleId(portletRequest);

        Role role = _roleService.fetchRole(roleId);

        if (!role.isSystem() && RolePermissionUtil.contains(themeDisplay.getPermissionChecker(), roleId,
                ActionKeys.DELETE)) {

            return true;
        }

        return false;
    } catch (Exception e) {
    }

    return false;
}

From source file:com.liferay.roles.admin.web.internal.search.RoleChecker.java

License:Open Source License

@Override
public boolean isDisabled(Object obj) {
    Role role = (Role) obj;

    PermissionChecker permissionChecker = PermissionThreadLocal.getPermissionChecker();

    try {//from   w w w  . j  a  va2  s.  co  m
        if (role.isSystem()
                || !RolePermissionUtil.contains(permissionChecker, role.getRoleId(), ActionKeys.DELETE)) {

            return true;
        }
    } catch (Exception e) {
        _log.error(e, e);
    }

    return super.isDisabled(obj);
}