jmuehlner commented on code in PR #821:
URL: https://github.com/apache/guacamole-client/pull/821#discussion_r1156496415
##########
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/ModeledDirectoryObjectService.java:
##########
@@ -387,25 +396,36 @@ public Collection<InternalType>
retrieveObjects(ModeledAuthenticatedUser user,
Collection<String> identifiers) throws GuacamoleException {
// Ignore invalid identifiers
- identifiers = filterIdentifiers(identifiers);
+ List<String> filteredIdentifiers = filterIdentifiers(identifiers);
// Do not query if no identifiers given
- if (identifiers.isEmpty())
+ if (filteredIdentifiers.isEmpty())
return Collections.<InternalType>emptyList();
- Collection<ModelType> objects;
+ int batchSize = environment.getDefaultBatchSize();
- // Bypass permission checks if the user is privileged
- if (user.isPrivileged())
- objects = getObjectMapper().select(identifiers);
+ Collection<ModelType> allObjects = new
ArrayList<>(filteredIdentifiers.size());
+
+ for (int startIndex = 0; startIndex < filteredIdentifiers.size();
startIndex += batchSize) {
Review Comment:
A comment before this loop would be very handy for reader's to understand
what's going on here. There's a lot of dense code that's understandable with
some thinking, but at a glance it's not super obvious (at least not to me).
##########
extensions/guacamole-auth-jdbc/modules/guacamole-auth-jdbc-base/src/main/java/org/apache/guacamole/auth/jdbc/base/ModeledDirectoryObjectService.java:
##########
@@ -387,25 +396,36 @@ public Collection<InternalType>
retrieveObjects(ModeledAuthenticatedUser user,
Collection<String> identifiers) throws GuacamoleException {
// Ignore invalid identifiers
- identifiers = filterIdentifiers(identifiers);
+ List<String> filteredIdentifiers = filterIdentifiers(identifiers);
// Do not query if no identifiers given
- if (identifiers.isEmpty())
+ if (filteredIdentifiers.isEmpty())
return Collections.<InternalType>emptyList();
- Collection<ModelType> objects;
+ int batchSize = environment.getDefaultBatchSize();
- // Bypass permission checks if the user is privileged
- if (user.isPrivileged())
- objects = getObjectMapper().select(identifiers);
+ Collection<ModelType> allObjects = new
ArrayList<>(filteredIdentifiers.size());
+
+ for (int startIndex = 0; startIndex < filteredIdentifiers.size();
startIndex += batchSize) {
Review Comment:
A comment before this loop would be very handy for readers to understand
what's going on here. There's a lot of dense code that's understandable with
some thinking, but at a glance it's not super obvious (at least not to me).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]