Skip to content
Snippets Groups Projects
Commit 255ca5ff authored by Shinsuke Sugaya's avatar Shinsuke Sugaya
Browse files

fix #1666 replace with %20

parent 15b2b825
Branches
Tags
No related merge requests found
...@@ -119,7 +119,9 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl { ...@@ -119,7 +119,9 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
// branch is empty when git repository is empty. // branch is empty when git repository is empty.
if (StringUtil.isNotEmpty(branch)) { if (StringUtil.isNotEmpty(branch)) {
final String refStr = getGitRef(rootURL, authToken, owner, name, branch); final String refStr = getGitRef(rootURL, authToken, owner, name, branch);
if (logger.isInfoEnabled()) {
logger.info("Crawl " + owner + "/" + name); logger.info("Crawl " + owner + "/" + name);
}
// crawl and store file contents recursively // crawl and store file contents recursively
crawlFileContents( crawlFileContents(
rootURL, rootURL,
...@@ -139,7 +141,9 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl { ...@@ -139,7 +141,9 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
}); });
} }
if (logger.isInfoEnabled()) {
logger.info("Crawl issues in " + owner + "/" + name); logger.info("Crawl issues in " + owner + "/" + name);
}
// store issues // store issues
for (int issueId = 1; issueId <= issueCount + pullCount; issueId++) { for (int issueId = 1; issueId <= issueCount + pullCount; issueId++) {
storeIssueById(rootURL, authToken, issueLabel, owner, name, new Integer(issueId), roleList, crawlingConfig, callback, storeIssueById(rootURL, authToken, issueLabel, owner, name, new Integer(issueId), roleList, crawlingConfig, callback,
...@@ -150,7 +154,9 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl { ...@@ -150,7 +154,9 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
} }
} }
if (logger.isInfoEnabled()) {
logger.info("Crawl Wiki in " + owner + "/" + name); logger.info("Crawl Wiki in " + owner + "/" + name);
}
// crawl Wiki // crawl Wiki
storeWikiContents(rootURL, authToken, wikiLabel, owner, name, roleList, crawlingConfig, callback, paramMap, scriptMap, storeWikiContents(rootURL, authToken, wikiLabel, owner, name, roleList, crawlingConfig, callback, paramMap, scriptMap,
defaultDataMap, readInterval); defaultDataMap, readInterval);
...@@ -229,7 +235,9 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl { ...@@ -229,7 +235,9 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
} }
} while (repoList.size() < totalCount); } while (repoList.size() < totalCount);
if (logger.isInfoEnabled()) {
logger.info("There exist " + repoList.size() + " repositories"); logger.info("There exist " + repoList.size() + " repositories");
}
return repoList; return repoList;
} }
...@@ -389,7 +397,6 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl { ...@@ -389,7 +397,6 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
} }
for (final String page : pageList) { for (final String page : pageList) {
// FIXME: URL encoding (e.g. page name that contains spaces)
final String pageUrl = wikiUrl + "/contents/" + page + ".md"; final String pageUrl = wikiUrl + "/contents/" + page + ".md";
final String viewUrl = rootURL + owner + "/" + name + "/wiki/" + page; final String viewUrl = rootURL + owner + "/" + name + "/wiki/" + page;
...@@ -399,7 +406,8 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl { ...@@ -399,7 +406,8 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
final Map<String, Object> dataMap = new HashMap<>(); final Map<String, Object> dataMap = new HashMap<>();
dataMap.putAll(defaultDataMap); dataMap.putAll(defaultDataMap);
dataMap.putAll(ComponentUtil.getDocumentHelper().processRequest(crawlingConfig, paramMap.get("crawlingInfoId"), pageUrl)); dataMap.putAll(ComponentUtil.getDocumentHelper().processRequest(crawlingConfig, paramMap.get("crawlingInfoId"),
pageUrl.replace("+", "%20")));
dataMap.put("url", viewUrl); dataMap.put("url", viewUrl);
dataMap.put("role", roleList); dataMap.put("role", roleList);
...@@ -408,7 +416,9 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl { ...@@ -408,7 +416,9 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
// TODO scriptMap // TODO scriptMap
callback.store(paramMap, dataMap); callback.store(paramMap, dataMap);
logger.info("Stored " + pageUrl); if (logger.isDebugEnabled()) {
logger.debug("Stored " + pageUrl);
}
if (readInterval > 0) { if (readInterval > 0) {
sleep(readInterval); sleep(readInterval);
...@@ -453,7 +463,7 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl { ...@@ -453,7 +463,7 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
} }
} }
private String encode(final String rootURL, final String path, final String query) { protected String encode(final String rootURL, final String path, final String query) {
try { try {
final URI rootURI = new URI(rootURL); final URI rootURI = new URI(rootURL);
final URI uri = final URI uri =
......
/*
* Copyright 2012-2018 CodeLibs Project and the Others.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied. See the License for the specific language
* governing permissions and limitations under the License.
*/
package org.codelibs.fess.ds.impl;
import org.codelibs.fess.unit.UnitFessTestCase;
public class GitBucketDataStoreImplTest extends UnitFessTestCase {
public GitBucketDataStoreImpl dataStore;
@Override
public void setUp() throws Exception {
super.setUp();
dataStore = new GitBucketDataStoreImpl();
}
public void test_encode() {
String rootURL = "https://gitbucket.com/";
String path;
String query;
path = "api/v3/repos/";
query = "aaa=111";
assertEquals("https://gitbucket.com/api/v3/repos/?aaa=111", dataStore.encode(rootURL, path, query));
path = "api/v3/repos/AA BB";
query = "aaa=11 11";
assertEquals("https://gitbucket.com/api/v3/repos/AA%20BB?aaa=11%2011", dataStore.encode(rootURL, path, query));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment