fix #1058
This commit is contained in:
parent
7f79078a1c
commit
78f614e28e
1 changed files with 29 additions and 24 deletions
|
@ -184,32 +184,37 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected List<String> getSourceLabelList(final String rootURL, final String authToken) {
|
|
||||||
final String url = rootURL + "api/v3/fess/label";
|
|
||||||
try (CurlResponse curlResponse = Curl.get(url).header("Authorization", "token " + authToken).execute()) {
|
|
||||||
final Map<String, Object> map = curlResponse.getContentAsMap();
|
|
||||||
assert (map.containsKey("source_label"));
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
final List<String> sourceLabels = (List<String>) map.get("source_label");
|
|
||||||
return sourceLabels;
|
|
||||||
} catch (final Exception e) {
|
|
||||||
logger.warn("Failed to access to " + rootURL, e);
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected List<Map<String, Object>> getRepositoryList(final String rootURL, final String authToken) {
|
protected List<Map<String, Object>> getRepositoryList(final String rootURL, final String authToken) {
|
||||||
final String url = rootURL + "api/v3/fess/repos";
|
final String url = rootURL + "api/v3/fess/repos";
|
||||||
try (CurlResponse curlResponse = Curl.get(url).header("Authorization", "token " + authToken).execute()) {
|
int totalCount = -1; // initialize with dummy value
|
||||||
|
final List<Map<String, Object>> repoList = new ArrayList<>();
|
||||||
|
|
||||||
|
do {
|
||||||
|
final String urlWithOffset = url + "?offset=" + repoList.size();
|
||||||
|
|
||||||
|
try (CurlResponse curlResponse = Curl.get(urlWithOffset).header("Authorization", "token " + authToken).execute()) {
|
||||||
final Map<String, Object> map = curlResponse.getContentAsMap();
|
final Map<String, Object> map = curlResponse.getContentAsMap();
|
||||||
|
|
||||||
|
assert (map.containsKey("total_count"));
|
||||||
|
assert (map.containsKey("response_count"));
|
||||||
assert (map.containsKey("repositories"));
|
assert (map.containsKey("repositories"));
|
||||||
|
|
||||||
|
totalCount = (int) map.get("total_count");
|
||||||
|
int responseCount = (int) map.get("response_count");
|
||||||
|
if (responseCount == 0)
|
||||||
|
break;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final List<Map<String, Object>> repoList = (List<Map<String, Object>>) map.get("repositories");
|
List<Map<String, Object>> repos = (ArrayList<Map<String, Object>>) map.get("repositories");
|
||||||
return repoList;
|
repoList.addAll(repos);
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
logger.warn("Failed to access to " + rootURL, e);
|
logger.warn("Failed to access to " + rootURL, e);
|
||||||
return Collections.emptyList();
|
break;
|
||||||
}
|
}
|
||||||
|
} while (repoList.size() < totalCount);
|
||||||
|
|
||||||
|
logger.info("There exist " + repoList.size() + " repositories");
|
||||||
|
return repoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String getGitRef(final String rootURL, final String authToken, final String owner, final String name, final String branch) {
|
protected String getGitRef(final String rootURL, final String authToken, final String owner, final String name, final String branch) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue