Error in UserLocalServiceImpl.addUser - if the default communities (groups) are specified badly the exception is thrown and the user is not initialized properly
Created: 27/Jan/09 06:11 AM
Updated: 02/Feb/09 02:06 PM
Component/s:
None
Affects Version/s:
5.1.2
Fix Version/s:
None
Time Tracking:
Not Specified
Environment:
5.1.2 Tomcat6.0.16, postgresql (but is environment independent)
.
In teh case at least one default Group (default community specified in the Enterprise Admin Portlet) does not exist, then the array will be generated, whcih contains at least one group Id (array item) equal to 0. The the method
groupLocalService.addUserGroups(userId, groupIds);
throws an exeption "Group Id with Id 0 does ot exist" and the rest of the method is skipped - there are initialized no roles, no user groups, no default webs, no e-mail is sent.
The solutio is simple - instead of usig array use List, like by the roles and user groups.
Description
In the addUser method there is following code containing error:
// Default groups
String[] defaultGroupNames = PrefsPropsUtil.getStringArray(
companyId, PropsKeys.ADMIN_DEFAULT_GROUP_NAMES, StringPool.NEW_LINE,
PropsValues.ADMIN_DEFAULT_GROUP_NAMES);
long[] groupIds = new long[defaultGroupNames.length];
for (int i = 0; i < defaultGroupNames.length; i++) {
try {
Group group = groupFinder.findByC_N(
companyId, defaultGroupNames[i]);
groupIds[i] = group.getGroupId();
}
catch (NoSuchGroupException nsge) {
}
}
groupLocalService.addUserGroups(userId, groupIds);
.
In teh case at least one default Group (default community specified in the Enterprise Admin Portlet) does not exist, then the array will be generated, whcih contains at least one group Id (array item) equal to 0. The the method
groupLocalService.addUserGroups(userId, groupIds);
throws an exeption "Group Id with Id 0 does ot exist" and the rest of the method is skipped - there are initialized no roles, no user groups, no default webs, no e-mail is sent.
The solutio is simple - instead of usig array use List, like by the roles and user groups.
Artur Linhart (BC) added a comment - 30/Jan/09 11:59 PM - Visible to Hello,
does it mean this error will in the next versions not come even if the method adUser is called by some own defined portlet direct?
thank You for information, Artur