From 965ba68c4774a9ddc6343fb7d20aee0b3824902d Mon Sep 17 00:00:00 2001 From: j2blake Date: Fri, 11 Nov 2011 15:49:34 +0000 Subject: [PATCH] NIHVIVO-2343 Fix the logic so you can't add a proxy to yourself, even in a new many-to-many relationship. --- .../manageproxies/ManageProxiesCreatePage.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ManageProxiesCreatePage.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ManageProxiesCreatePage.java index f2b655efe..86459891c 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ManageProxiesCreatePage.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/accounts/manageproxies/ManageProxiesCreatePage.java @@ -98,24 +98,28 @@ public class ManageProxiesCreatePage extends AbstractPageHandler { return valid; } - /** We don't remove any existing relationships, we just add new ones. */ + /** + * We don't remove any existing relationships, we just add new ones. But we + * won't add a relationship to one's self. + */ public void createRelationships() { for (UserAccount proxyAccount : proxyAccounts) { Set profiles = new HashSet(); - profiles.addAll(proxyAccount.getProxiedIndividualUris()); profiles.addAll(figureNonSelfProfileUris(proxyAccount)); + profiles.addAll(proxyAccount.getProxiedIndividualUris()); proxyAccount.setProxiedIndividualUris(profiles); userAccountsDao.updateUserAccount(proxyAccount); } } + /* Look at the desired profiles, and remove any that are this proxy's self. */ private Collection figureNonSelfProfileUris(UserAccount proxyAccount) { - List mySelves = selfEditingConfiguration - .getAssociatedIndividuals(indDao, proxyAccount); - List myProfiles = new ArrayList(profileUris); - myProfiles.removeAll(mySelves); + for (Individual self : selfEditingConfiguration + .getAssociatedIndividuals(indDao, proxyAccount)) { + myProfiles.remove(self.getURI()); + } return myProfiles; }