Search in sources :

Example 1 with PortletPermissions

use of com.liferay.imex.role.model.PortletPermissions in project liferay-imex by jpdacunha.

the class ExportRolePermissionsServiceImpl method getRolePermissions.

private RolePermissions getRolePermissions(long companyId, long roleId, boolean allActions) throws Exception {
    RolePermissions result = new RolePermissions();
    List<Portlet> portlets = portletLocalService.getPortlets(companyId, true, false);
    List<String> portletNames = new ArrayList<String>(portlets.size() + 1);
    for (Portlet portlet : portlets) {
        String portletName = portlet.getPortletId();
        portletNames.add(portletName);
    }
    portletNames.add(PortletKeys.PORTAL);
    for (String portletName : portletNames) {
        PortletPermissions portletPermissions = new PortletPermissions();
        List<String> modelResources = ResourceActionsUtil.getPortletModelResources(portletName);
        for (String modelResource : modelResources) {
            Resource r = getModelResource(companyId, roleId, modelResource, allActions);
            if (allActions || r.getActionList().size() > 0) {
                portletPermissions.getModelResourceList().add(r);
            }
        }
        Resource pr = getPortletResource(companyId, roleId, portletName, allActions);
        portletPermissions.setPortletResource(pr);
        if (allActions || portletPermissions.getModelResourceList().size() > 0 || pr.getActionList().size() > 0) {
            result.getPortletPermissionsList().add(portletPermissions);
        }
    }
    return result;
}
Also used : RolePermissions(com.liferay.imex.role.model.RolePermissions) Portlet(com.liferay.portal.kernel.model.Portlet) PortletPermissions(com.liferay.imex.role.model.PortletPermissions) ArrayList(java.util.ArrayList) Resource(com.liferay.imex.role.model.Resource)

Aggregations

PortletPermissions (com.liferay.imex.role.model.PortletPermissions)1 Resource (com.liferay.imex.role.model.Resource)1 RolePermissions (com.liferay.imex.role.model.RolePermissions)1 Portlet (com.liferay.portal.kernel.model.Portlet)1 ArrayList (java.util.ArrayList)1