From 794637e479ef0ce2016a399ec7cf12d6ca62b8f9 Mon Sep 17 00:00:00 2001 From: Adam Rauch Date: Sun, 9 Jun 2024 13:56:49 -0700 Subject: [PATCH] Migrate away from deprecated methods --- mGAP/src/org/labkey/mgap/mGAPController.java | 14 +++++++------- mcc/src/org/labkey/mcc/MccController.java | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/mGAP/src/org/labkey/mgap/mGAPController.java b/mGAP/src/org/labkey/mgap/mGAPController.java index c51815b47..a6afe1452 100644 --- a/mGAP/src/org/labkey/mgap/mGAPController.java +++ b/mGAP/src/org/labkey/mgap/mGAPController.java @@ -399,7 +399,6 @@ public void validateForm(ApproveUserRequestsForm form, Errors errors) public Object execute(ApproveUserRequestsForm form, BindException errors) throws Exception { ApiSimpleResponse response = new ApiSimpleResponse(); - MutableSecurityPolicy policy = new MutableSecurityPolicy(mGAPManager.get().getMGapContainer().getPolicy()); List newUserStatusList = new ArrayList<>(); List existingUsersGivenAccess = new ArrayList<>(); try (DbScope.Transaction transaction = CoreSchema.getInstance().getScope().ensureTransaction()) @@ -433,7 +432,7 @@ public Object execute(ApproveUserRequestsForm form, BindException errors) throws u.setLastName((String)map.get("lastName")); UserManager.updateUser(getUser(), u); - if (st.isLdapEmail()) + if (st.isLdapOrSsoEmail()) { existingUsersGivenAccess.add(st.getUser()); } @@ -449,9 +448,13 @@ public Object execute(ApproveUserRequestsForm form, BindException errors) throws row.put("userId", u.getUserId()); Table.update(getUser(), ti, row, requestId); - if (!policy.hasPermission(u, ReadPermission.class)) + Container mGapContainer = mGAPManager.get().getMGapContainer(); + + if (!mGapContainer.hasPermission(u, ReadPermission.class)) { + MutableSecurityPolicy policy = new MutableSecurityPolicy(mGapContainer.getPolicy()); policy.addRoleAssignment(u, ReaderRole.class); + SecurityPolicyManager.savePolicy(policy, getUser()); } else { @@ -459,13 +462,10 @@ public Object execute(ApproveUserRequestsForm form, BindException errors) throws } } - SecurityPolicyManager.savePolicy(policy, getUser()); - transaction.commit(); } - Set allUsers = new HashSet<>(); - allUsers.addAll(existingUsersGivenAccess); + Set allUsers = new HashSet<>(existingUsersGivenAccess); //send emails: for (SecurityManager.NewUserStatus st : newUserStatusList) diff --git a/mcc/src/org/labkey/mcc/MccController.java b/mcc/src/org/labkey/mcc/MccController.java index 782fe0274..e560f2ac2 100644 --- a/mcc/src/org/labkey/mcc/MccController.java +++ b/mcc/src/org/labkey/mcc/MccController.java @@ -373,7 +373,7 @@ public Object execute(ApproveUserRequestsForm form, BindException errors) throws u.setLastName((String)map.get("lastName")); UserManager.updateUser(getUser(), u); - if (st.isLdapEmail()) + if (st.isLdapOrSsoEmail()) { existingUsersGivenAccess.add(st.getUser()); }