|
13 | 13 | import edu.harvard.iq.dataverse.DvObjectServiceBean; |
14 | 14 | import edu.harvard.iq.dataverse.FileMetadata; |
15 | 15 | import edu.harvard.iq.dataverse.RoleAssigneeServiceBean; |
16 | | -import edu.harvard.iq.dataverse.authorization.groups.Group; |
| 16 | +import edu.harvard.iq.dataverse.authorization.RoleAssignee; |
17 | 17 | import edu.harvard.iq.dataverse.authorization.groups.GroupServiceBean; |
18 | | -import edu.harvard.iq.dataverse.authorization.users.AuthenticatedUser; |
| 18 | +import edu.harvard.iq.dataverse.authorization.users.PrivateUrlUser; |
19 | 19 | import edu.harvard.iq.dataverse.settings.JvmSettings; |
20 | 20 |
|
21 | 21 | import java.io.IOException; |
@@ -74,8 +74,6 @@ public class SolrIndexServiceBean { |
74 | 74 | RoleAssigneeServiceBean roleAssigneeSvc; |
75 | 75 | @EJB |
76 | 76 | SolrClientIndexService solrClientService; |
77 | | - @EJB |
78 | | - GroupServiceBean groupSvc; |
79 | 77 |
|
80 | 78 | @PersistenceContext(unitName = "VDCNet-ejbPU") |
81 | 79 | private EntityManager em; |
@@ -469,34 +467,18 @@ private Map<Long, List<String>> getFileDownloadersMap(Long id) { |
469 | 467 | .flatMap(List::stream) |
470 | 468 | .collect(Collectors.toSet()); |
471 | 469 |
|
472 | | - // Separate identifiers by type and build swaps map in one pass |
473 | | - Map<String, String> swaps = allIdentifiers.stream() |
474 | | - .collect(Collectors.toMap( |
475 | | - identifier -> identifier, |
476 | | - identifier -> { |
477 | | - if (identifier.startsWith("@")) { |
478 | | - // Will be replaced with actual user lookup below |
479 | | - return identifier; |
480 | | - } else if (identifier.startsWith(":")) { |
481 | | - Group group = groupSvc.getGroup(identifier); |
482 | | - return group != null ? searchPermissionsService.getIndexableStringForUserOrGroup(group) : identifier; |
483 | | - } |
484 | | - return identifier; |
485 | | - } |
486 | | - )); |
487 | | - |
488 | | - // Batch lookup users and update swaps map |
489 | | - Set<String> userIdentifiers = allIdentifiers.stream() |
490 | | - .filter(identifier -> identifier.startsWith("@")) |
491 | | - .map(identifier -> identifier.substring(1)) |
492 | | - .collect(Collectors.toSet()); |
493 | | - |
494 | | - if (!userIdentifiers.isEmpty()) { |
495 | | - em.createNamedQuery("AuthenticatedUser.findByUserIdentifiers", AuthenticatedUser.class) |
496 | | - .setParameter("userIdentifiers", userIdentifiers) |
497 | | - .getResultStream() |
498 | | - .forEach(user -> swaps.put("@" + user.getUserIdentifier(), |
499 | | - searchPermissionsService.getIndexableStringForUserOrGroup(user))); |
| 470 | + // Build swaps map by looking up each identifier and converting to indexable string |
| 471 | + Map<String, String> swaps = new HashMap<>(); |
| 472 | + for (String identifier : allIdentifiers) { |
| 473 | + if (!identifier.startsWith(PrivateUrlUser.PREFIX)) { |
| 474 | + RoleAssignee roleAssignee = roleAssigneeSvc.getRoleAssignee(identifier); |
| 475 | + if (roleAssignee != null) { |
| 476 | + String indexableString = searchPermissionsService.getIndexableStringForUserOrGroup(roleAssignee); |
| 477 | + if (indexableString != null) { |
| 478 | + swaps.put(identifier, indexableString); |
| 479 | + } |
| 480 | + } |
| 481 | + } |
500 | 482 | } |
501 | 483 |
|
502 | 484 | // Transform the identifier map to indexable strings map |
|
0 commit comments