Alon Bar-Lev has uploaded a new change for review. Change subject: aaa: remove duplicate groups from entities ......................................................................
aaa: remove duplicate groups from entities Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1120720 Change-Id: If5c1313c96e0e3e0900023efed2469dfea306632 Signed-off-by: Alon Bar-Lev <alo...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/aaa/DirectoryUtils.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/aaa/DbUser.java 3 files changed, 22 insertions(+), 19 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/07/34107/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java index 04091e0..4e7296e 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommandBase.java @@ -924,7 +924,7 @@ * @return <code>true</code> if the current user is authorized to run the action, <code>false</code> otherwise */ protected boolean checkUserAndGroupsAuthorization(Guid userId, - List<Guid> groupIds, + Collection<Guid> groupIds, final ActionGroup actionGroup, final Guid object, final VdcObjectType type, diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/aaa/DirectoryUtils.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/aaa/DirectoryUtils.java index 46689c9..799b71f 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/aaa/DirectoryUtils.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/aaa/DirectoryUtils.java @@ -4,8 +4,9 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; -import java.util.LinkedList; +import java.util.HashSet; import java.util.List; +import java.util.Set; import org.ovirt.engine.api.extensions.ExtKey; import org.ovirt.engine.api.extensions.ExtMap; @@ -33,8 +34,8 @@ dbUser = new DbUser(mapPrincipalRecordToDirectoryUser(authz, principal)); dbUser.setId(userId); DbGroupDAO dao = DbFacade.getInstance().getDbGroupDao(); - LinkedList<Guid> groupIds = new LinkedList<Guid>(); - LinkedList<String> groupsNames = new LinkedList<String>(); + Set<Guid> groupIds = new HashSet<Guid>(); + Set<String> groupsNames = new HashSet<String>(); for (ExtMap group : principal.get(PrincipalRecord.GROUPS, Collections.<ExtMap> emptyList())) { DbGroup dbGroup = dao.getByExternalId(authz, group.<String> get(GroupRecord.ID)); if (dbGroup != null) { diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/aaa/DbUser.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/aaa/DbUser.java index d62a68d..550656f 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/aaa/DbUser.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/aaa/DbUser.java @@ -1,6 +1,8 @@ package org.ovirt.engine.core.common.businessentities.aaa; -import java.util.LinkedList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashSet; import javax.validation.constraints.Size; @@ -65,20 +67,20 @@ */ private boolean isAdmin; - private LinkedList<String> groupNames; + private Collection<String> groupNames; /** * Comma delimited list of group identifiers. */ - private LinkedList<Guid> groupIds; + private Collection<Guid> groupIds; public DbUser() { loginName = ""; firstName = ""; lastName = ""; department = ""; - groupNames = new LinkedList<String>(); - groupIds = new LinkedList<Guid>(); + groupNames = Collections.emptyList(); + groupIds = Collections.emptyList(); role = ""; note = ""; } @@ -95,7 +97,7 @@ active = true; role = ""; note = ""; - groupNames = new LinkedList<String>(); + groupNames = new HashSet<String>(); for (DirectoryGroup directoryGroup : directoryUser.getGroups()) { groupNames.add(directoryGroup.getName()); } @@ -173,12 +175,12 @@ email = value; } - public LinkedList<String> getGroupNames() { - return groupNames; + public Collection<String> getGroupNames() { + return Collections.unmodifiableCollection(groupNames); } - public void setGroupNames(LinkedList<String> value) { - groupNames = value; + public void setGroupNames(Collection<String> value) { + groupNames = new HashSet<String>(value); } public String getNote() { @@ -222,15 +224,15 @@ return isAdmin; } - public void setGroupIds(LinkedList<Guid> groupIds) { - this.groupIds = groupIds; + public void setGroupIds(Collection<Guid> groupIds) { + this.groupIds = new HashSet<Guid>(groupIds); } - public LinkedList<Guid> getGroupIds() { + public Collection<Guid> getGroupIds() { if (groupIds == null) { - groupIds = new LinkedList<Guid>(); + groupIds = Collections.emptyList(); } - return groupIds; + return Collections.unmodifiableCollection(groupIds); } @Override -- To view, visit http://gerrit.ovirt.org/34107 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: If5c1313c96e0e3e0900023efed2469dfea306632 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches