Created
April 2, 2013 19:26
-
-
Save bmvakili/5295400 to your computer and use it in GitHub Desktop.
Liferay Groovy Script
Get all roles; list User Groups associated with each role.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.liferay.portlet.usergroupsadmin.search.*; | |
import java.util.*; | |
import com.liferay.portal.service.*; | |
import com.liferay.portal.model.*; | |
import com.liferay.portal.model.UserGroup; | |
List<Role> roles = RoleLocalServiceUtil.getRoles(0,999999999); | |
for (Role role : roles) { | |
long roleId = role.getRoleId(); | |
List<Group> roleGroups = GroupLocalServiceUtil.getRoleGroups(roleId); | |
for (Group roleGroup : roleGroups) { | |
Map userGroupParams = new LinkedHashMap<String, Object>(); | |
List userGroupsRoles = new ArrayList(); | |
userGroupParams.put("userGroupsRoles", new Long(role.getRoleId())); | |
List t = UserGroupLocalServiceUtil.search(10153, "", userGroupParams, 0, 999999999, null); | |
List<String> added = new ArrayList<String>(); | |
for (Object o : t) { | |
UserGroup ug = (UserGroup) o; | |
if (!added.contains(ug.getName())) { | |
added.add(ug.getName()); | |
System.out.println(role.getName() + " " + ug.getName()); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment