Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
Fess Search engine
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jonas Leder
Fess Search engine
Commits
d8aacc5a
Commit
d8aacc5a
authored
May 20, 2017
by
Keiichi Watanabe
Browse files
Options
Downloads
Patches
Plain Diff
improve GitBucketDataStore to crawl issue comments
parent
b259965c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/org/codelibs/fess/ds/impl/GitBucketDataStoreImpl.java
+26
-2
26 additions, 2 deletions
...ava/org/codelibs/fess/ds/impl/GitBucketDataStoreImpl.java
with
26 additions
and
2 deletions
src/main/java/org/codelibs/fess/ds/impl/GitBucketDataStoreImpl.java
+
26
−
2
View file @
d8aacc5a
...
...
@@ -41,6 +41,9 @@ import org.elasticsearch.common.xcontent.json.JsonXContent;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.fasterxml.jackson.core.type.TypeReference
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
/**
* @author Keiichi Watanabe
*/
...
...
@@ -310,8 +313,8 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
logger
.
warn
(
"Failed to access to "
+
issueUrl
,
e
);
}
// FIXME: Get issue comments from `commentsUrl`
// How to parse JSON-style list?
final
String
commentsStr
=
String
.
join
(
"\n"
,
getIssueComments
(
issueUrl
,
authToken
));
contentStr
+=
"\n"
+
commentsStr
;
dataMap
.
put
(
"content"
,
contentStr
);
dataMap
.
put
(
"url"
,
viewUrl
);
...
...
@@ -325,6 +328,27 @@ public class GitBucketDataStoreImpl extends AbstractDataStoreImpl {
return
;
}
private
List
<
String
>
getIssueComments
(
final
String
issueUrl
,
final
String
authToken
)
{
final
String
commentsUrl
=
issueUrl
+
"/comments"
;
final
List
<
String
>
commentList
=
new
ArrayList
<
String
>();
try
(
CurlResponse
curlResponse
=
Curl
.
get
(
commentsUrl
).
header
(
"Authorization"
,
"token "
+
authToken
).
execute
())
{
final
String
commentsJson
=
curlResponse
.
getContentAsString
();
List
<
Map
<
String
,
Object
>>
comments
=
new
ObjectMapper
().
readValue
(
commentsJson
,
new
TypeReference
<
List
<
Map
<
String
,
Object
>>>()
{
});
for
(
Map
<
String
,
Object
>
comment
:
comments
)
{
if
(
comment
.
containsKey
(
"body"
))
{
commentList
.
add
((
String
)
comment
.
get
(
"body"
));
}
}
}
catch
(
final
Exception
e
)
{
logger
.
warn
(
"Failed to access to "
+
issueUrl
,
e
);
}
return
commentList
;
}
@SuppressWarnings
(
"unchecked"
)
private
void
storeWikiContents
(
final
String
rootURL
,
final
String
authToken
,
final
String
wikiLabel
,
final
String
owner
,
final
String
name
,
final
List
<
String
>
roleList
,
final
CrawlingConfig
crawlingConfig
,
final
IndexUpdateCallback
callback
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment