fix #1063
This commit is contained in:
parent
4bbe6df6b5
commit
da1c763771
1 changed files with 18 additions and 4 deletions
|
@ -16,6 +16,8 @@
|
|||
package org.codelibs.fess.ds.impl;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -27,6 +29,7 @@ import java.util.stream.Collectors;
|
|||
import org.codelibs.core.lang.StringUtil;
|
||||
import org.codelibs.elasticsearch.runner.net.Curl;
|
||||
import org.codelibs.elasticsearch.runner.net.CurlResponse;
|
||||
import org.codelibs.fess.Constants;
|
||||
import org.codelibs.fess.crawler.client.CrawlerClientFactory;
|
||||
import org.codelibs.fess.crawler.client.http.HcHttpClient;
|
||||
import org.codelibs.fess.crawler.client.http.RequestHeader;
|
||||
|
@ -221,7 +224,8 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
|
|||
}
|
||||
|
||||
protected String getGitRef(final String rootURL, final String authToken, final String owner, final String name, final String branch) {
|
||||
final String url = rootURL + "api/v3/repos/" + owner + "/" + name + "/git/refs/heads/" + branch;
|
||||
final String url = rootURL + "api/v3/repos/" + owner + "/" + name + "/git/refs/heads/" + encode(branch);
|
||||
|
||||
try (CurlResponse curlResponse = Curl.get(url).header("Authorization", "token " + authToken).execute()) {
|
||||
final Map<String, Object> map = curlResponse.getContentAsMap();
|
||||
assert (map.containsKey("object"));
|
||||
|
@ -292,7 +296,6 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
|
|||
final Map<String, Object> defaultDataMap) {
|
||||
|
||||
final String issueUrl = rootURL + "api/v3/repos/" + owner + "/" + name + "/issues/" + issueId.toString();
|
||||
// final String commentsUrl = issueUrl + "/comments";
|
||||
final String viewUrl = rootURL + owner + "/" + name + "/issues/" + issueId.toString();
|
||||
|
||||
if (logger.isInfoEnabled()) {
|
||||
|
@ -402,7 +405,7 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
|
|||
return;
|
||||
}
|
||||
|
||||
final String url = rootURL + "api/v3/repos/" + owner + "/" + name + "/contents/" + path + "?ref=" + refStr;
|
||||
final String url = rootURL + "api/v3/repos/" + owner + "/" + name + "/contents/" + encode(path) + "?ref=" + refStr;
|
||||
|
||||
try (CurlResponse curlResponse = Curl.get(url).header("Authorization", "token " + authToken).execute()) {
|
||||
final InputStream iStream = curlResponse.getContentAsStream();
|
||||
|
@ -411,7 +414,8 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
|
|||
for (int i = 0; i < fileList.size(); ++i) {
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<String, String> file = (Map<String, String>) fileList.get(i);
|
||||
final String newPath = path.isEmpty() ? file.get("name") : path + "/" + file.get("name");
|
||||
final String fname = encode(file.get("name"));
|
||||
final String newPath = path.isEmpty() ? fname : path + "/" + fname;
|
||||
switch (file.get("type")) {
|
||||
case "file":
|
||||
consumer.accept(newPath);
|
||||
|
@ -428,4 +432,14 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
|
|||
logger.warn("Failed to access to " + url, e);
|
||||
}
|
||||
}
|
||||
|
||||
private String encode(final String s) {
|
||||
try {
|
||||
final String encoded = URLEncoder.encode(s, Constants.UTF_8);
|
||||
return encoded;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
logger.warn("Failed to encode \"" + s + "\"", e);
|
||||
return s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue