// Create an array to store local user objects.
User[] users = new User[emailAndNames.size()];
for (int i = 0; i < users.length; i++) {
// Create the new user structure.
User newUser = new User();
newUser.setEmail(emailAndNames.get(i)[0]);
newUser.setName(emailAndNames.get(i)[1]);
newUser.setRoleId(roleId);
newUser.setPreferredLocale("en_US");
users[i] = newUser;
}
// Create the users.
users = userService.createUsers(users);
if (users != null) {
for (User newUser : users) {
System.out.println("A user with ID \"" + newUser.getId()
+ "\", email \"" + newUser.getEmail()
+ "\", and role \"" + newUser.getRoleName() + "\" was created.");
}
} else {
System.out.println("No users created.");
}
} catch (Exception e) {