public UserDetailBean(User user, PasswordCredential credential, List<Role> roles, List<Group> groups,
List<String> allRoles, List<String> allGroups, String rule, List<String> profilingRules) {
this.name = user.getName();
this.infoMap = user.getInfoMap();
this.creationDate = user.getCreationDate();
this.modifiedDate = user.getModifiedDate();
this.enabled = user.isEnabled();
this.availableRoles = allRoles;
this.availableGroups = allGroups;
this.availableRules = profilingRules;
this.rule = rule;
this.credentialUpdateRequired = credential.isUpdateRequired();
for (Role role : roles) {
this.roles = (this.roles == null ? new ArrayList<String>() : this.roles);
this.roles.add(role.getName());
if (availableRoles.contains(role.getName())) {
availableRoles.remove(role.getName());
}
}
for (Group group : groups) {
this.groups = (this.groups == null ? new ArrayList<String>() : this.groups);
this.groups.add(group.getName());
if (availableGroups.contains(group.getName())) {
availableGroups.remove(group.getName());
}
}
}