@@ -1004,20 +1004,43 @@ private String getPermissionFilterQuery(DataverseRequest dataverseRequest, SolrQ
1004
1004
1005
1005
// ----------------------------------------------------
1006
1006
// (1) Is this a GuestUser?
1007
- // Yes, see if GuestUser is part of any groups such as IP Groups.
1008
1007
// ----------------------------------------------------
1009
1008
if (user instanceof GuestUser ) {
1009
+
1010
+ StringBuilder sb = new StringBuilder ();
1011
+
1012
+ // Yes, see if GuestUser is part of any groups, such as IP Groups.
1013
+ Set <Group > groups = groupService .collectAncestors (groupService .groupsFor (dataverseRequest ));
1014
+
1010
1015
if (FeatureFlags .AVOID_EXPENSIVE_SOLR_JOIN .enabled ()) {
1011
1016
/**
1012
1017
* Instead of doing an expensive join, narrow down to only
1013
1018
* public objects. This field is indexed on the content document
1014
1019
* itself, rather than a permission document.
1015
1020
*/
1016
- return SearchFields .PUBLIC_OBJECT + ":" + true ;
1021
+ sb .append (SearchFields .PUBLIC_OBJECT + ":" + true );
1022
+
1023
+ // If there are any IP groups, we'll add separate (and much cheaper)
1024
+ // joins on them.
1025
+ // Note that in order for these potential extra joins to work with
1026
+ // the above, we need to use a query syntax that is a bit different
1027
+ // from what we normally use (below):
1028
+ int groupCounter = 0 ;
1029
+ for (Group group : groups ) {
1030
+ logger .fine ("found group " + group .getIdentifier () + " with alias " + group .getAlias ());
1031
+ String groupAlias = group .getAlias ();
1032
+ if (groupAlias != null && !groupAlias .isEmpty () && !groupAlias .startsWith ("builtIn" )) {
1033
+ groupCounter ++;
1034
+ solrQuery .setParam ("q" + groupCounter , SearchFields .DISCOVERABLE_BY + ":" + IndexServiceBean .getGroupPrefix () + groupAlias );
1035
+ sb .append (" OR " );
1036
+ sb .append ("{!join from=" + SearchFields .DEFINITION_POINT + " to=id v=$q" + groupCounter + "}" );
1037
+ }
1038
+ }
1039
+ String ret = sb .toString ();
1040
+ logger .info ("Returning experimental query for Guest user: " + ret );
1041
+ return ret ;
1017
1042
}
1018
1043
String groupsFromProviders = "" ;
1019
- Set <Group > groups = groupService .collectAncestors (groupService .groupsFor (dataverseRequest ));
1020
- StringBuilder sb = new StringBuilder ();
1021
1044
for (Group group : groups ) {
1022
1045
logger .fine ("found group " + group .getIdentifier () + " with alias " + group .getAlias ());
1023
1046
String groupAlias = group .getAlias ();
0 commit comments