Skip to content

Commit

Permalink
Search Beta fixes2 (#484)
Browse files Browse the repository at this point in the history
* Fix jackrabbit excpetion when repo name contains space
  • Loading branch information
xdavidson committed Dec 4, 2020
1 parent 6964cdd commit a64d0a4
Showing 1 changed file with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package com.redhat.pantheon.servlet;

import com.google.common.base.Strings;
import com.redhat.pantheon.jcr.JcrQueryHelper;
import com.redhat.pantheon.model.HashableFileResource;
import com.redhat.pantheon.model.module.*;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.jackrabbit.JcrConstants;
import org.apache.jackrabbit.util.ISO9075;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.apache.sling.api.resource.ResourceResolver;
Expand All @@ -21,6 +21,7 @@
import javax.servlet.Servlet;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import static com.google.common.base.Strings.isNullOrEmpty;
Expand Down Expand Up @@ -99,9 +100,13 @@ protected String getQuery(SlingHttpServletRequest request) {

StringBuilder queryBuilder = null;
if (repoParam != null) {
log.info("[" + ModuleListingServlet.class.getSimpleName() + "] contentTypeParam: " + contentTypeParam);
String repos = String.join(" | ", repoParam);
log.info("[" + ModuleListingServlet.class.getSimpleName() + "] repos: " + repos);
// encode if repo name contains space.
// https://www.mail-archive.com/[email protected]/msg05782.html
String repos = Arrays.stream(repoParam)
.map( repo -> {
return ISO9075.encode(repo);
})
.collect(Collectors.joining(" | "));
String contentType = contentTypeParam != null ? contentTypeParam : "pant:document";

queryBuilder = new StringBuilder()
Expand Down

0 comments on commit a64d0a4

Please sign in to comment.