@@ -1081,22 +1081,40 @@ private String getPermissionFilterQuery(DataverseRequest dataverseRequest, SolrQ
1081
1081
// ----------------------------------------------------
1082
1082
1083
1083
// A quick speedup experiment (L.A.)
1084
- // - This ignores the group membership completely;
1085
- // so, not a production-ready fix, just a proof of concept,
1086
1084
// an attempt to replace an uber-expensive join on ALL the public
1087
1085
// documents with the "publicObject:true" flag, similarly to what we
1088
1086
// are doing for guest users, above, and only using
1089
1087
// the join to explicitly look up the (few) documents the user is
1090
- // directly authorized to see (once again, groups are ignored for now)
1088
+ // directly authorized to see, by direct assignment or via
1089
+ // group membership. Group support is very experimental still.
1091
1090
if (FeatureFlags .AVOID_EXPENSIVE_SOLR_JOIN .enabled ()) {
1092
- StringBuilder sb = new StringBuilder ();
1093
-
1094
- sb .append (SearchFields .PUBLIC_OBJECT + ":" + true + " OR " );
1095
- sb .append ("{!join from=" + SearchFields .DEFINITION_POINT + " to=id}" + SearchFields .DISCOVERABLE_BY + ":" + IndexServiceBean .getGroupPerUserPrefix () + au .getId ());
1096
- String ret = sb .toString ();
1097
- logger .info ("Returning experimental query: " +ret );
1098
- return ret ;
1091
+ StringBuilder sb = new StringBuilder ();
1092
+
1093
+ sb .append (SearchFields .PUBLIC_OBJECT + ":" + true + " OR " );
1094
+
1095
+ // An AuthenticatedUser should also be able to see all the content
1096
+ // on which they have direct permissions:
1097
+ solrQuery .setParam ("q1" , SearchFields .DISCOVERABLE_BY + ":" + IndexServiceBean .getGroupPerUserPrefix () + au .getId ());
1098
+ sb .append ("{!join from=" + SearchFields .DEFINITION_POINT + " to=id v=$q1}" );
1099
+
1100
+ // In addition to the user referenced directly, we will also
1101
+ // add joins on all the non-public groups that may exist for the
1102
+ // user:
1103
+ Set <Group > groups = groupService .collectAncestors (groupService .groupsFor (dataverseRequest ));
1104
+ int groupCounter = 1 ;
1105
+ for (Group group : groups ) {
1106
+ String groupAlias = group .getAlias ();
1107
+ if (groupAlias != null && !groupAlias .isEmpty () && !groupAlias .startsWith ("builtIn" )) {
1108
+ groupCounter ++;
1109
+ solrQuery .setParam ("q" + groupCounter , SearchFields .DISCOVERABLE_BY + ":" + IndexServiceBean .getGroupPrefix () + groupAlias );
1110
+ sb .append (" OR " );
1111
+ sb .append ("{!join from=" + SearchFields .DEFINITION_POINT + " to=id v=$q" + groupCounter + "}" );
1112
+ }
1099
1113
}
1114
+ String ret = sb .toString ();
1115
+ logger .info ("Returning experimental query: " + ret );
1116
+ return ret ;
1117
+ }
1100
1118
/**
1101
1119
* @todo all this code needs cleanup and clarification.
1102
1120
*/
@@ -1109,7 +1127,7 @@ private String getPermissionFilterQuery(DataverseRequest dataverseRequest, SolrQ
1109
1127
* @todo rename this from publicPlusUserPrivateGroup. Confusing
1110
1128
*/
1111
1129
// safe default: public only
1112
- String publicPlusUserPrivateGroup = publicOnly ;
1130
+ String publicPlusUserPrivateGroup = publicOnly ;
1113
1131
// + (onlyDatatRelatedToMe ? "" : (publicOnly + " OR "))
1114
1132
// + "{!join from=" + SearchFields.GROUPS + " to=" + SearchFields.PERMS + "}id:" + IndexServiceBean.getGroupPerUserPrefix() + au.getId() + ")";
1115
1133
0 commit comments