@@ -68,9 +68,10 @@ public AuthInstallerUserManagerPrefetchingImpl(UserManager delegate, final Value
68
68
Iterator <Authorizable > authorizablesToPrefetchIt = delegate .findAuthorizables (new Query () {
69
69
public <T > void build (QueryBuilder <T > builder ) {
70
70
builder .setCondition (
71
- builder .or ( //
72
- builder .neq ("@" + JcrConstants .JCR_PRIMARYTYPE , valueFactory .createValue (UserConstants .NT_REP_USER )),
73
- builder .eq ("@" + UserConstants .REP_AUTHORIZABLE_ID , valueFactory .createValue (Constants .USER_ANONYMOUS ))) //
71
+ builder .or (
72
+ builder .eq ("@" + JcrConstants .JCR_PRIMARYTYPE , valueFactory .createValue (UserConstants .NT_REP_SYSTEM_USER )),
73
+ builder .eq ("@" + JcrConstants .JCR_PRIMARYTYPE , valueFactory .createValue (UserConstants .NT_REP_GROUP ))
74
+ )
74
75
);
75
76
}
76
77
});
@@ -81,22 +82,16 @@ public <T> void build(QueryBuilder<T> builder) {
81
82
long startPrefetchMemberships = System .currentTimeMillis ();
82
83
while (authorizablesToPrefetchIt .hasNext ()) {
83
84
Authorizable auth = authorizablesToPrefetchIt .next ();
84
- String authId = auth .getID ();
85
-
86
- // also cache those groups which are not member of any other group!
87
- Set <String > memberOfByAuthorizableIds = new HashSet <>();
88
- this .isMemberOfByAuthorizableId .put (authId , memberOfByAuthorizableIds );
89
- Iterator <Group > declaredMemberOf = auth .declaredMemberOf ();
90
- while (declaredMemberOf .hasNext ()) {
91
- Group memberOfGroup = declaredMemberOf .next ();
92
- String memberOfGroupId = memberOfGroup .getID ();
93
- memberOfByAuthorizableIds .add (memberOfGroupId );
94
- nonRegularUserMembersByAuthorizableId .computeIfAbsent (memberOfGroupId , id -> new HashSet <>()).add (authId );
95
- membershipCount ++;
96
- }
85
+ membershipCount += prefetchAuthorizable (auth );
97
86
authorizableIdsAndPaths .put (auth .getID (), auth .getPath ());
98
87
}
99
88
89
+ Authorizable anonymous = delegate .getAuthorizable (UserConstants .DEFAULT_ANONYMOUS_ID );
90
+ if (anonymous != null ) {
91
+ membershipCount += prefetchAuthorizable (anonymous );
92
+ authorizableIdsAndPaths .put (anonymous .getID (), anonymous .getPath ());
93
+ }
94
+
100
95
installLog .addMessage (LOG , "Prefetched " + membershipCount + " memberships in "
101
96
+ msHumanReadable (System .currentTimeMillis () - startPrefetchMemberships ));
102
97
}
@@ -147,6 +142,27 @@ public void removeAuthorizable(final Authorizable authorizable) throws Repositor
147
142
authorizableIdsAndPaths .remove (authorizable .getID ());
148
143
}
149
144
145
+ private int prefetchAuthorizable (final Authorizable authorizable ) throws RepositoryException {
146
+ Objects .requireNonNull (authorizable );
147
+
148
+ int membershipCount = 0 ;
149
+ String authId = authorizable .getID ();
150
+
151
+ // also cache those groups which are not member of any other group!
152
+ Set <String > memberOfByAuthorizableIds = new HashSet <>();
153
+ this .isMemberOfByAuthorizableId .put (authId , memberOfByAuthorizableIds );
154
+ Iterator <Group > declaredMemberOf = authorizable .declaredMemberOf ();
155
+ while (declaredMemberOf .hasNext ()) {
156
+ Group memberOfGroup = declaredMemberOf .next ();
157
+ String memberOfGroupId = memberOfGroup .getID ();
158
+ memberOfByAuthorizableIds .add (memberOfGroupId );
159
+ nonRegularUserMembersByAuthorizableId .computeIfAbsent (memberOfGroupId , id -> new HashSet <>()).add (authId );
160
+ membershipCount ++;
161
+ }
162
+ authorizableIdsAndPaths .put (authorizable .getID (), authorizable .getPath ());
163
+ return membershipCount ;
164
+ }
165
+
150
166
private void removeGroupFromCache (final Group group ) throws RepositoryException {
151
167
final String groupID = group .getID ();
152
168
final Iterator <Authorizable > membersIt = group .getDeclaredMembers ();
0 commit comments