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

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

Introduction

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

Prototype

public static String getPortletRootModelResource(String portletName) 

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]));
    }//  w  w w .  j  a  va2  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.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);
        }/*ww  w  . j a  v  a 2s  .  c  o m*/
    }
}