List of usage examples for com.liferay.portal.kernel.service RoleLocalServiceUtil getRoles
public static java.util.List<com.liferay.portal.kernel.model.Role> getRoles(long[] roleIds) throws com.liferay.portal.kernel.exception.PortalException
From source file:com.liferay.dynamic.data.mapping.service.test.DDMStructureServiceTest.java
License:Open Source License
@Test public void testSearchWithSiteAdminPermission() throws Exception { DDMStructure structure = addStructure(_classNameId, StringUtil.randomString()); structure = addStructure(_classNameId, StringUtil.randomString()); String modelName = ResourceActionsUtil.getCompositeModelName(PortalUtil.getClassName(_classNameId), DDMStructure.class.getName()); List<Role> roles = RoleLocalServiceUtil.getRoles(TestPropsValues.getCompanyId()); for (Role role : roles) { ResourcePermissionServiceUtil.removeResourcePermission(structure.getGroupId(), structure.getCompanyId(), modelName, ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(structure.getPrimaryKey()), role.getRoleId(), ActionKeys.VIEW); }//from w w w. j a v a2 s . c o m long[] groupIds = { group.getGroupId(), group.getGroupId() }; List<DDMStructure> structures = DDMStructureServiceUtil.search(TestPropsValues.getCompanyId(), groupIds, _classNameId, StringPool.BLANK, WorkflowConstants.STATUS_ANY, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); Assert.assertEquals(structures.toString(), 2, structures.size()); }
From source file:com.liferay.dynamic.data.mapping.service.test.DDMStructureServiceTest.java
License:Open Source License
@Test public void testSearchWithSiteMemberPermission() throws Exception { DDMStructure structure = addStructure(_classNameId, StringUtil.randomString()); structure = addStructure(_classNameId, StringUtil.randomString()); String modelName = ResourceActionsUtil.getCompositeModelName(PortalUtil.getClassName(_classNameId), DDMStructure.class.getName()); List<Role> roles = RoleLocalServiceUtil.getRoles(TestPropsValues.getCompanyId()); for (Role role : roles) { ResourcePermissionServiceUtil.removeResourcePermission(structure.getGroupId(), structure.getCompanyId(), modelName, ResourceConstants.SCOPE_INDIVIDUAL, String.valueOf(structure.getPrimaryKey()), role.getRoleId(), ActionKeys.VIEW); }/* w w w . j av a2s. c om*/ long[] groupIds = { group.getGroupId(), group.getGroupId() }; User siteMemberUser = UserTestUtil.addGroupUser(group, RoleConstants.SITE_MEMBER); PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(siteMemberUser); PermissionThreadLocal.setPermissionChecker(permissionChecker); List<DDMStructure> structures = DDMStructureServiceUtil.search(TestPropsValues.getCompanyId(), groupIds, _classNameId, StringPool.BLANK, WorkflowConstants.STATUS_ANY, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); Assert.assertEquals(structures.toString(), 1, structures.size()); }
From source file:eu.gerhards.liferay.services.angular.service.impl.AngularRoleServiceImpl.java
License:Open Source License
@Override public List<Role> getRolesInCompany(long companyId) throws PortalException { PortalPermissionUtil.check(getPermissionChecker(), AngularActionKeys.LIST_ROLES); List<Role> companyRoles = RoleLocalServiceUtil.getRoles(companyId); return companyRoles; }