Posts

Showing posts with the label usergroup

Adding Default Roles, sites and userGroup

If we want add the default "UserGroups" , "Groups" and "Roles" to the users, we can use the following methods to add. This will ensure, when user is creating it will assign these "UserGroups" , "Groups" and "Roles" to the users If we look into this " admin.default.role.names " in the portal.properties , it has User and PowerUser added, So whenever user is created, these 2 roles are assigned. Here for admin.default.user.group.names , we have added as CoffeGroup , so this group will be assigned automatically to the newly created user. Note: Whatever value we assign to the property , this should exists in the Portal. i.e  CoffeGroup (user group)should be exist in the portal, before creation of user. 1. UserGroup     #     # Input a list of default user group names separated by \n characters that     # are associated with newly created users.     #     admin.default.user.group.names=CoffeGroup UserLoca...

Creating the User Group and assigning the roles for the user group

1.Creating the UserGroup: We can get the userId and companyId from themeDisplay.      UserGroup userGrp = UserGroupLocalServiceUtil.addUserGroup(userId, companyId, "Test User Group", "Test User Group Desc"); 2.Assiging the user to UserGroup: Here we can assign group of users but as of now we are assigning the only one user. UserLocalServiceUtil.addUserGroupUsers(userGrp.getUserGroupId(), new long []{userId}); 3.Assiging the roles to the usergroups:            Here we are getting the groupId of the UserGroup and also the role long groupId =userGrp.getGroup().getGroupId() Role roleId = RoleLocalServiceUtil.getRole(companyId, "Power User"); RoleLocalServiceUtil.addGroupRole(groupId, roleId);