Example usage for com.liferay.portal.kernel.security.permission ResourceActionsUtil getModelResourceActions

List of usage examples for com.liferay.portal.kernel.security.permission ResourceActionsUtil getModelResourceActions

Introduction

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

Prototype

public static List<String> getModelResourceActions(String name) 

Source Link

Usage

From source file:com.liferay.application.list.user.personal.site.permissions.internal.UserPersonalSitePermissions.java

License:Open Source License

protected void initPermissions(long companyId, long powerUserRoleId, String rootPortletId,
        long userPersonalSiteGroupId) throws PortalException {

    String primaryKey = String.valueOf(userPersonalSiteGroupId);

    if (_resourcePermissionLocalService.getResourcePermissionsCount(companyId, rootPortletId,
            ResourceConstants.SCOPE_GROUP, primaryKey) == 0) {

        List<String> portletActionIds = ResourceActionsUtil.getPortletResourceActions(rootPortletId);

        _resourcePermissionLocalService.setResourcePermissions(companyId, rootPortletId,
                ResourceConstants.SCOPE_GROUP, String.valueOf(userPersonalSiteGroupId), powerUserRoleId,
                portletActionIds.toArray(new String[0]));
    }/*  ww  w. j  av a2  s .c o m*/

    String modelName = ResourceActionsUtil.getPortletRootModelResource(rootPortletId);

    if (Validator.isBlank(modelName)) {
        return;
    }

    if (_resourcePermissionLocalService.getResourcePermissionsCount(companyId, modelName,
            ResourceConstants.SCOPE_GROUP, primaryKey) == 0) {

        List<String> modelActionIds = ResourceActionsUtil.getModelResourceActions(modelName);

        _resourcePermissionLocalService.setResourcePermissions(companyId, modelName,
                ResourceConstants.SCOPE_GROUP, String.valueOf(userPersonalSiteGroupId), powerUserRoleId,
                modelActionIds.toArray(new String[0]));
    }
}

From source file:com.liferay.exportimport.internal.util.ExportImportPermissionUtil.java

License:Open Source License

public static Map<Long, Set<String>> getRoleIdsToActionIds(long companyId, String resourceName,
        String resourcePK) {//from w w w  . j  a  v  a 2s .com

    List<String> existingActionIds = ResourceActionsUtil.getModelResourceActions(resourceName);

    Map<Long, Set<String>> existingRoleIdsToActionIds = new HashMap<>();

    try {
        existingRoleIdsToActionIds = getRoleIdsToActionIds(companyId, resourceName, resourcePK,
                existingActionIds);
    } catch (PortalException pe) {

        // LPS-52675

        if (_log.isDebugEnabled()) {
            _log.debug(pe, pe);
        }
    }

    return existingRoleIdsToActionIds;
}

From source file:com.liferay.roles.admin.web.internal.portlet.RolesAdminPortlet.java

License:Open Source License

protected void updateViewRootResourcePermission(Role role, long scopeGroupId, String portletId, int scope,
        String[] groupIds) throws Exception {

    String modelResource = ResourceActionsUtil.getPortletRootModelResource(portletId);

    if (modelResource != null) {
        List<String> actions = ResourceActionsUtil.getModelResourceActions(modelResource);

        if (actions.contains(ActionKeys.VIEW)) {
            updateAction(role, scopeGroupId, modelResource, ActionKeys.VIEW, true, scope, groupIds);
        }/*  w ww .  j a  v a2 s  .co m*/
    }
}