reschke commented on code in PR #63:
URL:
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/63#discussion_r865843672
##########
src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java:
##########
@@ -975,52 +976,52 @@ private boolean addEntry(final Map<String,
List<MapEntry>> entryMap, final Strin
}
/**
- * Load aliases Search for all nodes inheriting the sling:alias
- * property
+ * Load aliases - Search for all nodes (except under /jcr:system) below
+ * configured alias locations having the sling:alias property
*/
private Map<String, Map<String, String>> loadAliases(final
ResourceResolver resolver) {
final Map<String, Map<String, String>> map = new ConcurrentHashMap<>();
- final String queryString = updateAliasQuery();
+ final String queryString = generateAliasQuery();
+
log.debug("start alias query: {}", queryString);
+ long queryStart = System.nanoTime();
final Iterator<Resource> i = resolver.findResources(queryString,
"sql");
- log.debug("end alias query");
+ long queryElapsed = System.nanoTime() - queryStart;
+ log.debug("end alias query; elapsed {}ms",
TimeUnit.NANOSECONDS.toMillis(queryElapsed));
+
long count = 0;
+ long processStart = System.nanoTime();
while (i.hasNext()) {
count += 1;
- final Resource resource = i.next();
- loadAlias(resource, map);
+ loadAlias(i.next(), map);
}
- log.debug("read {} aliases", count);
+ long processElapsed = System.nanoTime() - processStart;
+ log.debug("processed {} aliases in {}ms", count,
TimeUnit.NANOSECONDS.toMillis(processElapsed));
+
return map;
}
-
/*
- * Update alias query based on configured alias locations
- */
- private String updateAliasQuery(){
+ * generate alias query based on configured alias locations
+ */
+ private String generateAliasQuery() {
final Set<String> allowedLocations =
this.factory.getAllowedAliasLocations();
StringBuilder baseQuery = new StringBuilder(ALIAS_BASE_QUERY_DEFAULT);
baseQuery.append(" ").append("WHERE");
- if(allowedLocations.isEmpty()){
+ if (allowedLocations.isEmpty()) {
String jcrSystemPath = StringUtils.removeEnd(JCR_SYSTEM_PREFIX,
"/");
- baseQuery.append(" ").append("(").append("NOT
ISDESCENDANTNODE(page,")
-
.append("\"").append(jcrSystemPath).append("\"").append("))");
-
- }else{
+ baseQuery.append(" (").append("NOT
ISDESCENDANTNODE(page,'").append(queryLiteral(jcrSystemPath)).append("'))");
Review Comment:
Well, it's more readable than before; I didn't want to change too much at
once.
--
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]