From 0512d267f766cfb0a70d2b4508d935a9e85266d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacobo=20Aragunde=20P=C3=A9rez?= Date: Tue, 10 Jul 2012 12:21:35 +0200 Subject: [PATCH] Bug #1492: Check if the role had been added before. FEA: ItEr76S04BugFixing --- .../org/libreplan/business/users/entities/User.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java b/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java index 075a0ab9f..96e26c4e5 100644 --- a/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java +++ b/libreplan-business/src/main/java/org/libreplan/business/users/entities/User.java @@ -194,7 +194,18 @@ public class User extends BaseEntity implements IHumanIdentifiable{ } public void addProfile(Profile profile) { - profiles.add(profile); + if (!containsProfile(profile)) { + profiles.add(profile); + } + } + + private boolean containsProfile(Profile profile) { + for (Profile assignedProfile : profiles) { + if (assignedProfile.getId().equals(profile.getId())) { + return true; + } + } + return false; } public void removeProfile(Profile profile) {